From 07cd0ff29802bb36649ed5de5bc39e2210f91c2d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 2 Aug 2005 01:32:29 +0000 Subject: [PATCH] Add a comment Make LSR ignore GEP's that have loop variant base values, as we currently cannot codegen them git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22576 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LoopStrengthReduce.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 0967fb7200b..f3834158c1c 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -251,6 +251,9 @@ void LoopStrengthReduce::AnalyzeGetElementPtrUsers(GetElementPtrInst *GEP, UIntPtrTy)); } else { SCEVHandle Idx = SE->getSCEV(GEP->getOperand(i)); + + // If this operand is reducible, and it's not the one we are looking at + // currently, do not process the GEP at this time. if (CanReduceSCEV(Idx, L)) return; Base = SCEVAddExpr::get(Base, GetAdjustedIndex(Idx, @@ -287,6 +290,13 @@ void LoopStrengthReduce::AnalyzeGetElementPtrUsers(GetElementPtrInst *GEP, assert(CanReduceSCEV(GEPIndexExpr, L) && "Non reducible idx??"); + // FIXME: If the base is not loop invariant, we currently cannot emit this. + if (!Base->isLoopInvariant(L)) { + DEBUG(std::cerr << "IGNORING GEP due to non-invaiant base: " + << *Base << "\n"); + return; + } + Base = SCEVAddExpr::get(Base, cast(GEPIndexExpr)->getStart()); SCEVHandle Stride = cast(GEPIndexExpr)->getOperand(1);