summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/IndVarSimplify/elim-extend.ll
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2011-05-31 21:17:47 +0000
committerAndrew Trick <atrick@apple.com>2011-05-31 21:17:47 +0000
commit812276eed44239bfac28318c1ec5847cbbc5bd7f (patch)
tree7e369b3f468dbb5b6ddee91b4e0b30a3caf22ddc /llvm/test/Transforms/IndVarSimplify/elim-extend.ll
parent8f0cd597f19447440a5267e5d3a760b0af0da061 (diff)
downloadbcm5719-llvm-812276eed44239bfac28318c1ec5847cbbc5bd7f.tar.gz
bcm5719-llvm-812276eed44239bfac28318c1ec5847cbbc5bd7f.zip
scev: Better sign-extend removal. Normalize postincrement recurrences
so that their sign extended forms are congruent when no overflow occurs. llvm-svn: 132360
Diffstat (limited to 'llvm/test/Transforms/IndVarSimplify/elim-extend.ll')
-rw-r--r--llvm/test/Transforms/IndVarSimplify/elim-extend.ll29
1 files changed, 12 insertions, 17 deletions
diff --git a/llvm/test/Transforms/IndVarSimplify/elim-extend.ll b/llvm/test/Transforms/IndVarSimplify/elim-extend.ll
index ce490cc8d04..4b336f03795 100644
--- a/llvm/test/Transforms/IndVarSimplify/elim-extend.ll
+++ b/llvm/test/Transforms/IndVarSimplify/elim-extend.ll
@@ -2,9 +2,8 @@
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"
-; Test reusing the same IV with constant start for preinc and postinc values
-; with and without NSW.
-; IV rewrite only removes one sext. WidenIVs should remove all three.
+; IV with constant start, preinc and postinc sign extends, with and without NSW.
+; IV rewrite only removes one sext. WidenIVs removes all three.
define void @postincConstIV(i8* %base, i32 %limit) nounwind {
entry:
br label %loop
@@ -33,21 +32,19 @@ return:
ret void
}
-; Test reusing the same IV with nonconstant start for preinc and postinc values
+; IV with nonconstant start, preinc and postinc sign extends,
; with and without NSW.
-; As with constant IV start, WidenIVs should remove all three.
-;
-; FIXME: WidenIVs should remove %postofs just like %postofsnsw
+; As with postincConstIV, WidenIVs removes all three sexts.
define void @postincVarIV(i8* %base, i32 %init, i32 %limit) nounwind {
entry:
- br label %loop
+ %precond = icmp sgt i32 %limit, %init
+ br i1 %precond, label %loop, label %return
; CHECK: loop:
-; CHECK: sext
; CHECK-NOT: sext
; CHECK: exit:
loop:
%iv = phi i32 [ %postiv, %loop ], [ %init, %entry ]
- %ivnsw = phi i32 [ %postivnsw, %loop ], [ 0, %entry ]
+ %ivnsw = phi i32 [ %postivnsw, %loop ], [ %init, %entry ]
%preofs = sext i32 %iv to i64
%preadr = getelementptr i8* %base, i64 %preofs
store i8 0, i8* %preadr
@@ -59,7 +56,7 @@ loop:
%postofsnsw = sext i32 %postivnsw to i64
%postadrnsw = getelementptr i8* %base, i64 %postofsnsw
store i8 0, i8* %postadrnsw
- %cond = icmp sgt i32 %limit, %iv
+ %cond = icmp sgt i32 %limit, %postiv
br i1 %cond, label %loop, label %exit
exit:
br label %return
@@ -103,15 +100,13 @@ innerpreheader:
; CHECK: innerloop:
;
; Eliminate %ofs2 after widening inneriv.
+; Eliminate %ofs3 after normalizing sext(innerpostiv)
; CHECK-NOT: sext
; CHECK: getelementptr
;
-; FIXME: We should not increase the number of IVs in this loop.
-; sext elimination plus LFTR results in 3 final IVs.
-;
-; FIXME: eliminate %ofs3 based the loop pre/post conditions
-; even though innerpostiv is not NSW, thus sign extending innerpostiv
-; does not yield the same expression as incrementing the widened inneriv.
+; FIXME: We should check that indvars does not increase the number of
+; IVs in this loop. sext elimination plus LFTR currently results in 2 final
+; IVs. Waiting to remove LFTR.
innerloop:
%inneriv = phi i32 [ %innerpostiv, %innerloop ], [ %innercount, %innerpreheader ]
%innerpostiv = add i32 %inneriv, 1
OpenPOWER on IntegriCloud