[llvm-commits] [llvm] r134054 - in /llvm/trunk: lib/Transforms/Scalar/IndVarSimplify.cpp test/Transforms/IndVarSimplify/no-iv-rewrite.ll
Andrew Trick
atrick at apple.com
Tue Jun 28 20:13:40 PDT 2011
Author: atrick
Date: Tue Jun 28 22:13:40 2011
New Revision: 134054
URL: http://llvm.org/viewvc/llvm-project?rev=134054&view=rev
Log:
indvars -disable-iv-rewrite: just because SCEV ignores casts doesn't
mean they can be removed.
Modified:
llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
llvm/trunk/test/Transforms/IndVarSimplify/no-iv-rewrite.ll
Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=134054&r1=134053&r2=134054&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Tue Jun 28 22:13:40 2011
@@ -1007,6 +1007,7 @@
// Eliminate any operation that SCEV can prove is an identity function.
if (!SE->isSCEVable(UseInst->getType()) ||
+ (UseInst->getType() != IVOperand->getType()) ||
(SE->getSCEV(UseInst) != SE->getSCEV(IVOperand)))
return false;
Modified: llvm/trunk/test/Transforms/IndVarSimplify/no-iv-rewrite.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/no-iv-rewrite.ll?rev=134054&r1=134053&r2=134054&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IndVarSimplify/no-iv-rewrite.ll (original)
+++ llvm/trunk/test/Transforms/IndVarSimplify/no-iv-rewrite.ll Tue Jun 28 22:13:40 2011
@@ -23,6 +23,7 @@
; sext should be eliminated while preserving gep inboundsness.
; CHECK-NOT: sext
; CHECK: getelementptr inbounds
+; CHECK: exit
loop:
%i.02 = phi i32 [ 0, %ph ], [ %iinc, %loop ]
%s.01 = phi i32 [ 0, %ph ], [ %sinc, %loop ]
@@ -63,6 +64,7 @@
; CHECK: getelementptr inbounds
; %vall sext should obviously not be eliminated
; CHECK: sext
+; CHECK: exit
loop:
%i.02 = phi i32 [ 0, %ph ], [ %iinc, %loop ]
%s.01 = phi i64 [ 0, %ph ], [ %sinc, %loop ]
@@ -106,6 +108,7 @@
; Preserve gep inboundsness, and don't factor it.
; CHECK: getelementptr inbounds i32* %ptriv, i32 1
; CHECK-NOT: add
+; CHECK: exit
loop:
%ptriv = phi i32* [ %first, %ph ], [ %ptrpost, %loop ]
%ofs = sext i32 %idx to i64
@@ -121,3 +124,37 @@
return:
ret void
}
+
+%struct = type { i32 }
+
+define void @bitcastiv(i32 %start, i32 %limit, i32 %step, %struct* %base)
+nounwind
+{
+entry:
+ br label %loop
+
+; CHECK: loop:
+;
+; Preserve casts
+; CHECK: phi i32
+; CHECK: bitcast
+; CHECK: getelementptr
+; CHECK: exit
+loop:
+ %iv = phi i32 [%start, %entry], [%next, %loop]
+ %p = phi %struct* [%base, %entry], [%pinc, %loop]
+ %adr = getelementptr %struct* %p, i32 0, i32 0
+ store i32 3, i32* %adr
+ %pp = bitcast %struct* %p to i32*
+ store i32 4, i32* %pp
+ %pinc = getelementptr %struct* %p, i32 1
+ %next = add i32 %iv, 1
+ %cond = icmp ne i32 %next, %limit
+ br i1 %cond, label %loop, label %exit
+
+exit:
+ br label %return
+
+return:
+ ret void
+}
\ No newline at end of file
More information about the llvm-commits
mailing list