From e85c594b0a8897da88d976859159db7f2d994b61 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 18 Jun 2016 16:44:01 +0100 Subject: add a precompute pass --- src/passes/pass.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/passes/pass.cpp') diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index babb4635b..c5315a044 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -63,6 +63,7 @@ void PassRunner::addDefaultOptimizationPasses() { add("remove-unused-brs"); add("remove-unused-names"); add("optimize-instructions"); + add("precompute"); add("simplify-locals"); add("vacuum"); // previous pass creates garbage add("remove-unused-brs"); // simplify-locals opens opportunities for phi optimizations @@ -80,6 +81,7 @@ void PassRunner::addDefaultFunctionOptimizationPasses() { add("remove-unused-brs"); add("remove-unused-names"); add("optimize-instructions"); + add("precompute"); add("simplify-locals"); add("vacuum"); // previous pass creates garbage add("remove-unused-brs"); // simplify-locals opens opportunities for phi optimizations -- cgit v1.2.3 From d6bda73f13fe17434f3bd78b58da6961d297361a Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 18 Jun 2016 17:55:44 +0100 Subject: run precompute after every optimize-instructions --- src/passes/pass.cpp | 2 + test/emcc_hello_world.fromasm | 156 +++++--------------------------- test/emcc_hello_world.fromasm.imprecise | 156 +++++--------------------------- 3 files changed, 50 insertions(+), 264 deletions(-) (limited to 'src/passes/pass.cpp') diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index c5315a044..1c66147ef 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -72,6 +72,7 @@ void PassRunner::addDefaultOptimizationPasses() { add("reorder-locals"); add("merge-blocks"); add("optimize-instructions"); + add("precompute"); add("vacuum"); // should not be needed, last few passes do not create garbage, but just to be safe add("duplicate-function-elimination"); // optimizations show more functions as duplicate } @@ -90,6 +91,7 @@ void PassRunner::addDefaultFunctionOptimizationPasses() { add("reorder-locals"); add("merge-blocks"); add("optimize-instructions"); + add("precompute"); add("vacuum"); // should not be needed, last few passes do not create garbage, but just to be safe } diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm index d42874592..79f28f9e8 100644 --- a/test/emcc_hello_world.fromasm +++ b/test/emcc_hello_world.fromasm @@ -3743,18 +3743,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -4152,18 +4143,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9015,18 +8997,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9052,18 +9025,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9102,18 +9066,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9144,18 +9099,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 8) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 8) - (i32.const 1) - ) - (i32.const -1) + (i32.const 7) ) + (i32.const -8) ) ) ) @@ -9191,18 +9137,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9255,18 +9192,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9299,18 +9227,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9363,18 +9282,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9407,18 +9317,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 8) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 8) - (i32.const 1) - ) - (i32.const -1) + (i32.const 7) ) + (i32.const -8) ) ) ) @@ -9444,18 +9345,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 8) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 8) - (i32.const 1) - ) - (i32.const -1) + (i32.const 7) ) + (i32.const -8) ) ) ) diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise index 8899b7965..cdfd59b07 100644 --- a/test/emcc_hello_world.fromasm.imprecise +++ b/test/emcc_hello_world.fromasm.imprecise @@ -3741,18 +3741,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -4150,18 +4141,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9013,18 +8995,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9050,18 +9023,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9100,18 +9064,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9142,18 +9097,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 8) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 8) - (i32.const 1) - ) - (i32.const -1) + (i32.const 7) ) + (i32.const -8) ) ) ) @@ -9189,18 +9135,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9253,18 +9190,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9297,18 +9225,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9361,18 +9280,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 4) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 4) - (i32.const 1) - ) - (i32.const -1) + (i32.const 3) ) + (i32.const -4) ) ) ) @@ -9405,18 +9315,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 8) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 8) - (i32.const 1) - ) - (i32.const -1) + (i32.const 7) ) + (i32.const -8) ) ) ) @@ -9442,18 +9343,9 @@ (i32.load (get_local $2) ) - (i32.sub - (i32.const 8) - (i32.const 1) - ) - ) - (i32.xor - (i32.sub - (i32.const 8) - (i32.const 1) - ) - (i32.const -1) + (i32.const 7) ) + (i32.const -8) ) ) ) -- cgit v1.2.3