diff options
Diffstat (limited to 'test')
26 files changed, 776 insertions, 495 deletions
diff --git a/test/debugInfo.fromasm b/test/debugInfo.fromasm index 70d5183e7..af058db39 100644 --- a/test/debugInfo.fromasm +++ b/test/debugInfo.fromasm @@ -74,16 +74,8 @@ (get_local $0) (i32.const 0) ) - (block - (set_local $4 - (i32.const 0) - ) - (set_local $2 - (i32.const 0) - ) - (set_local $3 - (i32.const 1) - ) + (set_local $3 + (i32.const 1) ) (block (set_local $1 diff --git a/test/debugInfo.fromasm.clamp b/test/debugInfo.fromasm.clamp index 70d5183e7..af058db39 100644 --- a/test/debugInfo.fromasm.clamp +++ b/test/debugInfo.fromasm.clamp @@ -74,16 +74,8 @@ (get_local $0) (i32.const 0) ) - (block - (set_local $4 - (i32.const 0) - ) - (set_local $2 - (i32.const 0) - ) - (set_local $3 - (i32.const 1) - ) + (set_local $3 + (i32.const 1) ) (block (set_local $1 diff --git a/test/debugInfo.fromasm.clamp.map b/test/debugInfo.fromasm.clamp.map index 6fb01998b..ecc297b63 100644 --- a/test/debugInfo.fromasm.clamp.map +++ b/test/debugInfo.fromasm.clamp.map @@ -1 +1 @@ -{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c","(unknown)"],"names":[],"mappings":"iLC8ylTA,QC7vlTA,OAkDA,UCnGA,OACA,OACA,uBCAA,wBAKA,MAJA,OADA,0BAKA,0FCsi1DA,KCrvyDA"}
\ No newline at end of file +{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c","(unknown)"],"names":[],"mappings":"iLC8ylTA,QC7vlTA,OAkDA,UCnGA,OACA,OACA,uBCAA,gBAKA,MAJA,OADA,0BAKA,0FCsi1DA,KCrvyDA"}
\ No newline at end of file diff --git a/test/debugInfo.fromasm.imprecise b/test/debugInfo.fromasm.imprecise index 5db316589..390aa7f1e 100644 --- a/test/debugInfo.fromasm.imprecise +++ b/test/debugInfo.fromasm.imprecise @@ -66,16 +66,8 @@ (get_local $0) (i32.const 0) ) - (block - (set_local $4 - (i32.const 0) - ) - (set_local $2 - (i32.const 0) - ) - (set_local $3 - (i32.const 1) - ) + (set_local $3 + (i32.const 1) ) (block (set_local $1 diff --git a/test/debugInfo.fromasm.imprecise.map b/test/debugInfo.fromasm.imprecise.map index b7ca07106..5efd89334 100644 --- a/test/debugInfo.fromasm.imprecise.map +++ b/test/debugInfo.fromasm.imprecise.map @@ -1 +1 @@ -{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c","(unknown)"],"names":[],"mappings":"iLC8ylTA,QC7vlTA,OAkDA,QCnGA,OACA,OACA,aCAA,wBAKA,MAJA,OADA,0BAKA,0FCsi1DA,KCrvyDA"}
\ No newline at end of file +{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c","(unknown)"],"names":[],"mappings":"iLC8ylTA,QC7vlTA,OAkDA,QCnGA,OACA,OACA,aCAA,gBAKA,MAJA,OADA,0BAKA,0FCsi1DA,KCrvyDA"}
\ No newline at end of file diff --git a/test/debugInfo.fromasm.map b/test/debugInfo.fromasm.map index 6fb01998b..ecc297b63 100644 --- a/test/debugInfo.fromasm.map +++ b/test/debugInfo.fromasm.map @@ -1 +1 @@ -{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c","(unknown)"],"names":[],"mappings":"iLC8ylTA,QC7vlTA,OAkDA,UCnGA,OACA,OACA,uBCAA,wBAKA,MAJA,OADA,0BAKA,0FCsi1DA,KCrvyDA"}
\ No newline at end of file +{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c","(unknown)"],"names":[],"mappings":"iLC8ylTA,QC7vlTA,OAkDA,UCnGA,OACA,OACA,uBCAA,gBAKA,MAJA,OADA,0BAKA,0FCsi1DA,KCrvyDA"}
\ No newline at end of file diff --git a/test/emcc_O2_hello_world.fromasm b/test/emcc_O2_hello_world.fromasm index c9bb769e0..aa1a08dc6 100644 --- a/test/emcc_O2_hello_world.fromasm +++ b/test/emcc_O2_hello_world.fromasm @@ -894,12 +894,7 @@ (set_local $5 (get_local $11) ) - (block - (set_local $19 - (i32.const 0) - ) - (br $do-once4) - ) + (br $do-once4) ) ) (loop $while-in7 @@ -1524,9 +1519,6 @@ (set_local $10 (get_local $15) ) - (set_local $5 - (i32.const 0) - ) (loop $while-in14 (if (i32.lt_u @@ -1655,12 +1647,6 @@ (set_local $33 (get_local $0) ) - (set_local $6 - (i32.const 0) - ) - (set_local $30 - (i32.const 0) - ) (set_local $7 (i32.const 86) ) @@ -2006,12 +1992,7 @@ (set_local $1 (get_local $15) ) - (block - (set_local $8 - (i32.const 0) - ) - (br $do-once17) - ) + (br $do-once17) ) ) (loop $while-in20 @@ -4049,12 +4030,7 @@ (set_local $0 (get_local $16) ) - (block - (set_local $24 - (i32.const 0) - ) - (br $do-once47) - ) + (br $do-once47) ) ) (loop $while-in50 @@ -6244,7 +6220,7 @@ (get_local $7) ) ) - (if + (br_if $do-once0 (i32.eqz (tee_local $0 (i32.load @@ -6252,12 +6228,6 @@ ) ) ) - (block - (set_local $6 - (i32.const 0) - ) - (br $do-once0) - ) ) ) (loop $while-in @@ -6804,12 +6774,7 @@ (set_local $3 (get_local $0) ) - (block - (set_local $12 - (i32.const 0) - ) - (br $do-once6) - ) + (br $do-once6) ) ) (loop $while-in9 @@ -8126,11 +8091,10 @@ ) ) (if - (call $___towrite - (get_local $2) - ) - (set_local $4 - (i32.const 0) + (i32.eqz + (call $___towrite + (get_local $2) + ) ) (block (set_local $6 diff --git a/test/emcc_O2_hello_world.fromasm.clamp b/test/emcc_O2_hello_world.fromasm.clamp index c9bb769e0..aa1a08dc6 100644 --- a/test/emcc_O2_hello_world.fromasm.clamp +++ b/test/emcc_O2_hello_world.fromasm.clamp @@ -894,12 +894,7 @@ (set_local $5 (get_local $11) ) - (block - (set_local $19 - (i32.const 0) - ) - (br $do-once4) - ) + (br $do-once4) ) ) (loop $while-in7 @@ -1524,9 +1519,6 @@ (set_local $10 (get_local $15) ) - (set_local $5 - (i32.const 0) - ) (loop $while-in14 (if (i32.lt_u @@ -1655,12 +1647,6 @@ (set_local $33 (get_local $0) ) - (set_local $6 - (i32.const 0) - ) - (set_local $30 - (i32.const 0) - ) (set_local $7 (i32.const 86) ) @@ -2006,12 +1992,7 @@ (set_local $1 (get_local $15) ) - (block - (set_local $8 - (i32.const 0) - ) - (br $do-once17) - ) + (br $do-once17) ) ) (loop $while-in20 @@ -4049,12 +4030,7 @@ (set_local $0 (get_local $16) ) - (block - (set_local $24 - (i32.const 0) - ) - (br $do-once47) - ) + (br $do-once47) ) ) (loop $while-in50 @@ -6244,7 +6220,7 @@ (get_local $7) ) ) - (if + (br_if $do-once0 (i32.eqz (tee_local $0 (i32.load @@ -6252,12 +6228,6 @@ ) ) ) - (block - (set_local $6 - (i32.const 0) - ) - (br $do-once0) - ) ) ) (loop $while-in @@ -6804,12 +6774,7 @@ (set_local $3 (get_local $0) ) - (block - (set_local $12 - (i32.const 0) - ) - (br $do-once6) - ) + (br $do-once6) ) ) (loop $while-in9 @@ -8126,11 +8091,10 @@ ) ) (if - (call $___towrite - (get_local $2) - ) - (set_local $4 - (i32.const 0) + (i32.eqz + (call $___towrite + (get_local $2) + ) ) (block (set_local $6 diff --git a/test/emcc_O2_hello_world.fromasm.imprecise b/test/emcc_O2_hello_world.fromasm.imprecise index 21e641976..af05b1e3f 100644 --- a/test/emcc_O2_hello_world.fromasm.imprecise +++ b/test/emcc_O2_hello_world.fromasm.imprecise @@ -893,12 +893,7 @@ (set_local $5 (get_local $11) ) - (block - (set_local $19 - (i32.const 0) - ) - (br $do-once4) - ) + (br $do-once4) ) ) (loop $while-in7 @@ -1523,9 +1518,6 @@ (set_local $10 (get_local $15) ) - (set_local $5 - (i32.const 0) - ) (loop $while-in14 (if (i32.lt_u @@ -1654,12 +1646,6 @@ (set_local $33 (get_local $0) ) - (set_local $6 - (i32.const 0) - ) - (set_local $30 - (i32.const 0) - ) (set_local $7 (i32.const 86) ) @@ -2005,12 +1991,7 @@ (set_local $1 (get_local $15) ) - (block - (set_local $8 - (i32.const 0) - ) - (br $do-once17) - ) + (br $do-once17) ) ) (loop $while-in20 @@ -4048,12 +4029,7 @@ (set_local $0 (get_local $16) ) - (block - (set_local $24 - (i32.const 0) - ) - (br $do-once47) - ) + (br $do-once47) ) ) (loop $while-in50 @@ -6243,7 +6219,7 @@ (get_local $7) ) ) - (if + (br_if $do-once0 (i32.eqz (tee_local $0 (i32.load @@ -6251,12 +6227,6 @@ ) ) ) - (block - (set_local $6 - (i32.const 0) - ) - (br $do-once0) - ) ) ) (loop $while-in @@ -6803,12 +6773,7 @@ (set_local $3 (get_local $0) ) - (block - (set_local $12 - (i32.const 0) - ) - (br $do-once6) - ) + (br $do-once6) ) ) (loop $while-in9 @@ -8125,11 +8090,10 @@ ) ) (if - (call $___towrite - (get_local $2) - ) - (set_local $4 - (i32.const 0) + (i32.eqz + (call $___towrite + (get_local $2) + ) ) (block (set_local $6 diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm index 3246cd8d1..a9843a84e 100644 --- a/test/emcc_hello_world.fromasm +++ b/test/emcc_hello_world.fromasm @@ -261,9 +261,6 @@ (func $_strerror (; 28 ;) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - (set_local $1 - (i32.const 0) - ) (block $__rjto$1 (block $__rjti$1 (block $__rjti$0 @@ -2417,15 +2414,9 @@ (i32.const 8) ) ) - (set_local $16 - (i32.const 0) - ) (set_local $5 (get_local $1) ) - (set_local $10 - (i32.const 0) - ) (set_local $1 (i32.const 0) ) @@ -8580,7 +8571,7 @@ ) ) ) - (if + (br_if $do-once4 (i32.eqz (tee_local $1 (i32.load @@ -8593,12 +8584,6 @@ ) ) ) - (block - (set_local $9 - (i32.const 0) - ) - (br $do-once4) - ) ) ) (loop $while-in7 @@ -9206,9 +9191,6 @@ ) ) (block - (set_local $6 - (i32.const 0) - ) (set_local $8 (i32.shl (get_local $2) @@ -9346,13 +9328,8 @@ ) ) ) - (block - (set_local $4 - (i32.const 0) - ) - (set_local $0 - (i32.const 0) - ) + (set_local $0 + (i32.const 0) ) ) (if @@ -9631,7 +9608,7 @@ ) ) ) - (if + (br_if $do-once17 (i32.eqz (tee_local $1 (i32.load @@ -9644,12 +9621,6 @@ ) ) ) - (block - (set_local $11 - (i32.const 0) - ) - (br $do-once17) - ) ) ) (loop $while-in20 @@ -10971,9 +10942,6 @@ (get_local $1) ) ) - (set_local $3 - (get_local $1) - ) ) (if (i32.ne @@ -11639,12 +11607,7 @@ (set_local $0 (get_local $3) ) - (block - (set_local $12 - (i32.const 0) - ) - (br $do-once55) - ) + (br $do-once55) ) ) (loop $while-in58 @@ -13629,12 +13592,7 @@ (set_local $4 (get_local $7) ) - (block - (set_local $6 - (i32.const 0) - ) - (br $do-once0) - ) + (br $do-once0) ) ) (loop $while-in @@ -14281,12 +14239,7 @@ (set_local $0 (get_local $1) ) - (block - (set_local $9 - (i32.const 0) - ) - (br $do-once6) - ) + (br $do-once6) ) ) (loop $while-in9 diff --git a/test/emcc_hello_world.fromasm.clamp b/test/emcc_hello_world.fromasm.clamp index 2f52a5eac..86bfe811e 100644 --- a/test/emcc_hello_world.fromasm.clamp +++ b/test/emcc_hello_world.fromasm.clamp @@ -259,9 +259,6 @@ (func $_strerror (; 27 ;) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - (set_local $1 - (i32.const 0) - ) (block $__rjto$1 (block $__rjti$1 (block $__rjti$0 @@ -2467,15 +2464,9 @@ (i32.const 8) ) ) - (set_local $16 - (i32.const 0) - ) (set_local $5 (get_local $1) ) - (set_local $10 - (i32.const 0) - ) (set_local $1 (i32.const 0) ) @@ -8630,7 +8621,7 @@ ) ) ) - (if + (br_if $do-once4 (i32.eqz (tee_local $1 (i32.load @@ -8643,12 +8634,6 @@ ) ) ) - (block - (set_local $9 - (i32.const 0) - ) - (br $do-once4) - ) ) ) (loop $while-in7 @@ -9256,9 +9241,6 @@ ) ) (block - (set_local $6 - (i32.const 0) - ) (set_local $8 (i32.shl (get_local $2) @@ -9396,13 +9378,8 @@ ) ) ) - (block - (set_local $4 - (i32.const 0) - ) - (set_local $0 - (i32.const 0) - ) + (set_local $0 + (i32.const 0) ) ) (if @@ -9681,7 +9658,7 @@ ) ) ) - (if + (br_if $do-once17 (i32.eqz (tee_local $1 (i32.load @@ -9694,12 +9671,6 @@ ) ) ) - (block - (set_local $11 - (i32.const 0) - ) - (br $do-once17) - ) ) ) (loop $while-in20 @@ -11021,9 +10992,6 @@ (get_local $1) ) ) - (set_local $3 - (get_local $1) - ) ) (if (i32.ne @@ -11689,12 +11657,7 @@ (set_local $0 (get_local $3) ) - (block - (set_local $12 - (i32.const 0) - ) - (br $do-once55) - ) + (br $do-once55) ) ) (loop $while-in58 @@ -13679,12 +13642,7 @@ (set_local $4 (get_local $7) ) - (block - (set_local $6 - (i32.const 0) - ) - (br $do-once0) - ) + (br $do-once0) ) ) (loop $while-in @@ -14331,12 +14289,7 @@ (set_local $0 (get_local $1) ) - (block - (set_local $9 - (i32.const 0) - ) - (br $do-once6) - ) + (br $do-once6) ) ) (loop $while-in9 diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise index b387f8cac..54c162195 100644 --- a/test/emcc_hello_world.fromasm.imprecise +++ b/test/emcc_hello_world.fromasm.imprecise @@ -258,9 +258,6 @@ (func $_strerror (; 27 ;) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - (set_local $1 - (i32.const 0) - ) (block $__rjto$1 (block $__rjti$1 (block $__rjti$0 @@ -2370,15 +2367,9 @@ (i32.const 8) ) ) - (set_local $16 - (i32.const 0) - ) (set_local $5 (get_local $1) ) - (set_local $10 - (i32.const 0) - ) (set_local $1 (i32.const 0) ) @@ -8519,7 +8510,7 @@ ) ) ) - (if + (br_if $do-once4 (i32.eqz (tee_local $1 (i32.load @@ -8532,12 +8523,6 @@ ) ) ) - (block - (set_local $9 - (i32.const 0) - ) - (br $do-once4) - ) ) ) (loop $while-in7 @@ -9145,9 +9130,6 @@ ) ) (block - (set_local $6 - (i32.const 0) - ) (set_local $8 (i32.shl (get_local $2) @@ -9285,13 +9267,8 @@ ) ) ) - (block - (set_local $4 - (i32.const 0) - ) - (set_local $0 - (i32.const 0) - ) + (set_local $0 + (i32.const 0) ) ) (if @@ -9570,7 +9547,7 @@ ) ) ) - (if + (br_if $do-once17 (i32.eqz (tee_local $1 (i32.load @@ -9583,12 +9560,6 @@ ) ) ) - (block - (set_local $11 - (i32.const 0) - ) - (br $do-once17) - ) ) ) (loop $while-in20 @@ -10910,9 +10881,6 @@ (get_local $1) ) ) - (set_local $3 - (get_local $1) - ) ) (if (i32.ne @@ -11578,12 +11546,7 @@ (set_local $0 (get_local $3) ) - (block - (set_local $12 - (i32.const 0) - ) - (br $do-once55) - ) + (br $do-once55) ) ) (loop $while-in58 @@ -13567,12 +13530,7 @@ (set_local $4 (get_local $8) ) - (block - (set_local $6 - (i32.const 0) - ) - (br $do-once0) - ) + (br $do-once0) ) ) (loop $while-in @@ -14219,12 +14177,7 @@ (set_local $0 (get_local $1) ) - (block - (set_local $9 - (i32.const 0) - ) - (br $do-once6) - ) + (br $do-once6) ) ) (loop $while-in9 diff --git a/test/memorygrowth.fromasm b/test/memorygrowth.fromasm index 560b34249..c556c8896 100644 --- a/test/memorygrowth.fromasm +++ b/test/memorygrowth.fromasm @@ -902,7 +902,7 @@ (get_local $9) ) ) - (if + (br_if $do-once4 (i32.eqz (tee_local $14 (i32.load @@ -915,12 +915,6 @@ ) ) ) - (block - (set_local $23 - (i32.const 0) - ) - (br $do-once4) - ) ) ) (loop $while-in7 @@ -1560,9 +1554,6 @@ (set_local $7 (get_local $12) ) - (set_local $8 - (i32.const 0) - ) (loop $while-in14 (if (i32.lt_u @@ -1691,12 +1682,6 @@ (set_local $36 (get_local $4) ) - (set_local $5 - (i32.const 0) - ) - (set_local $33 - (i32.const 0) - ) (set_local $7 (i32.const 86) ) @@ -2039,12 +2024,7 @@ (set_local $1 (get_local $12) ) - (block - (set_local $22 - (i32.const 0) - ) - (br $do-once17) - ) + (br $do-once17) ) ) (loop $while-in20 @@ -4218,12 +4198,7 @@ (get_local $18) ) ) - (block - (set_local $24 - (i32.const 0) - ) - (br $do-once51) - ) + (br $do-once51) ) ) (loop $while-in54 @@ -6290,7 +6265,7 @@ (get_local $3) ) ) - (if + (br_if $do-once0 (i32.eqz (tee_local $0 (i32.load @@ -6298,12 +6273,6 @@ ) ) ) - (block - (set_local $5 - (i32.const 0) - ) - (br $do-once0) - ) ) ) (loop $while-in @@ -6967,12 +6936,7 @@ (set_local $6 (get_local $0) ) - (block - (set_local $11 - (i32.const 0) - ) - (br $do-once6) - ) + (br $do-once6) ) ) (loop $while-in9 @@ -8172,11 +8136,10 @@ ) ) (if - (call $Xa - (get_local $2) - ) - (set_local $4 - (i32.const 0) + (i32.eqz + (call $Xa + (get_local $2) + ) ) (block (set_local $6 diff --git a/test/memorygrowth.fromasm.clamp b/test/memorygrowth.fromasm.clamp index 560b34249..c556c8896 100644 --- a/test/memorygrowth.fromasm.clamp +++ b/test/memorygrowth.fromasm.clamp @@ -902,7 +902,7 @@ (get_local $9) ) ) - (if + (br_if $do-once4 (i32.eqz (tee_local $14 (i32.load @@ -915,12 +915,6 @@ ) ) ) - (block - (set_local $23 - (i32.const 0) - ) - (br $do-once4) - ) ) ) (loop $while-in7 @@ -1560,9 +1554,6 @@ (set_local $7 (get_local $12) ) - (set_local $8 - (i32.const 0) - ) (loop $while-in14 (if (i32.lt_u @@ -1691,12 +1682,6 @@ (set_local $36 (get_local $4) ) - (set_local $5 - (i32.const 0) - ) - (set_local $33 - (i32.const 0) - ) (set_local $7 (i32.const 86) ) @@ -2039,12 +2024,7 @@ (set_local $1 (get_local $12) ) - (block - (set_local $22 - (i32.const 0) - ) - (br $do-once17) - ) + (br $do-once17) ) ) (loop $while-in20 @@ -4218,12 +4198,7 @@ (get_local $18) ) ) - (block - (set_local $24 - (i32.const 0) - ) - (br $do-once51) - ) + (br $do-once51) ) ) (loop $while-in54 @@ -6290,7 +6265,7 @@ (get_local $3) ) ) - (if + (br_if $do-once0 (i32.eqz (tee_local $0 (i32.load @@ -6298,12 +6273,6 @@ ) ) ) - (block - (set_local $5 - (i32.const 0) - ) - (br $do-once0) - ) ) ) (loop $while-in @@ -6967,12 +6936,7 @@ (set_local $6 (get_local $0) ) - (block - (set_local $11 - (i32.const 0) - ) - (br $do-once6) - ) + (br $do-once6) ) ) (loop $while-in9 @@ -8172,11 +8136,10 @@ ) ) (if - (call $Xa - (get_local $2) - ) - (set_local $4 - (i32.const 0) + (i32.eqz + (call $Xa + (get_local $2) + ) ) (block (set_local $6 diff --git a/test/memorygrowth.fromasm.imprecise b/test/memorygrowth.fromasm.imprecise index 6e5e9e996..522944903 100644 --- a/test/memorygrowth.fromasm.imprecise +++ b/test/memorygrowth.fromasm.imprecise @@ -901,7 +901,7 @@ (get_local $9) ) ) - (if + (br_if $do-once4 (i32.eqz (tee_local $14 (i32.load @@ -914,12 +914,6 @@ ) ) ) - (block - (set_local $23 - (i32.const 0) - ) - (br $do-once4) - ) ) ) (loop $while-in7 @@ -1559,9 +1553,6 @@ (set_local $7 (get_local $12) ) - (set_local $8 - (i32.const 0) - ) (loop $while-in14 (if (i32.lt_u @@ -1690,12 +1681,6 @@ (set_local $36 (get_local $4) ) - (set_local $5 - (i32.const 0) - ) - (set_local $33 - (i32.const 0) - ) (set_local $7 (i32.const 86) ) @@ -2038,12 +2023,7 @@ (set_local $1 (get_local $12) ) - (block - (set_local $22 - (i32.const 0) - ) - (br $do-once17) - ) + (br $do-once17) ) ) (loop $while-in20 @@ -4217,12 +4197,7 @@ (get_local $18) ) ) - (block - (set_local $24 - (i32.const 0) - ) - (br $do-once51) - ) + (br $do-once51) ) ) (loop $while-in54 @@ -6289,7 +6264,7 @@ (get_local $3) ) ) - (if + (br_if $do-once0 (i32.eqz (tee_local $0 (i32.load @@ -6297,12 +6272,6 @@ ) ) ) - (block - (set_local $5 - (i32.const 0) - ) - (br $do-once0) - ) ) ) (loop $while-in @@ -6966,12 +6935,7 @@ (set_local $6 (get_local $0) ) - (block - (set_local $11 - (i32.const 0) - ) - (br $do-once6) - ) + (br $do-once6) ) ) (loop $while-in9 @@ -8171,11 +8135,10 @@ ) ) (if - (call $Xa - (get_local $2) - ) - (set_local $4 - (i32.const 0) + (i32.eqz + (call $Xa + (get_local $2) + ) ) (block (set_local $6 diff --git a/test/passes/rse.txt b/test/passes/rse.txt new file mode 100644 index 000000000..017616cce --- /dev/null +++ b/test/passes/rse.txt @@ -0,0 +1,434 @@ +(module + (type $0 (func (param i32 f64))) + (type $1 (func (param i32))) + (type $2 (func)) + (type $3 (func (param i32 i32))) + (memory $0 0) + (func $basic (; 0 ;) (type $0) (param $x i32) (param $y f64) + (local $a f32) + (local $b i64) + (set_local $x + (i32.const 0) + ) + (set_local $y + (f64.const 0) + ) + (drop + (f32.const 0) + ) + (drop + (i64.const 0) + ) + ) + (func $later-param-use (; 1 ;) (type $1) (param $x i32) + (set_local $x + (i32.const 0) + ) + (drop + (i32.const 0) + ) + ) + (func $diff-value (; 2 ;) (type $1) (param $x i32) + (local $a i32) + (set_local $x + (i32.const 0) + ) + (set_local $x + (i32.const 1) + ) + (drop + (i32.const 1) + ) + (set_local $a + (i32.const 1) + ) + (drop + (i32.const 1) + ) + (set_local $a + (i32.const 0) + ) + ) + (func $unreach (; 3 ;) (type $2) + (local $a i32) + (block $x + (drop + (i32.const 0) + ) + (set_local $a + (i32.const 1) + ) + (drop + (i32.const 1) + ) + (br $x) + (set_local $a + (i32.const 1) + ) + (set_local $a + (i32.const 2) + ) + (set_local $a + (i32.const 2) + ) + ) + ) + (func $loop (; 4 ;) (type $2) + (local $a i32) + (local $b i32) + (loop $x + (set_local $a + (i32.const 0) + ) + (set_local $a + (i32.const 1) + ) + (br_if $x + (i32.const 1) + ) + ) + (block $y + (drop + (i32.const 0) + ) + (set_local $b + (i32.const 1) + ) + (br $y) + ) + (drop + (i32.const 1) + ) + ) + (func $if (; 5 ;) (type $2) + (local $x i32) + (if + (i32.const 0) + (set_local $x + (i32.const 1) + ) + (set_local $x + (i32.const 1) + ) + ) + (drop + (i32.const 1) + ) + ) + (func $if2 (; 6 ;) (type $2) + (local $x i32) + (if + (tee_local $x + (i32.const 1) + ) + (drop + (i32.const 1) + ) + (drop + (i32.const 1) + ) + ) + (drop + (i32.const 1) + ) + ) + (func $if3 (; 7 ;) (type $2) + (local $x i32) + (if + (tee_local $x + (i32.const 1) + ) + (drop + (i32.const 1) + ) + (set_local $x + (i32.const 2) + ) + ) + (set_local $x + (i32.const 1) + ) + ) + (func $copy (; 8 ;) (type $2) + (local $x i32) + (local $y i32) + (set_local $x + (i32.const 1) + ) + (set_local $y + (get_local $x) + ) + (drop + (i32.const 1) + ) + (set_local $x + (i32.const 2) + ) + (if + (i32.const 1) + (nop) + (nop) + ) + (set_local $y + (get_local $x) + ) + (drop + (i32.const 2) + ) + (if + (i32.const 1) + (nop) + (nop) + ) + (drop + (i32.const 2) + ) + (set_local $x + (i32.const 3) + ) + (set_local $y + (i32.const 3) + ) + (drop + (get_local $x) + ) + ) + (func $param-unique (; 9 ;) (type $1) (param $x i32) + (local $a i32) + (set_local $a + (get_local $x) + ) + (drop + (get_local $x) + ) + (set_local $x + (i32.eqz + (i32.const 9999) + ) + ) + (set_local $a + (get_local $x) + ) + (drop + (get_local $x) + ) + ) + (func $set-unique (; 10 ;) (type $2) + (local $x i32) + (local $y i32) + (set_local $x + (i32.eqz + (i32.const 123) + ) + ) + (set_local $y + (get_local $x) + ) + (drop + (get_local $x) + ) + (set_local $x + (i32.eqz + (i32.const 456) + ) + ) + (set_local $y + (get_local $x) + ) + (drop + (get_local $x) + ) + (set_local $x + (i32.eqz + (i32.const 789) + ) + ) + (if + (i32.const 1) + (nop) + (nop) + ) + (set_local $y + (get_local $x) + ) + (drop + (get_local $x) + ) + (set_local $x + (i32.eqz + (i32.const 1000) + ) + ) + (set_local $y + (get_local $x) + ) + (if + (i32.const 1) + (nop) + (nop) + ) + (drop + (get_local $x) + ) + ) + (func $identical_complex (; 11 ;) (type $1) (param $x i32) + (local $y i32) + (set_local $y + (get_local $x) + ) + (drop + (get_local $x) + ) + (drop + (get_local $x) + ) + (drop + (get_local $x) + ) + (drop + (get_local $y) + ) + (drop + (get_local $y) + ) + ) + (func $merge (; 12 ;) (type $2) + (local $x i32) + (if + (i32.const 1) + (set_local $x + (i32.const 1) + ) + (set_local $x + (i32.const 1) + ) + ) + (drop + (i32.const 1) + ) + (set_local $x + (i32.const 2) + ) + (loop $loop + (drop + (i32.const 2) + ) + (set_local $x + (i32.const 3) + ) + (set_local $x + (i32.const 2) + ) + (br_if $loop + (i32.const 2) + ) + ) + (drop + (i32.const 2) + ) + ) + (func $one-arm (; 13 ;) (type $3) (param $1 i32) (param $3 i32) + (set_local $1 + (get_local $3) + ) + (if + (i32.const 1) + (nop) + (drop + (get_local $1) + ) + ) + ) + (func $one-arm2 (; 14 ;) (type $3) (param $1 i32) (param $3 i32) + (set_local $1 + (get_local $3) + ) + (if + (i32.const 1) + (drop + (get_local $1) + ) + ) + ) + (func $many-merges (; 15 ;) (type $2) + (local $0 i32) + (local $1 i32) + (block $block + (br_if $block + (i32.const 0) + ) + (loop $loop + (set_local $1 + (get_local $0) + ) + (set_local $0 + (i32.const 99) + ) + (br_if $loop + (i32.const 1) + ) + ) + ) + (set_local $0 + (get_local $1) + ) + (if + (i32.const 0) + (drop + (get_local $0) + ) + ) + ) + (func $fuzz (; 16 ;) (type $2) + (local $x i32) + (loop $label$4 + (block $label$5 + (if + (i32.const 1) + (block $block + (set_local $x + (i32.const 203) + ) + (br $label$5) + ) + ) + (br_if $label$4 + (i32.const 2) + ) + ) + ) + (loop $label$7 + (if + (if (result i32) + (i32.const 3) + (i32.const 4) + (i32.const 5) + ) + (br $label$7) + ) + ) + ) + (func $fuzz2 (; 17 ;) (type $2) + (local $var$1 i32) + (if + (i32.const 0) + (if + (i32.const 1) + (set_local $var$1 + (i32.const 2) + ) + ) + ) + (loop $label$10 + (block $label$11 + (if + (i32.const 5) + (br_if $label$11 + (i32.const 6) + ) + ) + (br $label$10) + ) + ) + ) +) diff --git a/test/passes/rse.wast b/test/passes/rse.wast new file mode 100644 index 000000000..6a0ada018 --- /dev/null +++ b/test/passes/rse.wast @@ -0,0 +1,252 @@ +(module + (func $basic (param $x i32) (param $y f64) + (local $a f32) + (local $b i64) + (set_local $x (i32.const 0)) + (set_local $y (f64.const 0)) + (set_local $a (f32.const 0)) + (set_local $b (i64.const 0)) + ) + (func $later-param-use (param $x i32) + (set_local $x (i32.const 0)) + (set_local $x (i32.const 0)) + ) + (func $diff-value (param $x i32) + (local $a i32) + (set_local $x (i32.const 0)) + (set_local $x (i32.const 1)) + (set_local $x (i32.const 1)) + (set_local $a (i32.const 1)) + (set_local $a (i32.const 1)) + (set_local $a (i32.const 0)) + ) + (func $unreach + (local $a i32) + (block $x + (set_local $a (i32.const 0)) + (set_local $a (i32.const 1)) + (set_local $a (i32.const 1)) + (br $x) + (set_local $a (i32.const 1)) ;; ignore all these + (set_local $a (i32.const 2)) + (set_local $a (i32.const 2)) + ) + ) + (func $loop + (local $a i32) + (local $b i32) + (loop $x + (set_local $a (i32.const 0)) + (set_local $a (i32.const 1)) + (br_if $x (i32.const 1)) + ) + (block $y + (set_local $b (i32.const 0)) + (set_local $b (i32.const 1)) + (br $y) + ) + (set_local $b (i32.const 1)) + ) + (func $if + (local $x i32) + (if (tee_local $x (i32.const 0)) + (set_local $x (i32.const 1)) + (set_local $x (i32.const 1)) + ) + (set_local $x (i32.const 1)) + ) + (func $if2 + (local $x i32) + (if (tee_local $x (i32.const 1)) + (set_local $x (i32.const 1)) + (set_local $x (i32.const 1)) + ) + (set_local $x (i32.const 1)) + ) + (func $if3 + (local $x i32) + (if (tee_local $x (i32.const 1)) + (set_local $x (i32.const 1)) + (set_local $x (i32.const 2)) + ) + (set_local $x (i32.const 1)) + ) + (func $copy + (local $x i32) + (local $y i32) + (set_local $x (i32.const 1)) + (set_local $y (get_local $x)) + (set_local $y (i32.const 1)) + (set_local $x (i32.const 2)) + (if (i32.const 1) (nop) (nop)) ;; control flow + (set_local $y (get_local $x)) + (set_local $y (i32.const 2)) + (if (i32.const 1) (nop) (nop)) ;; control flow + (set_local $y (i32.const 2)) + ;; flip + (set_local $x (i32.const 3)) + (set_local $y (i32.const 3)) + (set_local $y (get_local $x)) ;; do this last + ) + (func $param-unique + (param $x i32) + (local $a i32) + (set_local $a (get_local $x)) + (set_local $a (get_local $x)) + (set_local $x (i32.eqz (i32.const 9999))) + (set_local $a (get_local $x)) + (set_local $a (get_local $x)) + ) + (func $set-unique + (local $x i32) + (local $y i32) + (set_local $x (i32.eqz (i32.const 123))) + (set_local $y (get_local $x)) + (set_local $y (get_local $x)) + (set_local $x (i32.eqz (i32.const 456))) + (set_local $y (get_local $x)) + (set_local $y (get_local $x)) + (set_local $x (i32.eqz (i32.const 789))) + (if (i32.const 1) (nop) (nop)) ;; control flow + (set_local $y (get_local $x)) + (set_local $y (get_local $x)) + (set_local $x (i32.eqz (i32.const 1000))) + (set_local $y (get_local $x)) + (if (i32.const 1) (nop) (nop)) ;; control flow + (set_local $y (get_local $x)) + ) + (func $identical_complex (param $x i32) + (local $y i32) + (set_local $y (get_local $x)) + (set_local $y (get_local $x)) + (set_local $y (get_local $x)) + (set_local $x (get_local $x)) + (set_local $y (get_local $y)) + (set_local $x (get_local $y)) + ) + (func $merge + (local $x i32) + (if (i32.const 1) + (set_local $x (i32.const 1)) + (set_local $x (i32.const 1)) + ) + (set_local $x (i32.const 1)) + (set_local $x (i32.const 2)) + (loop $loop + (set_local $x (i32.const 2)) + (set_local $x (i32.const 3)) + (set_local $x (i32.const 2)) + (br_if $loop (i32.const 2)) + ) + (set_local $x (i32.const 2)) + ) + (func $one-arm + (param $1 i32) + (param $3 i32) + (set_local $1 + (get_local $3) + ) + (if + (i32.const 1) + (nop) + (set_local $3 + (get_local $1) + ) + ) + ) + (func $one-arm2 + (param $1 i32) + (param $3 i32) + (set_local $1 + (get_local $3) + ) + (if + (i32.const 1) + (set_local $3 + (get_local $1) + ) + ) + ) + (func $many-merges + (local $0 i32) + (local $1 i32) + (block $block + (br_if $block + (i32.const 0) + ) + (loop $loop + (set_local $1 + (get_local $0) + ) + (set_local $0 + (i32.const 99) + ) + (br_if $loop + (i32.const 1) + ) + ) + ) + (set_local $0 ;; make them equal + (get_local $1) + ) + (if + (i32.const 0) + (set_local $1 ;; we can drop this + (get_local $0) + ) + ) + ) + (func $fuzz + (local $x i32) + (loop $label$4 + (block $label$5 + (if + (i32.const 1) + (block + (set_local $x + (i32.const 203) + ) + (br $label$5) + ) + ) + (br_if $label$4 + (i32.const 2) + ) + ) + ) + (loop $label$7 + (if + (if (result i32) + (i32.const 3) + (i32.const 4) + (i32.const 5) + ) + (br $label$7) + ) + ) + ) + (func $fuzz2 + (local $var$1 i32) + (if + (i32.const 0) + (if + (i32.const 1) + (set_local $var$1 + (i32.const 2) + ) + ) + ) + (loop $label$10 + (block $label$11 + (if + (i32.const 5) + (br_if $label$11 + (i32.const 6) + ) + ) + (br $label$10) + ) + ) + ) +) + diff --git a/test/threads.fromasm b/test/threads.fromasm index 7aafe4a4b..97a3f7de9 100644 --- a/test/threads.fromasm +++ b/test/threads.fromasm @@ -24,9 +24,7 @@ (i32.atomic.load16_u (i32.const 2458) ) - (tee_local $0 - (i32.const 0) - ) + (i32.const 0) ) (i32.atomic.rmw.xchg (get_local $0) diff --git a/test/threads.fromasm.clamp b/test/threads.fromasm.clamp index 7aafe4a4b..97a3f7de9 100644 --- a/test/threads.fromasm.clamp +++ b/test/threads.fromasm.clamp @@ -24,9 +24,7 @@ (i32.atomic.load16_u (i32.const 2458) ) - (tee_local $0 - (i32.const 0) - ) + (i32.const 0) ) (i32.atomic.rmw.xchg (get_local $0) diff --git a/test/threads.fromasm.imprecise b/test/threads.fromasm.imprecise index 546f27370..a166a49ef 100644 --- a/test/threads.fromasm.imprecise +++ b/test/threads.fromasm.imprecise @@ -23,9 +23,7 @@ (i32.atomic.load16_u (i32.const 2458) ) - (tee_local $0 - (i32.const 0) - ) + (i32.const 0) ) (i32.atomic.rmw.xchg (get_local $0) diff --git a/test/unit.fromasm b/test/unit.fromasm index c890b3a55..9a58b7747 100644 --- a/test/unit.fromasm +++ b/test/unit.fromasm @@ -771,9 +771,6 @@ (local $0 i32) (local $1 i32) (local $2 i32) - (set_local $1 - (i32.const 0) - ) (loop $label$continue$L7 (block $label$break$L7 (set_local $0 diff --git a/test/unit.fromasm.clamp b/test/unit.fromasm.clamp index 09c68d8f1..4d8776037 100644 --- a/test/unit.fromasm.clamp +++ b/test/unit.fromasm.clamp @@ -819,9 +819,6 @@ (local $0 i32) (local $1 i32) (local $2 i32) - (set_local $1 - (i32.const 0) - ) (loop $label$continue$L7 (block $label$break$L7 (set_local $0 diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise index 6cda1e7c1..1212a4c34 100644 --- a/test/unit.fromasm.imprecise +++ b/test/unit.fromasm.imprecise @@ -760,9 +760,6 @@ (local $0 i32) (local $1 i32) (local $2 i32) - (set_local $1 - (i32.const 0) - ) (loop $label$continue$L7 (block $label$break$L7 (set_local $0 diff --git a/test/wasm-only.fromasm b/test/wasm-only.fromasm index 8ac681f2b..2f9a2a37b 100644 --- a/test/wasm-only.fromasm +++ b/test/wasm-only.fromasm @@ -667,9 +667,7 @@ (block $switch8 (if (i32.ne - (tee_local $1 - (i32.const 100) - ) + (i32.const 100) (i32.const 214748364) ) (br_if $switch8 diff --git a/test/wasm-only.fromasm.clamp b/test/wasm-only.fromasm.clamp index 8ac681f2b..2f9a2a37b 100644 --- a/test/wasm-only.fromasm.clamp +++ b/test/wasm-only.fromasm.clamp @@ -667,9 +667,7 @@ (block $switch8 (if (i32.ne - (tee_local $1 - (i32.const 100) - ) + (i32.const 100) (i32.const 214748364) ) (br_if $switch8 diff --git a/test/wasm-only.fromasm.imprecise b/test/wasm-only.fromasm.imprecise index 8aab435ef..df12f655b 100644 --- a/test/wasm-only.fromasm.imprecise +++ b/test/wasm-only.fromasm.imprecise @@ -352,9 +352,7 @@ (block $switch8 (if (i32.ne - (tee_local $1 - (i32.const 100) - ) + (i32.const 100) (i32.const 214748364) ) (br_if $switch8 |