diff options
author | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-02-13 13:48:38 -0800 |
---|---|---|
committer | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-02-16 22:45:38 -0800 |
commit | f05efb982f8472c1dd6beb0e8dbc8afc73e82fcb (patch) | |
tree | 947b3654367ab0dc58324144aabb882cf0621866 | |
parent | 53b94fca7da5eeb08bb9b9802367a29c3e811e92 (diff) | |
download | binaryen-f05efb982f8472c1dd6beb0e8dbc8afc73e82fcb.tar.gz binaryen-f05efb982f8472c1dd6beb0e8dbc8afc73e82fcb.tar.bz2 binaryen-f05efb982f8472c1dd6beb0e8dbc8afc73e82fcb.zip |
tiny refactoring in OptimizeInstructions, for clarity
-rw-r--r-- | src/passes/OptimizeInstructions.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index efd9e0037..49100a9f4 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -377,13 +377,14 @@ struct OptimizeInstructions : public WalkerPass<PostWalker<OptimizeInstructions, if (auto* ext = getAlmostSignExt(binary)) { Index extraShifts; auto bits = getAlmostSignExtBits(binary, extraShifts); - auto* load = getFallthroughDynCast<Load>(ext); - // pattern match a load of 8 bits and a sign extend using a shl of 24 then shr_s of 24 as well, etc. - if (load && ((load->bytes == 1 && bits == 8) || (load->bytes == 2 && bits == 16))) { - // if the value falls through, we can't alter the load, as it might be captured in a tee - if (load->signed_ == true || load == ext) { - load->signed_ = true; - return removeAlmostSignExt(binary); + if (auto* load = getFallthroughDynCast<Load>(ext)) { + // pattern match a load of 8 bits and a sign extend using a shl of 24 then shr_s of 24 as well, etc. + if ((load->bytes == 1 && bits == 8) || (load->bytes == 2 && bits == 16)) { + // if the value falls through, we can't alter the load, as it might be captured in a tee + if (load->signed_ == true || load == ext) { + load->signed_ = true; + return removeAlmostSignExt(binary); + } } } // if the sign-extend input cannot have a sign bit, we don't need it |