From 429740a6c257fd395d99d46ba4598e18c4839d2a Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Thu, 4 Aug 2016 23:49:05 +0000 Subject: GVN-hoist: fix early exit logic The patch splits a complex && if condition into easier to read and understand logic. That wrong early exit condition was letting some instructions with not all operands available pass through when HoistingGeps was true. Differential Revision: https://reviews.llvm.org/D23174 llvm-svn: 277785 --- llvm/lib/Transforms/Scalar/GVNHoist.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp index 171a8edfee4..c734dfced8e 100644 --- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp +++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp @@ -750,12 +750,19 @@ private: Repl = InstructionsToHoist.front(); // We can move Repl in HoistPt only when all operands are available. - // When not HoistingGeps we need to copy the GEPs now. // The order in which hoistings are done may influence the availability // of operands. - if (!allOperandsAvailable(Repl, HoistPt) && !HoistingGeps && - !makeGepOperandsAvailable(Repl, HoistPt, InstructionsToHoist)) - continue; + if (!allOperandsAvailable(Repl, HoistPt)) { + + // When HoistingGeps there is nothing more we can do to make the + // operands available: just continue. + if (HoistingGeps) + continue; + + // When not HoistingGeps we need to copy the GEPs. + if (!makeGepOperandsAvailable(Repl, HoistPt, InstructionsToHoist)) + continue; + } // Move the instruction at the end of HoistPt. Instruction *Last = HoistPt->getTerminator(); -- cgit v1.2.3