summaryrefslogtreecommitdiff
path: root/test/Transforms/LoopUnroll
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2011-08-10 04:29:49 +0000
committerAndrew Trick <atrick@apple.com>2011-08-10 04:29:49 +0000
commit39f40299a6efc06747db0de53deb9be248913998 (patch)
tree8608ebdf69e6320adcffed565af017fe6c10fb35 /test/Transforms/LoopUnroll
parentbddb7f82103deb226baa6793f41c5961661167e7 (diff)
downloadllvm-39f40299a6efc06747db0de53deb9be248913998.tar.gz
llvm-39f40299a6efc06747db0de53deb9be248913998.tar.bz2
llvm-39f40299a6efc06747db0de53deb9be248913998.tar.xz
Invoke SimplifyIndVar when we partially unroll a loop. Fixes PR10534.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137203 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/LoopUnroll')
-rw-r--r--test/Transforms/LoopUnroll/2011-08-09-IVSimplify.ll39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/Transforms/LoopUnroll/2011-08-09-IVSimplify.ll b/test/Transforms/LoopUnroll/2011-08-09-IVSimplify.ll
new file mode 100644
index 0000000000..5790603cfc
--- /dev/null
+++ b/test/Transforms/LoopUnroll/2011-08-09-IVSimplify.ll
@@ -0,0 +1,39 @@
+; RUN: opt -S < %s -loop-unroll -unroll-count=4 -disable-iv-rewrite | FileCheck %s
+;
+; Test induction variable simplify after loop unrolling. It should
+; expose nice opportunities for GVN.
+
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:128:128-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
+
+; PR10534: LoopUnroll not keeping canonical induction variable...
+; CHECK: while.body.1:
+; CHECK: %shr.1 = lshr i32 %bit_addr.addr.01, 5
+; CHECK: %arrayidx.1 = getelementptr inbounds i32* %bitmap, i32 %shr.1
+; CHECK: while.body.2:
+; CHECK: %shr.2 = lshr i32 %bit_addr.addr.01, 5
+; CHECK: %arrayidx.2 = getelementptr inbounds i32* %bitmap, i32 %shr.2
+; CHECK: while.body.3:
+; CHECK: %shr.3 = lshr i32 %bit_addr.addr.01, 5
+; CHECK: %arrayidx.3 = getelementptr inbounds i32* %bitmap, i32 %shr.3
+define void @FlipBit(i32* nocapture %bitmap, i32 %bit_addr, i32 %nbits) nounwind {
+entry:
+ br label %while.body
+
+while.body:
+ %nbits.addr.02 = phi i32 [ 128, %entry ], [ %dec, %while.body ]
+ %bit_addr.addr.01 = phi i32 [ 0, %entry ], [ %inc, %while.body ]
+ %dec = add i32 %nbits.addr.02, -1
+ %shr = lshr i32 %bit_addr.addr.01, 5
+ %rem = and i32 %bit_addr.addr.01, 31
+ %shl = shl i32 1, %rem
+ %arrayidx = getelementptr inbounds i32* %bitmap, i32 %shr
+ %tmp6 = load i32* %arrayidx, align 4
+ %xor = xor i32 %tmp6, %shl
+ store i32 %xor, i32* %arrayidx, align 4
+ %inc = add i32 %bit_addr.addr.01, 1
+ %tobool = icmp eq i32 %dec, 0
+ br i1 %tobool, label %while.end, label %while.body
+
+while.end:
+ ret void
+}