summaryrefslogtreecommitdiff
path: root/test/Transforms/LoopVectorize/undef-inst-bug.ll
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2013-12-22 00:04:03 +0000
committerDimitry Andric <dim@FreeBSD.org>2013-12-22 00:04:03 +0000
commitf8af5cf600354830d4ccf59732403f0f073eccb9 (patch)
tree2ba0398b4c42ad4f55561327538044fd2c925a8b /test/Transforms/LoopVectorize/undef-inst-bug.ll
parent59d6cff90eecf31cb3dd860c4e786674cfdd42eb (diff)
Diffstat (limited to 'test/Transforms/LoopVectorize/undef-inst-bug.ll')
-rw-r--r--test/Transforms/LoopVectorize/undef-inst-bug.ll36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/Transforms/LoopVectorize/undef-inst-bug.ll b/test/Transforms/LoopVectorize/undef-inst-bug.ll
new file mode 100644
index 0000000000000..ed60e801afde3
--- /dev/null
+++ b/test/Transforms/LoopVectorize/undef-inst-bug.ll
@@ -0,0 +1,36 @@
+; RUN: opt -S -loop-vectorize -force-vector-width=4 -force-vector-unroll=1 < %s | FileCheck %s
+
+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-S128"
+
+; We use to fail on this loop because we did not properly handle the loop
+; invariant instruction anchored in the loop when used as a getelementptr index.
+; We would use the index from the original loop resulting in a use not dominated
+; by the definition.
+
+; PR16452
+
+; Verify that we don't miscompile this loop.
+
+; CHECK-LABEL: @t(
+; CHECK: <4 x i32>
+
+define void @t() {
+entry:
+ br label %for.body
+
+for.body:
+ %indvars.iv17 = phi i64 [ %indvars.next, %for.body ], [ 128, %entry ]
+
+ ; Loop invariant anchored in loop.
+ %idxprom21 = zext i32 undef to i64
+
+ %arrayidx23 = getelementptr inbounds [100 x [100 x i32]]* undef, i64 0, i64 %idxprom21, i64 %indvars.iv17
+ store i32 undef, i32* %arrayidx23, align 4
+ %indvars.next= add i64 %indvars.iv17, -1
+ %0 = trunc i64 %indvars.next to i32
+ %cmp15 = icmp ugt i32 %0, undef
+ br i1 %cmp15, label %for.body, label %loopexit
+
+loopexit:
+ ret void
+}