[llvm-commits] [llvm] r96177 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Dan Gohman gohman at apple.com
Sun Feb 14 10:50:49 PST 2010


Author: djg
Date: Sun Feb 14 12:50:49 2010
New Revision: 96177

URL: http://llvm.org/viewvc/llvm-project?rev=96177&view=rev
Log:
When complicated expressions are broken down into subexpressions
with multiplication by constants distributed through, occasionally
those subexpressions can include both x and -x. For now, if this
condition is discovered within LSR, just prune such cases away,
as they won't be profitable. This fixes a "zero allocated in a
base register" assertion failure.

Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=96177&r1=96176&r2=96177&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Sun Feb 14 12:50:49 2010
@@ -2012,8 +2012,14 @@
       F.BaseRegs.push_back(BaseReg);
   }
   if (Ops.size() > 1) {
-    F.BaseRegs.push_back(SE.getAddExpr(Ops));
-    (void)InsertFormula(LU, LUIdx, F);
+    const SCEV *Sum = SE.getAddExpr(Ops);
+    // TODO: If Sum is zero, it probably means ScalarEvolution missed an
+    // opportunity to fold something. For now, just ignore such cases
+    // rather than procede with zero in a register.
+    if (!Sum->isZero()) {
+      F.BaseRegs.push_back(Sum);
+      (void)InsertFormula(LU, LUIdx, F);
+    }
   }
 }
 





More information about the llvm-commits mailing list