From 977d653f9801b3eedc7dd667e4068573e73d2bb5 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 17 Nov 2022 15:00:28 -0800 Subject: [Wasm GC] Start an OptimizeCasts pass and reuse cast values there (#5263) (some.operation (ref.cast .. (local.get $ref)) (local.get $ref) ) => (some.operation (local.tee $temp (ref.cast .. (local.get $ref)) ) (local.get $temp) ) This can help cases where we cast for some reason but happen to not use the cast value in all places. This occurs in j2wasm in itable calls sometimes: The this pointer is is refined, but the itable may be done with an unrefined pointer, which is less optimizable. So far this is just inside basic blocks, but that is enough for the cast of itable calls and other common patterns I see. --- test/lit/help/wasm2js.test | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/lit/help/wasm2js.test') diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test index e5669563d..ce2748343 100644 --- a/test/lit/help/wasm2js.test +++ b/test/lit/help/wasm2js.test @@ -255,6 +255,8 @@ ;; CHECK-NEXT: load/store offsets, propagating ;; CHECK-NEXT: them across locals too ;; CHECK-NEXT: +;; CHECK-NEXT: --optimize-casts eliminate and reuse casts +;; CHECK-NEXT: ;; CHECK-NEXT: --optimize-for-js early optimize of the ;; CHECK-NEXT: instruction combinations for js ;; CHECK-NEXT: -- cgit v1.2.3