diff options
author | Max Graey <maxgraey@gmail.com> | 2022-06-07 21:34:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-07 11:34:23 -0700 |
commit | 82d82f1a4e9aa1ce1b80acbab4a95262ec7782ae (patch) | |
tree | cb552d37428b75738681030291cf65d11e195c97 /test/lit/passes/optimize-instructions-sign-ext.wast | |
parent | ec88ea6df0925ae0e648b26d327239e946de48a6 (diff) | |
download | binaryen-82d82f1a4e9aa1ce1b80acbab4a95262ec7782ae.tar.gz binaryen-82d82f1a4e9aa1ce1b80acbab4a95262ec7782ae.tar.bz2 binaryen-82d82f1a4e9aa1ce1b80acbab4a95262ec7782ae.zip |
[Optimize Instructions] Simplify sign extentions (Part 2) (#4382)
Similar to #4004 but for 32-bit integers
i32(x) << 24 >> 24 ==> i32.extend8_s(x)
i32(x) << 16 >> 16 ==> i32.extend16_s(x)
Diffstat (limited to 'test/lit/passes/optimize-instructions-sign-ext.wast')
-rw-r--r-- | test/lit/passes/optimize-instructions-sign-ext.wast | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/test/lit/passes/optimize-instructions-sign-ext.wast b/test/lit/passes/optimize-instructions-sign-ext.wast index 0b3396735..70572e616 100644 --- a/test/lit/passes/optimize-instructions-sign-ext.wast +++ b/test/lit/passes/optimize-instructions-sign-ext.wast @@ -62,4 +62,75 @@ (drop (i64.shr_s (i64.shl (local.get $x) (i64.const 16)) (i64.const 16))) ;; skip (drop (i64.extend_i32_s (i32.wrap_i64 (local.get $x)))) ) + + ;; i32(x) << 24 >> 24 ==> i32.extend8_s(x) + ;; i32(x) << 16 >> 16 ==> i32.extend16_s(x) + + ;; CHECK: (func $i32-sign-extentions (param $x i32) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.extend8_s + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.extend16_s + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.shr_s + ;; CHECK-NEXT: (i32.shl + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: (i32.const 8) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 8) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.shr_u + ;; CHECK-NEXT: (i32.shl + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: (i32.const 24) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 24) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.shr_u + ;; CHECK-NEXT: (i32.shl + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: (i32.const 16) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 16) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.shr_s + ;; CHECK-NEXT: (i32.shl + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: (i32.const 16) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 24) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.shr_s + ;; CHECK-NEXT: (i32.shl + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: (i32.const 24) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 16) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $i32-sign-extentions (param $x i32) + (drop (i32.shr_s (i32.shl (local.get $x) (i32.const 24)) (i32.const 24))) + (drop (i32.shr_s (i32.shl (local.get $x) (i32.const 16)) (i32.const 16))) + + (drop (i32.shr_s (i32.shl (local.get $x) (i32.const 8)) (i32.const 8))) ;; skip + (drop (i32.shr_u (i32.shl (local.get $x) (i32.const 24)) (i32.const 24))) ;; skip + (drop (i32.shr_u (i32.shl (local.get $x) (i32.const 16)) (i32.const 16))) ;; skip + (drop (i32.shr_s (i32.shl (local.get $x) (i32.const 16)) (i32.const 24))) ;; skip + (drop (i32.shr_s (i32.shl (local.get $x) (i32.const 24)) (i32.const 16))) ;; skip + ) ) |