From: Dan Gohman Date: Fri, 9 Apr 2010 19:12:34 +0000 (+0000) Subject: When looking for loop-invariant users, look through no-op instructions, X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=4a2a68336638e99a475b09a9278399db6749618f;p=oota-llvm.git When looking for loop-invariant users, look through no-op instructions, so that an unfortunately placed bitcast doesn't pin a value in a register. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100883 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index ee966edc03b..04f388477bc 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -1947,9 +1947,17 @@ LSRInstance::CollectLoopInvariantFixupsAndFormulae() { continue; // Ignore uses which are part of other SCEV expressions, to avoid // analyzing them multiple times. - if (SE.isSCEVable(UserInst->getType()) && - !isa(SE.getSCEV(const_cast(UserInst)))) - continue; + if (SE.isSCEVable(UserInst->getType())) { + const SCEV *UserS = SE.getSCEV(const_cast(UserInst)); + // If the user is a no-op, look through to its uses. + if (!isa(UserS)) + continue; + if (UserS == U) { + Worklist.push_back( + SE.getUnknown(const_cast(UserInst))); + continue; + } + } // Ignore icmp instructions which are already being analyzed. if (const ICmpInst *ICI = dyn_cast(UserInst)) { unsigned OtherIdx = !UI.getOperandNo();