Look through bitcast when finding IVs. (Chris' patch really.)
authorDale Johannesen <dalej@apple.com>
Mon, 26 Mar 2007 03:01:27 +0000 (03:01 +0000)
committerDale Johannesen <dalej@apple.com>
Mon, 26 Mar 2007 03:01:27 +0000 (03:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35347 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopStrengthReduce.cpp

index 4ace17f7a4a0fa86a735732362b27b0b44f31184..f48f828cb6f5875b518e03eae91f61490286581f 100644 (file)
@@ -235,6 +235,16 @@ DeleteTriviallyDeadInstructions(std::set<Instruction*> &Insts) {
 /// GetExpressionSCEV - Compute and return the SCEV for the specified
 /// instruction.
 SCEVHandle LoopStrengthReduce::GetExpressionSCEV(Instruction *Exp, Loop *L) {
+  // Pointer to pointer bitcast instructions return the same value as their
+  // operand.
+  if (BitCastInst *BCI = dyn_cast<BitCastInst>(Exp)) {
+    if (SE->hasSCEV(BCI) || !isa<Instruction>(BCI->getOperand(0)))
+      return SE->getSCEV(BCI);
+    SCEVHandle R = GetExpressionSCEV(cast<Instruction>(BCI->getOperand(0)), L);
+    SE->setSCEV(BCI, R);
+    return R;
+  }
+
   // Scalar Evolutions doesn't know how to compute SCEV's for GEP instructions.
   // If this is a GEP that SE doesn't know about, compute it now and insert it.
   // If this is not a GEP, or if we have already done this computation, just let