diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/optimize-instructions_all-features.txt | 79 | ||||
-rw-r--r-- | test/passes/optimize-instructions_fuzz-exec.txt | 67 | ||||
-rw-r--r-- | test/passes/optimize-instructions_fuzz-exec.wast | 78 |
3 files changed, 176 insertions, 48 deletions
diff --git a/test/passes/optimize-instructions_all-features.txt b/test/passes/optimize-instructions_all-features.txt index 3b557693d..d6c98bc0a 100644 --- a/test/passes/optimize-instructions_all-features.txt +++ b/test/passes/optimize-instructions_all-features.txt @@ -896,21 +896,19 @@ ) ) (drop - (i32.eq - (i32.and + (block (result i32) + (drop (local.get $0) - (i32.const 255) ) - (i32.const -2147483648) + (i32.const 0) ) ) (drop - (i32.eq - (i32.and + (block (result i32) + (drop (local.get $0) - (i32.const 255) ) - (i32.const 107) + (i32.const 0) ) ) (drop @@ -1458,30 +1456,27 @@ ) (func $sign-ext-ne (param $0 i32) (param $1 i32) (drop - (i32.ne - (i32.and + (block (result i32) + (drop (local.get $0) - (i32.const 255) ) - (i32.const -2147483648) + (i32.const 1) ) ) (drop - (i32.ne - (i32.and + (block (result i32) + (drop (local.get $0) - (i32.const 255) ) - (i32.const -2147483648) + (i32.const 1) ) ) (drop - (i32.ne - (i32.and + (block (result i32) + (drop (local.get $0) - (i32.const 255) ) - (i32.const 107) + (i32.const 1) ) ) (drop @@ -2176,21 +2171,19 @@ ) (func $fuzz-comp-impossible (param $x i32) (drop - (i32.eq - (i32.and + (block (result i32) + (drop (local.get $x) - (i32.const 65535) ) - (i32.const -2147483648) + (i32.const 0) ) ) (drop - (i32.eq - (i32.and + (block (result i32) + (drop (local.get $x) - (i32.const 255) ) - (i32.const -2147483648) + (i32.const 0) ) ) (drop @@ -2203,30 +2196,27 @@ ) ) (drop - (i32.eq - (i32.and + (block (result i32) + (drop (local.get $x) - (i32.const 255) ) - (i32.const -2147483648) + (i32.const 0) ) ) (drop - (i32.eq - (i32.and + (block (result i32) + (drop (local.get $x) - (i32.const 255) ) - (i32.const -2147483648) + (i32.const 0) ) ) (drop - (i32.eq - (i32.and + (block (result i32) + (drop (local.get $x) - (i32.const 255) ) - (i32.const -2147483648) + (i32.const 0) ) ) (drop @@ -2401,13 +2391,10 @@ ) ) (func $sign-ext-1-and-ne (result i32) - (i32.ne - (i32.and - (call $sign-ext-1-and-ne) - (i32.const 2147483647) - ) - (i32.const -2147483648) + (drop + (call $sign-ext-1-and-ne) ) + (i32.const 1) ) (func $neg-shifts-and-255 (result i32) (i32.and diff --git a/test/passes/optimize-instructions_fuzz-exec.txt b/test/passes/optimize-instructions_fuzz-exec.txt index 5da803fb1..e8985222d 100644 --- a/test/passes/optimize-instructions_fuzz-exec.txt +++ b/test/passes/optimize-instructions_fuzz-exec.txt @@ -257,11 +257,46 @@ [LoggingExternalInterface logging 1] [LoggingExternalInterface logging 1] [LoggingExternalInterface logging 0] +[fuzz-exec] calling call-compare-maybe-signed-eq +[fuzz-exec] note result: call-compare-maybe-signed-eq => 0 +[fuzz-exec] calling call-compare-maybe-signed-ne +[fuzz-exec] note result: call-compare-maybe-signed-ne => 1 (module (type $i32_=>_none (func (param i32))) + (type $none_=>_i32 (func (result i32))) + (type $i32_=>_i32 (func (param i32) (result i32))) + (type $none_=>_none (func)) (import "fuzzing-support" "log-i32" (func $log (param i32))) - (export "foo" (func $0)) - (func $0 (param $0 i32) + (export "foo" (func $1)) + (export "call-compare-maybe-signed-eq" (func $3)) + (export "call-compare-maybe-signed-ne" (func $5)) + (func $signed-comparison-to-unsigned + (call $log + (block (result i32) + (drop + (i32.const -25749) + ) + (i32.const 0) + ) + ) + (call $log + (block (result i32) + (drop + (i32.const -25749) + ) + (i32.const 0) + ) + ) + (call $log + (block (result i32) + (drop + (i32.const -25749) + ) + (i32.const 1) + ) + ) + ) + (func $1 (param $0 i32) (call $log (i32.le_s (i32.sub @@ -286,8 +321,36 @@ ) ) ) + (func $compare-maybe-signed-eq (param $0 i32) (result i32) + (drop + (local.get $0) + ) + (i32.const 0) + ) + (func $3 (result i32) + (call $compare-maybe-signed-eq + (i32.const 128) + ) + ) + (func $compare-maybe-signed-ne (param $0 i32) (result i32) + (drop + (local.get $0) + ) + (i32.const 1) + ) + (func $5 (result i32) + (call $compare-maybe-signed-ne + (i32.const 128) + ) + ) ) [fuzz-exec] calling foo [LoggingExternalInterface logging 1] [LoggingExternalInterface logging 1] [LoggingExternalInterface logging 0] +[fuzz-exec] calling call-compare-maybe-signed-eq +[fuzz-exec] note result: call-compare-maybe-signed-eq => 0 +[fuzz-exec] calling call-compare-maybe-signed-ne +[fuzz-exec] note result: call-compare-maybe-signed-ne => 1 +[fuzz-exec] comparing call-compare-maybe-signed-eq +[fuzz-exec] comparing call-compare-maybe-signed-ne 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) + ) + ) ) |