[llvm-commits] [llvm] r100884 - in /llvm/trunk: lib/Analysis/ScalarEvolutionExpander.cpp test/Transforms/LoopStrengthReduce/uglygep.ll
Dan Gohman
gohman at apple.com
Fri Apr 9 12:14:31 PDT 2010
Author: djg
Date: Fri Apr 9 14:14:31 2010
New Revision: 100884
URL: http://llvm.org/viewvc/llvm-project?rev=100884&view=rev
Log:
When emitting code for an add, don't force a SCEVUnknown wrapper around
a hoisted intermediate result if the intermediate result isn't an
Instruction.
Added:
llvm/trunk/test/Transforms/LoopStrengthReduce/uglygep.ll
Modified:
llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=100884&r1=100883&r2=100884&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Fri Apr 9 14:14:31 2010
@@ -705,10 +705,11 @@
Sum = expandAddToGEP(NewOps.begin(), NewOps.end(), PTy, Ty, Sum);
} else if (const PointerType *PTy = dyn_cast<PointerType>(Op->getType())) {
// The running sum is an integer, and there's a pointer at this level.
- // Try to form a getelementptr. Use a SCEVUnknown so that we don't
- // re-analyze the instructions that we just emitted.
+ // Try to form a getelementptr. If the running sum is instructions,
+ // use a SCEVUnknown to avoid re-analyzing them.
SmallVector<const SCEV *, 4> NewOps;
- NewOps.push_back(SE.getUnknown(Sum));
+ NewOps.push_back(isa<Instruction>(Sum) ? SE.getUnknown(Sum) :
+ SE.getSCEV(Sum));
for (++I; I != E && I->first == CurLoop; ++I)
NewOps.push_back(I->second);
Sum = expandAddToGEP(NewOps.begin(), NewOps.end(), PTy, Ty, expand(Op));
Added: llvm/trunk/test/Transforms/LoopStrengthReduce/uglygep.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/uglygep.ll?rev=100884&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LoopStrengthReduce/uglygep.ll (added)
+++ llvm/trunk/test/Transforms/LoopStrengthReduce/uglygep.ll Fri Apr 9 14:14:31 2010
@@ -0,0 +1,37 @@
+; RUN: opt < %s -loop-reduce -S | not grep uglygep
+
+; LSR shouldn't consider %t8 to be an interesting user of %t6, and it
+; should be able to form pretty GEPs.
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @Z4() nounwind {
+bb:
+ br label %bb3
+
+bb1: ; preds = %bb3
+ br i1 undef, label %bb10, label %bb2
+
+bb2: ; preds = %bb1
+ %t = add i64 %t4, 1 ; <i64> [#uses=1]
+ br label %bb3
+
+bb3: ; preds = %bb2, %bb
+ %t4 = phi i64 [ %t, %bb2 ], [ 0, %bb ] ; <i64> [#uses=3]
+ br label %bb1
+
+bb10: ; preds = %bb9
+ %t7 = icmp eq i64 %t4, 0 ; <i1> [#uses=1]
+ %t3 = add i64 %t4, 16 ; <i64> [#uses=1]
+ br label %bb14
+
+bb14: ; preds = %bb14, %bb10
+ %t2 = getelementptr inbounds i8* undef, i64 %t4 ; <i8*> [#uses=1]
+ store i8 undef, i8* %t2
+ %t6 = load float** undef
+ %t8 = bitcast float* %t6 to i8* ; <i8*> [#uses=1]
+ %t9 = getelementptr inbounds i8* %t8, i64 %t3 ; <i8*> [#uses=1]
+ store i8 undef, i8* %t9
+ br label %bb14
+}
More information about the llvm-commits
mailing list