diff options
author | Alon Zakai <azakai@google.com> | 2024-09-17 11:25:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-17 11:25:18 -0700 |
commit | 0da6d3e5b729e1fe7cc608720dc3d428fefcdb03 (patch) | |
tree | c73621438a93434f61407c55a2fe573fc28fb6f9 /test | |
parent | 34ad6a7598e662e9ff357987f2c81fde1e05c522 (diff) | |
download | binaryen-0da6d3e5b729e1fe7cc608720dc3d428fefcdb03.tar.gz binaryen-0da6d3e5b729e1fe7cc608720dc3d428fefcdb03.tar.bz2 binaryen-0da6d3e5b729e1fe7cc608720dc3d428fefcdb03.zip |
Fix selects of packed fields in GlobalStructOptimization (#6947)
We emit a select between two objects when only two objects exist of a
particular type. However, if the field is packed, we did not handle truncating the
written values.
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/gsi.wast | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/lit/passes/gsi.wast b/test/lit/passes/gsi.wast index 57d8137f4..299b19e00 100644 --- a/test/lit/passes/gsi.wast +++ b/test/lit/passes/gsi.wast @@ -1895,3 +1895,52 @@ ) ) ) + +;; Test packed fields. +(module + ;; CHECK: (type $struct (struct (field i8))) + (type $struct (struct (field i8))) + + ;; CHECK: (type $1 (func (result i32))) + + ;; CHECK: (global $A (ref $struct) (struct.new $struct + ;; CHECK-NEXT: (i32.const 257) + ;; CHECK-NEXT: )) + (global $A (ref $struct) (struct.new $struct + (i32.const 257) + )) + + ;; CHECK: (global $B (ref $struct) (struct.new $struct + ;; CHECK-NEXT: (i32.const 258) + ;; CHECK-NEXT: )) + (global $B (ref $struct) (struct.new $struct + (i32.const 258) + )) + + ;; CHECK: (func $test (type $1) (result i32) + ;; CHECK-NEXT: (select + ;; CHECK-NEXT: (i32.and + ;; CHECK-NEXT: (i32.const 257) + ;; CHECK-NEXT: (i32.const 255) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.and + ;; CHECK-NEXT: (i32.const 258) + ;; CHECK-NEXT: (i32.const 255) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (ref.eq + ;; CHECK-NEXT: (ref.as_non_null + ;; CHECK-NEXT: (global.get $A) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (global.get $A) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $test (result i32) + ;; We can infer this value is one of two things since only two objects exist + ;; of this type. We must emit the proper truncated value for them, as the + ;; values are truncated into i8. + (struct.get_u $struct 0 + (global.get $A) + ) + ) +) |