summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai (kripken) <alonzakai@gmail.com>2017-02-12 17:06:34 -0800
committerAlon Zakai (kripken) <alonzakai@gmail.com>2017-02-16 22:45:38 -0800
commit8a4edd97499120430fe1c6f2fdcbb0f5920cceab (patch)
treeb78556b69485b63aaac42dbcd0cd31e9a39eec1c /test
parent6affe6fb4d06550a40b4d73efe19c085317854d7 (diff)
downloadbinaryen-8a4edd97499120430fe1c6f2fdcbb0f5920cceab.tar.gz
binaryen-8a4edd97499120430fe1c6f2fdcbb0f5920cceab.tar.bz2
binaryen-8a4edd97499120430fe1c6f2fdcbb0f5920cceab.zip
handle fallthrough values in load_s/u and sign/zero-extend optimization
Diffstat (limited to 'test')
-rw-r--r--test/emcc_hello_world.fromasm36
-rw-r--r--test/emcc_hello_world.fromasm.imprecise36
-rw-r--r--test/passes/optimize-instructions.txt37
-rw-r--r--test/passes/optimize-instructions.wast47
4 files changed, 108 insertions, 48 deletions
diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm
index e90c9c008..78f0460fa 100644
--- a/test/emcc_hello_world.fromasm
+++ b/test/emcc_hello_world.fromasm
@@ -2632,21 +2632,15 @@
(i32.lt_u
(tee_local $8
(i32.add
- (i32.shr_s
- (i32.shl
- (tee_local $11
- (i32.load8_s
- (tee_local $10
- (i32.add
- (get_local $6)
- (i32.const 1)
- )
- )
+ (tee_local $11
+ (i32.load8_s
+ (tee_local $10
+ (i32.add
+ (get_local $6)
+ (i32.const 1)
)
)
- (i32.const 24)
)
- (i32.const 24)
)
(i32.const -48)
)
@@ -2772,21 +2766,15 @@
(i32.eq
(i32.and
(tee_local $6
- (i32.shr_s
- (i32.shl
- (tee_local $1
- (i32.load8_s
- (tee_local $10
- (i32.add
- (get_local $10)
- (i32.const 1)
- )
- )
+ (tee_local $1
+ (i32.load8_s
+ (tee_local $10
+ (i32.add
+ (get_local $10)
+ (i32.const 1)
)
)
- (i32.const 24)
)
- (i32.const 24)
)
)
(i32.const -32)
diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise
index 8a5ce0b89..ba1a50ca7 100644
--- a/test/emcc_hello_world.fromasm.imprecise
+++ b/test/emcc_hello_world.fromasm.imprecise
@@ -2575,21 +2575,15 @@
(i32.lt_u
(tee_local $8
(i32.add
- (i32.shr_s
- (i32.shl
- (tee_local $11
- (i32.load8_s
- (tee_local $10
- (i32.add
- (get_local $6)
- (i32.const 1)
- )
- )
+ (tee_local $11
+ (i32.load8_s
+ (tee_local $10
+ (i32.add
+ (get_local $6)
+ (i32.const 1)
)
)
- (i32.const 24)
)
- (i32.const 24)
)
(i32.const -48)
)
@@ -2715,21 +2709,15 @@
(i32.eq
(i32.and
(tee_local $6
- (i32.shr_s
- (i32.shl
- (tee_local $1
- (i32.load8_s
- (tee_local $10
- (i32.add
- (get_local $10)
- (i32.const 1)
- )
- )
+ (tee_local $1
+ (i32.load8_s
+ (tee_local $10
+ (i32.add
+ (get_local $10)
+ (i32.const 1)
)
)
- (i32.const 24)
)
- (i32.const 24)
)
)
(i32.const -32)
diff --git a/test/passes/optimize-instructions.txt b/test/passes/optimize-instructions.txt
index 01f1070f7..e4ab82365 100644
--- a/test/passes/optimize-instructions.txt
+++ b/test/passes/optimize-instructions.txt
@@ -1237,5 +1237,42 @@
(i32.const 256)
)
)
+ (drop
+ (tee_local $1
+ (i32.load8_s
+ (i32.const 1)
+ )
+ )
+ )
+ (drop
+ (i32.shr_s
+ (i32.shl
+ (tee_local $1
+ (i32.load8_u
+ (i32.const 1)
+ )
+ )
+ (i32.const 24)
+ )
+ (i32.const 24)
+ )
+ )
+ (drop
+ (i32.and
+ (tee_local $1
+ (i32.load8_s
+ (i32.const 1)
+ )
+ )
+ (i32.const 255)
+ )
+ )
+ (drop
+ (tee_local $1
+ (i32.load8_u
+ (i32.const 1)
+ )
+ )
+ )
)
)
diff --git a/test/passes/optimize-instructions.wast b/test/passes/optimize-instructions.wast
index 9cdec0a6c..7cfcd7a0d 100644
--- a/test/passes/optimize-instructions.wast
+++ b/test/passes/optimize-instructions.wast
@@ -1562,5 +1562,52 @@
(i32.const 16)
)
)
+ ;; through tees, we cannot alter the load sign
+ (drop
+ (i32.shr_s
+ (i32.shl
+ (tee_local $1
+ (i32.load8_s
+ (i32.const 1)
+ )
+ )
+ (i32.const 24)
+ )
+ (i32.const 24)
+ )
+ )
+ (drop
+ (i32.shr_s
+ (i32.shl
+ (tee_local $1
+ (i32.load8_u
+ (i32.const 1)
+ )
+ )
+ (i32.const 24)
+ )
+ (i32.const 24)
+ )
+ )
+ (drop
+ (i32.and
+ (tee_local $1
+ (i32.load8_s
+ (i32.const 1)
+ )
+ )
+ (i32.const 255)
+ )
+ )
+ (drop
+ (i32.and
+ (tee_local $1
+ (i32.load8_u
+ (i32.const 1)
+ )
+ )
+ (i32.const 255)
+ )
+ )
)
)