From 4c82daea60cc6f51a0797ae21c0bcc6d38e56853 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Tue, 27 Jan 2015 06:21:43 +0000 Subject: LoopRotate: Don't walk the uses of a Constant LoopRotate wanted to avoid live range interference by looking at the uses of a Value in the loop latch and seeing if any lied outside of the loop. We would wrongly perform this operation on Constants. This fixes PR22337. llvm-svn: 227171 --- llvm/lib/Transforms/Scalar/LoopRotation.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'llvm/lib/Transforms/Scalar/LoopRotation.cpp') diff --git a/llvm/lib/Transforms/Scalar/LoopRotation.cpp b/llvm/lib/Transforms/Scalar/LoopRotation.cpp index c37cd91..02fb80c 100644 --- a/llvm/lib/Transforms/Scalar/LoopRotation.cpp +++ b/llvm/lib/Transforms/Scalar/LoopRotation.cpp @@ -229,20 +229,17 @@ static bool shouldSpeculateInstrs(BasicBlock::iterator Begin, case Instruction::Shl: case Instruction::LShr: case Instruction::AShr: { - Value *IVOpnd = nullptr; - if (isa(I->getOperand(0))) - IVOpnd = I->getOperand(1); - - if (isa(I->getOperand(1))) { - if (IVOpnd) - return false; - - IVOpnd = I->getOperand(0); - } + Value *IVOpnd = !isa(I->getOperand(0)) + ? I->getOperand(0) + : !isa(I->getOperand(1)) + ? I->getOperand(1) + : nullptr; + if (!IVOpnd) + return false; // If increment operand is used outside of the loop, this speculation // could cause extra live range interference. - if (MultiExitLoop && IVOpnd) { + if (MultiExitLoop) { for (User *UseI : IVOpnd->users()) { auto *UserInst = cast(UseI); if (!L->contains(UserInst)) -- cgit v1.1