diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/optimize-instructions-gc-heap.wast | 66 |
1 files changed, 54 insertions, 12 deletions
diff --git a/test/lit/passes/optimize-instructions-gc-heap.wast b/test/lit/passes/optimize-instructions-gc-heap.wast index 6db63fae3..2988b1bd8 100644 --- a/test/lit/passes/optimize-instructions-gc-heap.wast +++ b/test/lit/passes/optimize-instructions-gc-heap.wast @@ -9,11 +9,10 @@ ;; CHECK: (type $struct (struct (field (mut i32)))) (type $struct (struct (field (mut i32)))) - ;; CHECK: (type $struct3 (struct (field (mut i32)) (field (mut i32)) (field (mut i32)))) - ;; CHECK: (type $struct2 (struct (field (mut i32)) (field (mut i32)))) (type $struct2 (struct (field (mut i32)) (field (mut i32)))) + ;; CHECK: (type $struct3 (struct (field (mut i32)) (field (mut i32)) (field (mut i32)))) (type $struct3 (struct (field (mut i32)) (field (mut i32)) (field (mut i32)))) ;; CHECK: (func $tee (type $1) @@ -272,12 +271,15 @@ ;; CHECK: (func $pattern-breaker (type $1) ;; CHECK-NEXT: (local $ref (ref null $struct)) + ;; CHECK-NEXT: (local $ref2 (ref null $struct)) ;; CHECK-NEXT: (local.set $ref ;; CHECK-NEXT: (struct.new $struct ;; CHECK-NEXT: (i32.const 10) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (local.set $ref2 + ;; CHECK-NEXT: (local.get $ref) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: (struct.set $struct 0 ;; CHECK-NEXT: (local.get $ref) ;; CHECK-NEXT: (i32.const 20) @@ -285,13 +287,56 @@ ;; CHECK-NEXT: ) (func $pattern-breaker (local $ref (ref null $struct)) + (local $ref2 (ref null $struct)) + (local.set $ref + (struct.new $struct + (i32.const 10) + ) + ) + ;; Any instruction that can not be swapped and is not + ;; the expected struct.set breaks the pattern. + (local.set $ref2 (local.get $ref)) + (struct.set $struct 0 + (local.get $ref) + (i32.const 20) + ) + ) + + ;; CHECK: (func $dont-swap-subsequent-struct-new (type $1) + ;; CHECK-NEXT: (local $ref (ref null $struct)) + ;; CHECK-NEXT: (local $ref2 (ref null $struct)) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (local.set $ref + ;; CHECK-NEXT: (struct.new $struct + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $ref2 + ;; CHECK-NEXT: (struct.new $struct + ;; CHECK-NEXT: (i32.const 20) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (struct.set $struct 0 + ;; CHECK-NEXT: (local.get $ref) + ;; CHECK-NEXT: (i32.const 20) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $dont-swap-subsequent-struct-new + (local $ref (ref null $struct)) + (local $ref2 (ref null $struct)) (local.set $ref (struct.new $struct (i32.const 10) ) ) - ;; Anything that we don't recognize breaks the pattern. (nop) + ;; We do not swap with another local.set of struct.new. + (local.set $ref2 + (struct.new $struct + (i32.const 20) + ) + ) + ;; last instruction in the block won't be swapped. (struct.set $struct 0 (local.get $ref) (i32.const 20) @@ -611,20 +656,17 @@ ;; CHECK: (func $many-news (type $1) ;; CHECK-NEXT: (local $ref (ref null $struct3)) ;; CHECK-NEXT: (local $ref2 (ref null $struct3)) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: (local.set $ref ;; CHECK-NEXT: (struct.new $struct3 ;; CHECK-NEXT: (i32.const 40) ;; CHECK-NEXT: (i32.const 50) - ;; CHECK-NEXT: (i32.const 30) + ;; CHECK-NEXT: (i32.const 60) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (nop) - ;; CHECK-NEXT: (nop) - ;; CHECK-NEXT: (struct.set $struct3 2 - ;; CHECK-NEXT: (local.get $ref) - ;; CHECK-NEXT: (i32.const 60) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: (local.set $ref ;; CHECK-NEXT: (struct.new $struct3 ;; CHECK-NEXT: (i32.const 400) |