summaryrefslogtreecommitdiff
path: root/test/passes/optimize-instructions_fuzz-exec.wast
diff options
context:
space:
mode:
Diffstat (limited to 'test/passes/optimize-instructions_fuzz-exec.wast')
-rw-r--r--test/passes/optimize-instructions_fuzz-exec.wast78
1 files changed, 78 insertions, 0 deletions
diff --git a/test/passes/optimize-instructions_fuzz-exec.wast b/test/passes/optimize-instructions_fuzz-exec.wast
index 8d2e1beee..8bd43b694 100644
--- a/test/passes/optimize-instructions_fuzz-exec.wast
+++ b/test/passes/optimize-instructions_fuzz-exec.wast
@@ -205,6 +205,47 @@
)
(module
(import "fuzzing-support" "log-i32" (func $log (param i32)))
+ (func $signed-comparison-to-unsigned
+ (call $log
+ (i32.eq ;; should be false
+ (i32.shr_s ;; 0x0000006b after the sign-extend
+ (i32.shl
+ (i32.const -25749) ;; 0xffff9b6b
+ (i32.const 24)
+ )
+ (i32.const 24)
+ )
+ (i32.const -149) ;; 0xffffff6b - high bits are set, but not sign bit
+ )
+ )
+ ;; the same, with mixed high bits. mixed bits mean the two sides can never be
+ ;; equal, so the eq is always false
+ (call $log
+ (i32.eq
+ (i32.shr_s
+ (i32.shl
+ (i32.const -25749)
+ (i32.const 24)
+ )
+ (i32.const 24)
+ )
+ (i32.const 0xffffeb)
+ )
+ )
+ ;; the same, with !=, so the result is always true
+ (call $log
+ (i32.ne
+ (i32.shr_s
+ (i32.shl
+ (i32.const -25749)
+ (i32.const 24)
+ )
+ (i32.const 24)
+ )
+ (i32.const 0xffffeb)
+ )
+ )
+ )
(func "foo" (param $0 i32)
;; 8 - 0x80000000 < 0
;;
@@ -246,4 +287,41 @@
)
)
)
+ ;; similar, but with the value compared to having the sign bit set but no
+ ;; upper bits
+ (func $compare-maybe-signed-eq (param $0 i32) (result i32)
+ (i32.eq
+ (i32.shr_s
+ (i32.shl
+ (local.get $0)
+ (i32.const 24)
+ )
+ (i32.const 24)
+ )
+ (i32.const 128)
+ )
+ )
+ (func "call-compare-maybe-signed-eq" (result i32)
+ (call $compare-maybe-signed-eq
+ (i32.const 128)
+ )
+ )
+ ;; the same with !=
+ (func $compare-maybe-signed-ne (param $0 i32) (result i32)
+ (i32.ne
+ (i32.shr_s
+ (i32.shl
+ (local.get $0)
+ (i32.const 24)
+ )
+ (i32.const 24)
+ )
+ (i32.const 128)
+ )
+ )
+ (func "call-compare-maybe-signed-ne" (result i32)
+ (call $compare-maybe-signed-ne
+ (i32.const 128)
+ )
+ )
)