From f05efb982f8472c1dd6beb0e8dbc8afc73e82fcb Mon Sep 17 00:00:00 2001 From: "Alon Zakai (kripken)" Date: Mon, 13 Feb 2017 13:48:38 -0800 Subject: tiny refactoring in OptimizeInstructions, for clarity --- src/passes/OptimizeInstructions.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src') 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(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(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 -- cgit v1.2.3