diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-01-15 22:30:16 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-01-15 22:30:16 +0000 |
| commit | 9f61947910e6ab40de38e6b4034751ef1513200f (patch) | |
| tree | 3231b7529d89052b2edb92bb5ddc6a9e960e5161 /test/Transforms | |
| parent | 5ca98fd98791947eba83a1ed3f2c8191ef7afa6c (diff) | |
Notes
Diffstat (limited to 'test/Transforms')
| -rw-r--r-- | test/Transforms/GCOVProfiling/linezero.ll | 2 | ||||
| -rw-r--r-- | test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll | 2 | ||||
| -rw-r--r-- | test/Transforms/IndVarSimplify/lftr-address-space-pointers.ll | 4 | ||||
| -rw-r--r-- | test/Transforms/IndVarSimplify/lftr-extend-const.ll | 4 | ||||
| -rw-r--r-- | test/Transforms/IndVarSimplify/lftr-reuse.ll | 24 | ||||
| -rw-r--r-- | test/Transforms/IndVarSimplify/pr20680.ll | 219 | ||||
| -rw-r--r-- | test/Transforms/LICM/PR21582.ll | 40 | ||||
| -rw-r--r-- | test/Transforms/LICM/speculate.ll | 10 | ||||
| -rw-r--r-- | test/Transforms/LoopVectorize/incorrect-dom-info.ll | 142 | ||||
| -rw-r--r-- | test/Transforms/LoopVectorize/loop-form.ll | 31 | ||||
| -rw-r--r-- | test/Transforms/LoopVectorize/runtime-check-address-space.ll | 154 | ||||
| -rw-r--r-- | test/Transforms/LoopVectorize/runtime-check-readonly-address-space.ll | 120 | ||||
| -rw-r--r-- | test/Transforms/LoopVectorize/unsized-pointee-crash.ll | 24 | ||||
| -rw-r--r-- | test/Transforms/LoopVectorize/vect.stats.ll | 54 | ||||
| -rw-r--r-- | test/Transforms/SROA/phi-and-select.ll | 34 |
15 files changed, 665 insertions, 199 deletions
diff --git a/test/Transforms/GCOVProfiling/linezero.ll b/test/Transforms/GCOVProfiling/linezero.ll index e2f832498428..ba1c563c64ab 100644 --- a/test/Transforms/GCOVProfiling/linezero.ll +++ b/test/Transforms/GCOVProfiling/linezero.ll @@ -1,4 +1,4 @@ -; RUN: sed -e 's@PATTERN@\%T@g' < %s > %t1 +; RUN: sed -e 's|PATTERN|%T|g' < %s > %t1 ; RUN: opt -insert-gcov-profiling -disable-output < %t1 ; RUN: rm %T/linezero.gcno %t1 ; REQUIRES: shell diff --git a/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll b/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll index a8020e6014b0..e462712fe7a5 100644 --- a/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll +++ b/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll @@ -6,7 +6,7 @@ target triple = "thumbv7-apple-darwin" ; CHECK-LABEL: @test( ; CHECK: if.end.i126: -; CHECK: %exitcond = icmp ne i8* %incdec.ptr.i, getelementptr (i8* null, i32 undef) +; CHECK: %exitcond = icmp ne i8* %destYPixelPtr.010.i, getelementptr (i8* null, i32 undef) define void @test() nounwind { entry: br label %while.cond diff --git a/test/Transforms/IndVarSimplify/lftr-address-space-pointers.ll b/test/Transforms/IndVarSimplify/lftr-address-space-pointers.ll index e4c31d125c60..9e55a1791341 100644 --- a/test/Transforms/IndVarSimplify/lftr-address-space-pointers.ll +++ b/test/Transforms/IndVarSimplify/lftr-address-space-pointers.ll @@ -11,7 +11,7 @@ entry: br i1 %cmp1, label %for.body, label %for.end ; Make sure the added GEP has the right index type -; CHECK: %lftr.limit = getelementptr i8 addrspace(2)* %base, i8 %0 +; CHECK: %lftr.limit = getelementptr i8 addrspace(2)* %base, i8 ; CHECK: for.body: ; CHECK: phi i8 addrspace(2)* @@ -43,7 +43,7 @@ entry: br i1 %cmp1, label %for.body, label %for.end ; Make sure the added GEP has the right index type -; CHECK: %lftr.limit = getelementptr i8 addrspace(3)* %base, i16 %0 +; CHECK: %lftr.limit = getelementptr i8 addrspace(3)* %base, i16 ; CHECK: for.body: ; CHECK: phi i8 addrspace(3)* diff --git a/test/Transforms/IndVarSimplify/lftr-extend-const.ll b/test/Transforms/IndVarSimplify/lftr-extend-const.ll index 4736f857bcce..eeffd0f55024 100644 --- a/test/Transforms/IndVarSimplify/lftr-extend-const.ll +++ b/test/Transforms/IndVarSimplify/lftr-extend-const.ll @@ -2,7 +2,7 @@ ; CHECK-LABEL: @foo( ; CHECK-NOT: %lftr.wideiv = trunc i32 %indvars.iv.next to i16 -; CHECK: %exitcond = icmp ne i32 %indvars.iv.next, 512 +; CHECK: %exitcond = icmp ne i32 %indvars.iv, 511 define void @foo() #0 { entry: br label %for.body @@ -21,7 +21,7 @@ for.end: ; preds = %for.body ; Check that post-incrementing the backedge taken count does not overflow. ; CHECK-LABEL: @postinc( -; CHECK: icmp eq i32 %indvars.iv.next, 256 +; CHECK: icmp eq i32 %indvars.iv, 255 define i32 @postinc() #0 { entry: br label %do.body diff --git a/test/Transforms/IndVarSimplify/lftr-reuse.ll b/test/Transforms/IndVarSimplify/lftr-reuse.ll index 1fdcdd1ec3a4..efb96bdbe6b5 100644 --- a/test/Transforms/IndVarSimplify/lftr-reuse.ll +++ b/test/Transforms/IndVarSimplify/lftr-reuse.ll @@ -82,15 +82,23 @@ exit: ; Perform LFTR without generating extra preheader code. define void @guardedloop([0 x double]* %matrix, [0 x double]* %vector, i32 %irow, i32 %ilead) nounwind { -; CHECK: entry: -; CHECK-NOT: zext -; CHECK-NOT: add -; CHECK: loop: -; CHECK: phi i64 -; CHECK: phi i64 +; CHECK-LABEL: @guardedloop( +; CHECK-LABEL: entry: +; CHECK-NEXT: %[[cmp:.*]] = icmp slt i32 1, %irow +; CHECK-NEXT: br i1 %[[cmp]], label %[[loop_preheader:.*]], label %[[return:.*]] + +; CHECK: [[loop_preheader]]: +; CHECK-NEXT: %[[sext:.*]] = sext i32 %ilead to i64 +; CHECK-NEXT: %[[add:.*]] = add i32 %irow, -1 +; CHECK-NEXT: br label %[[loop:.*]] + +; CHECK: [[loop]]: +; CHECK-NEXT: %[[indvars_iv2:.*]] = phi i64 +; CHECK-NEXT: phi i64 ; CHECK-NOT: phi -; CHECK: icmp ne -; CHECK: br i1 +; CHECK: %[[lftr_wideiv:.*]] = trunc i64 %[[indvars_iv2]] to i32 +; CHECK-NEXT: %[[exitcond:.*]] = icmp ne i32 %[[lftr_wideiv]], %[[add]] +; CHECK-NEXT: br i1 %[[exitcond]], label %[[loop]], label entry: %cmp = icmp slt i32 1, %irow br i1 %cmp, label %loop, label %return diff --git a/test/Transforms/IndVarSimplify/pr20680.ll b/test/Transforms/IndVarSimplify/pr20680.ll new file mode 100644 index 000000000000..88a7fd765d0b --- /dev/null +++ b/test/Transforms/IndVarSimplify/pr20680.ll @@ -0,0 +1,219 @@ +; RUN: opt < %s -indvars -S | FileCheck %s + +@a = common global i32 0, align 4 +@c = common global i32 0, align 4 +@b = common global i32 0, align 4 + +define void @f() { +; CHECK-LABEL: @f( +; CHECK-LABEL: entry: +; CHECK: br label %[[for_cond2_preheader:.*]] + +; CHECK: [[for_cond2_preheader]]: +; CHECK-NEXT: %[[indvars_iv:.*]] = phi i32 [ %[[indvars_iv_next:.*]], %[[for_inc13:.*]] ], [ -14, %entry ] +; br i1 {{.*}}, label %[[for_inc13]], label % +entry: + %0 = load i32* @a, align 4 + %tobool2 = icmp eq i32 %0, 0 + %1 = load i32* @a, align 4 + %tobool = icmp eq i32 %1, 0 + br label %for.cond2.preheader + +for.cond2.preheader: ; preds = %for.inc13, %entry + %storemerge15 = phi i8 [ -14, %entry ], [ %inc14, %for.inc13 ] + br i1 %tobool2, label %for.inc13, label %for.body3.lr.ph + +for.body3.lr.ph: ; preds = %for.cond2.preheader + %tobool5 = icmp eq i8 %storemerge15, 0 + %conv7 = sext i8 %storemerge15 to i32 + %2 = add nsw i32 %conv7, 1 + %3 = icmp ult i32 %2, 3 + %div = select i1 %3, i32 %conv7, i32 0 + br i1 %tobool5, label %for.body3.lr.ph.split.us, label %for.body3.lr.ph.for.body3.lr.ph.split_crit_edge + +for.body3.lr.ph.for.body3.lr.ph.split_crit_edge: ; preds = %for.body3.lr.ph + br label %for.body3.lr.ph.split + +for.body3.lr.ph.split.us: ; preds = %for.body3.lr.ph + br i1 %tobool, label %for.body3.lr.ph.split.us.split.us, label %for.body3.lr.ph.split.us.for.body3.lr.ph.split.us.split_crit_edge + +for.body3.lr.ph.split.us.for.body3.lr.ph.split.us.split_crit_edge: ; preds = %for.body3.lr.ph.split.us + br label %for.body3.lr.ph.split.us.split + +for.body3.lr.ph.split.us.split.us: ; preds = %for.body3.lr.ph.split.us + br label %for.body3.us.us + +for.body3.us.us: ; preds = %for.cond2.loopexit.us.us, %for.body3.lr.ph.split.us.split.us + br i1 true, label %cond.false.us.us, label %cond.end.us.us + +cond.false.us.us: ; preds = %for.body3.us.us + br label %cond.end.us.us + +cond.end.us.us: ; preds = %cond.false.us.us, %for.body3.us.us + %cond.us.us = phi i32 [ %div, %cond.false.us.us ], [ %conv7, %for.body3.us.us ] + %4 = load i32* @b, align 4 + %cmp91.us.us = icmp slt i32 %4, 1 + br i1 %cmp91.us.us, label %for.inc.lr.ph.us.us, label %for.cond2.loopexit.us.us + +for.cond2.loopexit.us.us: ; preds = %for.cond8.for.cond2.loopexit_crit_edge.us.us, %cond.end.us.us + br i1 true, label %for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa.us, label %for.body3.us.us + +for.inc.lr.ph.us.us: ; preds = %cond.end.us.us + br label %for.inc.us.us + +for.cond8.for.cond2.loopexit_crit_edge.us.us: ; preds = %for.inc.us.us + %inc.lcssa.us.us = phi i32 [ %inc.us.us, %for.inc.us.us ] + store i32 %inc.lcssa.us.us, i32* @b, align 4 + br label %for.cond2.loopexit.us.us + +for.inc.us.us: ; preds = %for.inc.us.us, %for.inc.lr.ph.us.us + %5 = phi i32 [ %4, %for.inc.lr.ph.us.us ], [ %inc.us.us, %for.inc.us.us ] + %inc.us.us = add nsw i32 %5, 1 + %cmp9.us.us = icmp slt i32 %inc.us.us, 1 + br i1 %cmp9.us.us, label %for.inc.us.us, label %for.cond8.for.cond2.loopexit_crit_edge.us.us + +for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa.us: ; preds = %for.cond2.loopexit.us.us + %cond.lcssa.ph.us.ph.us = phi i32 [ %cond.us.us, %for.cond2.loopexit.us.us ] + br label %for.cond2.for.inc13_crit_edge.us-lcssa.us + +for.body3.lr.ph.split.us.split: ; preds = %for.body3.lr.ph.split.us.for.body3.lr.ph.split.us.split_crit_edge + br label %for.body3.us + +for.body3.us: ; preds = %for.cond2.loopexit.us, %for.body3.lr.ph.split.us.split + br i1 true, label %cond.false.us, label %cond.end.us + +cond.false.us: ; preds = %for.body3.us + br label %cond.end.us + +cond.end.us: ; preds = %cond.false.us, %for.body3.us + %cond.us = phi i32 [ %div, %cond.false.us ], [ %conv7, %for.body3.us ] + %6 = load i32* @b, align 4 + %cmp91.us = icmp slt i32 %6, 1 + br i1 %cmp91.us, label %for.inc.lr.ph.us, label %for.cond2.loopexit.us + +for.inc.us: ; preds = %for.inc.lr.ph.us, %for.inc.us + %7 = phi i32 [ %6, %for.inc.lr.ph.us ], [ %inc.us, %for.inc.us ] + %inc.us = add nsw i32 %7, 1 + %cmp9.us = icmp slt i32 %inc.us, 1 + br i1 %cmp9.us, label %for.inc.us, label %for.cond8.for.cond2.loopexit_crit_edge.us + +for.cond2.loopexit.us: ; preds = %for.cond8.for.cond2.loopexit_crit_edge.us, %cond.end.us + br i1 false, label %for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa, label %for.body3.us + +for.inc.lr.ph.us: ; preds = %cond.end.us + br label %for.inc.us + +for.cond8.for.cond2.loopexit_crit_edge.us: ; preds = %for.inc.us + %inc.lcssa.us = phi i32 [ %inc.us, %for.inc.us ] + store i32 %inc.lcssa.us, i32* @b, align 4 + br label %for.cond2.loopexit.us + +for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa: ; preds = %for.cond2.loopexit.us + %cond.lcssa.ph.us.ph = phi i32 [ %cond.us, %for.cond2.loopexit.us ] + br label %for.cond2.for.inc13_crit_edge.us-lcssa.us + +for.cond2.for.inc13_crit_edge.us-lcssa.us: ; preds = %for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa, %for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa.us + %cond.lcssa.ph.us = phi i32 [ %cond.lcssa.ph.us.ph, %for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa ], [ %cond.lcssa.ph.us.ph.us, %for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa.us ] + br label %for.cond2.for.inc13_crit_edge + +for.body3.lr.ph.split: ; preds = %for.body3.lr.ph.for.body3.lr.ph.split_crit_edge + br i1 %tobool, label %for.body3.lr.ph.split.split.us, label %for.body3.lr.ph.split.for.body3.lr.ph.split.split_crit_edge + +for.body3.lr.ph.split.for.body3.lr.ph.split.split_crit_edge: ; preds = %for.body3.lr.ph.split + br label %for.body3.lr.ph.split.split + +for.body3.lr.ph.split.split.us: ; preds = %for.body3.lr.ph.split + br label %for.body3.us3 + +for.body3.us3: ; preds = %for.cond2.loopexit.us11, %for.body3.lr.ph.split.split.us + br i1 false, label %cond.false.us4, label %cond.end.us5 + +cond.false.us4: ; preds = %for.body3.us3 + br label %cond.end.us5 + +cond.end.us5: ; preds = %cond.false.us4, %for.body3.us3 + %cond.us6 = phi i32 [ %div, %cond.false.us4 ], [ %conv7, %for.body3.us3 ] + %8 = load i32* @b, align 4 + %cmp91.us7 = icmp slt i32 %8, 1 + br i1 %cmp91.us7, label %for.inc.lr.ph.us12, label %for.cond2.loopexit.us11 + +for.inc.us8: ; preds = %for.inc.lr.ph.us12, %for.inc.us8 + %9 = phi i32 [ %8, %for.inc.lr.ph.us12 ], [ %inc.us9, %for.inc.us8 ] + %inc.us9 = add nsw i32 %9, 1 + %cmp9.us10 = icmp slt i32 %inc.us9, 1 + br i1 %cmp9.us10, label %for.inc.us8, label %for.cond8.for.cond2.loopexit_crit_edge.us13 + +for.cond2.loopexit.us11: ; preds = %for.cond8.for.cond2.loopexit_crit_edge.us13, %cond.end.us5 + br i1 true, label %for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa.us, label %for.body3.us3 + +for.inc.lr.ph.us12: ; preds = %cond.end.us5 + br label %for.inc.us8 + +for.cond8.for.cond2.loopexit_crit_edge.us13: ; preds = %for.inc.us8 + %inc.lcssa.us14 = phi i32 [ %inc.us9, %for.inc.us8 ] + store i32 %inc.lcssa.us14, i32* @b, align 4 + br label %for.cond2.loopexit.us11 + +for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa.us: ; preds = %for.cond2.loopexit.us11 + %cond.lcssa.ph.ph.us = phi i32 [ %cond.us6, %for.cond2.loopexit.us11 ] + br label %for.cond2.for.inc13_crit_edge.us-lcssa + +for.body3.lr.ph.split.split: ; preds = %for.body3.lr.ph.split.for.body3.lr.ph.split.split_crit_edge + br label %for.body3 + +for.cond8.for.cond2.loopexit_crit_edge: ; preds = %for.inc + %inc.lcssa = phi i32 [ %inc, %for.inc ] + store i32 %inc.lcssa, i32* @b, align 4 + br label %for.cond2.loopexit + +for.cond2.loopexit: ; preds = %cond.end, %for.cond8.for.cond2.loopexit_crit_edge + br i1 false, label %for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa, label %for.body3 + +for.body3: ; preds = %for.cond2.loopexit, %for.body3.lr.ph.split.split + br i1 false, label %cond.false, label %cond.end + +cond.false: ; preds = %for.body3 + br label %cond.end + +cond.end: ; preds = %cond.false, %for.body3 + %cond = phi i32 [ %div, %cond.false ], [ %conv7, %for.body3 ] + %10 = load i32* @b, align 4 + %cmp91 = icmp slt i32 %10, 1 + br i1 %cmp91, label %for.inc.lr.ph, label %for.cond2.loopexit + +for.inc.lr.ph: ; preds = %cond.end + br label %for.inc + +for.inc: ; preds = %for.inc, %for.inc.lr.ph + %11 = phi i32 [ %10, %for.inc.lr.ph ], [ %inc, %for.inc ] + %inc = add nsw i32 %11, 1 + %cmp9 = icmp slt i32 %inc, 1 + br i1 %cmp9, label %for.inc, label %for.cond8.for.cond2.loopexit_crit_edge + +for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa: ; preds = %for.cond2.loopexit + %cond.lcssa.ph.ph = phi i32 [ %cond, %for.cond2.loopexit ] + br label %for.cond2.for.inc13_crit_edge.us-lcssa + +for.cond2.for.inc13_crit_edge.us-lcssa: ; preds = %for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa, %for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa.us + %cond.lcssa.ph = phi i32 [ %cond.lcssa.ph.ph, %for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa ], [ %cond.lcssa.ph.ph.us, %for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa.us ] + br label %for.cond2.for.inc13_crit_edge + +for.cond2.for.inc13_crit_edge: ; preds = %for.cond2.for.inc13_crit_edge.us-lcssa, %for.cond2.for.inc13_crit_edge.us-lcssa.us + %cond.lcssa = phi i32 [ %cond.lcssa.ph, %for.cond2.for.inc13_crit_edge.us-lcssa ], [ %cond.lcssa.ph.us, %for.cond2.for.inc13_crit_edge.us-lcssa.us ] + store i32 %cond.lcssa, i32* @c, align 4 + br label %for.inc13 + +; CHECK: [[for_inc13]]: +; CHECK-NEXT: %[[indvars_iv_next]] = add nuw nsw i32 %[[indvars_iv]], 1 +; CHECK-NEXT: %[[exitcond4:.*]] = icmp ne i32 %[[indvars_iv]], -1 +; CHECK-NEXT: br i1 %[[exitcond4]], label %[[for_cond2_preheader]], label %[[for_end15:.*]] +for.inc13: ; preds = %for.cond2.for.inc13_crit_edge, %for.cond2.preheader + %inc14 = add i8 %storemerge15, 1 + %cmp = icmp ugt i8 %inc14, 50 + br i1 %cmp, label %for.cond2.preheader, label %for.end15 + +; CHECK: [[for_end15]]: +; CHECK-NEXT: ret void +for.end15: ; preds = %for.inc13 + ret void +} diff --git a/test/Transforms/LICM/PR21582.ll b/test/Transforms/LICM/PR21582.ll new file mode 100644 index 000000000000..c068c2f8e32b --- /dev/null +++ b/test/Transforms/LICM/PR21582.ll @@ -0,0 +1,40 @@ +; RUN: opt < %s -basicaa -licm -S | FileCheck %s +@b = external global i32, align 4 +@fn3.i = external global i32, align 4 + +declare i32 @g() nounwind + +define i32 @f() { +entry: + br label %for.cond + +for.cond: ; preds = %for.end, %entry +; CHECK-LABEL: for.cond: +; CHECK: store i32 0, i32* @b + store i32 0, i32* @b, align 4 + br i1 true, label %for.body.preheader, label %for.end + +for.body.preheader: ; preds = %for.cond + br label %for.body + +for.body: ; preds = %for.body, %for.body.preheader + %g.15 = phi i32 [ undef, %for.body ], [ 0, %for.body.preheader ] + %arrayidx2 = getelementptr inbounds i32* @fn3.i, i64 0 + %0 = load i32* %arrayidx2, align 4 + %call = call i32 @g() + br i1 false, label %for.body, label %for.end.loopexit + +for.end.loopexit: ; preds = %for.body + br label %for.end + +for.end: ; preds = %for.end.loopexit, %for.cond + %whatever = phi i32 [ %call, %for.end.loopexit ], [ undef, %for.cond ] + br i1 false, label %for.cond, label %if.then + +if.then: ; preds = %for.end +; CHECK-LABEL: if.then: +; CHECK: phi i32 [ {{.*}}, %for.end ] +; CHECK-NOT: store i32 0, i32* @b +; CHECK: ret i32 + ret i32 %whatever +} diff --git a/test/Transforms/LICM/speculate.ll b/test/Transforms/LICM/speculate.ll index 4244f157d9f8..69266693c479 100644 --- a/test/Transforms/LICM/speculate.ll +++ b/test/Transforms/LICM/speculate.ll @@ -3,12 +3,11 @@ ; UDiv is safe to speculate if the denominator is known non-zero. ; CHECK-LABEL: @safe_udiv( -; CHECK: %div = udiv i64 %x, %or +; CHECK: %div = udiv i64 %x, 2 ; CHECK-NEXT: br label %for.body define void @safe_udiv(i64 %x, i64 %m, i64 %n, i32* %p, i64* %q) nounwind { entry: - %or = or i64 %m, 1 br label %for.body for.body: ; preds = %entry, %for.inc @@ -19,7 +18,7 @@ for.body: ; preds = %entry, %for.inc br i1 %tobool, label %for.inc, label %if.then if.then: ; preds = %for.body - %div = udiv i64 %x, %or + %div = udiv i64 %x, 2 %arrayidx1 = getelementptr inbounds i64* %q, i64 %i.02 store i64 %div, i64* %arrayidx1, align 8 br label %for.inc @@ -69,13 +68,12 @@ for.end: ; preds = %for.inc, %entry ; known to have at least one zero bit. ; CHECK-LABEL: @safe_sdiv( -; CHECK: %div = sdiv i64 %x, %or +; CHECK: %div = sdiv i64 %x, 2 ; CHECK-NEXT: br label %for.body define void @safe_sdiv(i64 %x, i64 %m, i64 %n, i32* %p, i64* %q) nounwind { entry: %and = and i64 %m, -3 - %or = or i64 %and, 1 br label %for.body for.body: ; preds = %entry, %for.inc @@ -86,7 +84,7 @@ for.body: ; preds = %entry, %for.inc br i1 %tobool, label %for.inc, label %if.then if.then: ; preds = %for.body - %div = sdiv i64 %x, %or + %div = sdiv i64 %x, 2 %arrayidx1 = getelementptr inbounds i64* %q, i64 %i.02 store i64 %div, i64* %arrayidx1, align 8 br label %for.inc diff --git a/test/Transforms/LoopVectorize/incorrect-dom-info.ll b/test/Transforms/LoopVectorize/incorrect-dom-info.ll new file mode 100644 index 000000000000..624ee7e50597 --- /dev/null +++ b/test/Transforms/LoopVectorize/incorrect-dom-info.ll @@ -0,0 +1,142 @@ +; This test is based on one of benchmarks from SPEC2006. It exposes a bug with +; incorrect updating of the dom-tree. +; RUN: opt < %s -loop-vectorize -verify-dom-info +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" + +@PL_utf8skip = external constant [0 x i8] + +; Function Attrs: nounwind ssp uwtable +define void @Perl_pp_quotemeta() #0 { + %len = alloca i64, align 8 + br i1 undef, label %2, label %1 + +; <label>:1 ; preds = %0 + br label %3 + +; <label>:2 ; preds = %0 + br label %3 + +; <label>:3 ; preds = %2, %1 + br i1 undef, label %34, label %4 + +; <label>:4 ; preds = %3 + br i1 undef, label %5, label %6 + +; <label>:5 ; preds = %4 + br label %6 + +; <label>:6 ; preds = %5, %4 + br i1 undef, label %7, label %8 + +; <label>:7 ; preds = %6 + br label %8 + +; <label>:8 ; preds = %7, %6 + br i1 undef, label %.preheader, label %9 + +.preheader: ; preds = %9, %8 + br i1 undef, label %.loopexit, label %.lr.ph + +; <label>:9 ; preds = %8 + br i1 undef, label %thread-pre-split.preheader, label %.preheader + +thread-pre-split.preheader: ; preds = %9 + br i1 undef, label %thread-pre-split._crit_edge, label %.lr.ph21 + +.thread-pre-split.loopexit_crit_edge: ; preds = %19 + %scevgep.sum = xor i64 %umax, -1 + %scevgep45 = getelementptr i8* %d.020, i64 %scevgep.sum + br label %thread-pre-split.loopexit + +thread-pre-split.loopexit: ; preds = %11, %.thread-pre-split.loopexit_crit_edge + %d.1.lcssa = phi i8* [ %scevgep45, %.thread-pre-split.loopexit_crit_edge ], [ %d.020, %11 ] + br i1 false, label %thread-pre-split._crit_edge, label %.lr.ph21 + +.lr.ph21: ; preds = %26, %thread-pre-split.loopexit, %thread-pre-split.preheader + %d.020 = phi i8* [ undef, %26 ], [ %d.1.lcssa, %thread-pre-split.loopexit ], [ undef, %thread-pre-split.preheader ] + %10 = phi i64 [ %28, %26 ], [ undef, %thread-pre-split.loopexit ], [ undef, %thread-pre-split.preheader ] + br i1 undef, label %11, label %22 + +; <label>:11 ; preds = %.lr.ph21 + %12 = getelementptr inbounds [0 x i8]* @PL_utf8skip, i64 0, i64 undef + %13 = load i8* %12, align 1 + %14 = zext i8 %13 to i64 + %15 = icmp ugt i64 %14, %10 + %. = select i1 %15, i64 %10, i64 %14 + br i1 undef, label %thread-pre-split.loopexit, label %.lr.ph28 + +.lr.ph28: ; preds = %11 + %16 = xor i64 %10, -1 + %17 = xor i64 %14, -1 + %18 = icmp ugt i64 %16, %17 + %umax = select i1 %18, i64 %16, i64 %17 + br label %19 + +; <label>:19 ; preds = %19, %.lr.ph28 + %ulen.126 = phi i64 [ %., %.lr.ph28 ], [ %20, %19 ] + %20 = add i64 %ulen.126, -1 + %21 = icmp eq i64 %20, 0 + br i1 %21, label %.thread-pre-split.loopexit_crit_edge, label %19 + +; <label>:22 ; preds = %.lr.ph21 + br i1 undef, label %26, label %23 + +; <label>:23 ; preds = %22 + br i1 undef, label %26, label %24 + +; <label>:24 ; preds = %23 + br i1 undef, label %26, label %25 + +; <label>:25 ; preds = %24 + br label %26 + +; <label>:26 ; preds = %25, %24, %23, %22 + %27 = load i64* %len, align 8 + %28 = add i64 %27, -1 + br i1 undef, label %thread-pre-split._crit_edge, label %.lr.ph21 + +thread-pre-split._crit_edge: ; preds = %26, %thread-pre-split.loopexit, %thread-pre-split.preheader + br label %.loopexit + +.lr.ph: ; preds = %33, %.preheader + br i1 undef, label %29, label %thread-pre-split5 + +; <label>:29 ; preds = %.lr.ph + br i1 undef, label %33, label %30 + +; <label>:30 ; preds = %29 + br i1 undef, label %33, label %31 + +thread-pre-split5: ; preds = %.lr.ph + br i1 undef, label %33, label %31 + +; <label>:31 ; preds = %thread-pre-split5, %30 + br i1 undef, label %33, label %32 + +; <label>:32 ; preds = %31 + br label %33 + +; <label>:33 ; preds = %32, %31, %thread-pre-split5, %30, %29 + br i1 undef, label %.loopexit, label %.lr.ph + +.loopexit: ; preds = %33, %thread-pre-split._crit_edge, %.preheader + br label %35 + +; <label>:34 ; preds = %3 + br label %35 + +; <label>:35 ; preds = %34, %.loopexit + br i1 undef, label %37, label %36 + +; <label>:36 ; preds = %35 + br label %37 + +; <label>:37 ; preds = %36, %35 + ret void +} + +attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.ident = !{!0} + +!0 = metadata !{metadata !"clang version 3.6.0 "} diff --git a/test/Transforms/LoopVectorize/loop-form.ll b/test/Transforms/LoopVectorize/loop-form.ll new file mode 100644 index 000000000000..138df1d96138 --- /dev/null +++ b/test/Transforms/LoopVectorize/loop-form.ll @@ -0,0 +1,31 @@ +; RUN: opt -S -loop-vectorize < %s | FileCheck %s +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" + +; Check that we vectorize only bottom-tested loops. +; This is a reduced testcase from PR21302. +; +; rdar://problem/18886083 + +%struct.X = type { i32, i16 } +; CHECK-LABEL: @foo( +; CHECK-NOT: vector.body + +define void @foo(i32 %n) { +entry: + br label %for.cond + +for.cond: + %i = phi i32 [ 0, %entry ], [ %inc, %for.body ] + %cmp = icmp slt i32 %i, %n + br i1 %cmp, label %for.body, label %if.end + +for.body: + %iprom = sext i32 %i to i64 + %b = getelementptr inbounds %struct.X* undef, i64 %iprom, i32 1 + store i16 0, i16* %b, align 4 + %inc = add nsw i32 %i, 1 + br label %for.cond + +if.end: + ret void +} diff --git a/test/Transforms/LoopVectorize/runtime-check-address-space.ll b/test/Transforms/LoopVectorize/runtime-check-address-space.ll index 5bf7020a475a..848ffc428c5f 100644 --- a/test/Transforms/LoopVectorize/runtime-check-address-space.ll +++ b/test/Transforms/LoopVectorize/runtime-check-address-space.ll @@ -31,25 +31,23 @@ define void @foo(i32 addrspace(1)* %a, i32 addrspace(1)* %b, i32 %n) #0 { ; CHECK: ret entry: - br label %for.cond + %cmp1 = icmp slt i32 0, %n + br i1 %cmp1, label %for.body, label %for.end -for.cond: ; preds = %for.body, %entry - %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] - %cmp = icmp slt i32 %i.0, %n - br i1 %cmp, label %for.body, label %for.end - -for.body: ; preds = %for.cond - %idxprom = sext i32 %i.0 to i64 +for.body: ; preds = %entry, %for.body + %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ] + %idxprom = sext i32 %i.02 to i64 %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %idxprom %0 = load i32 addrspace(1)* %arrayidx, align 4 %mul = mul nsw i32 %0, 3 - %idxprom1 = sext i32 %i.0 to i64 + %idxprom1 = sext i32 %i.02 to i64 %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %idxprom1 store i32 %mul, i32 addrspace(1)* %arrayidx2, align 4 - %inc = add nsw i32 %i.0, 1 - br label %for.cond + %inc = add nsw i32 %i.02, 1 + %cmp = icmp slt i32 %inc, %n + br i1 %cmp, label %for.body, label %for.end -for.end: ; preds = %for.cond +for.end: ; preds = %for.body, %entry ret void } @@ -60,25 +58,23 @@ define void @bar0(i32* %a, i32 addrspace(1)* %b, i32 %n) #0 { ; CHECK: ret entry: - br label %for.cond + %cmp1 = icmp slt i32 0, %n + br i1 %cmp1, label %for.body, label %for.end -for.cond: ; preds = %for.body, %entry - %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] - %cmp = icmp slt i32 %i.0, %n - br i1 %cmp, label %for.body, label %for.end - -for.body: ; preds = %for.cond - %idxprom = sext i32 %i.0 to i64 +for.body: ; preds = %entry, %for.body + %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ] + %idxprom = sext i32 %i.02 to i64 %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %idxprom %0 = load i32 addrspace(1)* %arrayidx, align 4 %mul = mul nsw i32 %0, 3 - %idxprom1 = sext i32 %i.0 to i64 + %idxprom1 = sext i32 %i.02 to i64 %arrayidx2 = getelementptr inbounds i32* %a, i64 %idxprom1 store i32 %mul, i32* %arrayidx2, align 4 - %inc = add nsw i32 %i.0, 1 - br label %for.cond + %inc = add nsw i32 %i.02, 1 + %cmp = icmp slt i32 %inc, %n + br i1 %cmp, label %for.body, label %for.end -for.end: ; preds = %for.cond +for.end: ; preds = %for.body, %entry ret void } @@ -89,25 +85,23 @@ define void @bar1(i32 addrspace(1)* %a, i32* %b, i32 %n) #0 { ; CHECK: ret entry: - br label %for.cond + %cmp1 = icmp slt i32 0, %n + br i1 %cmp1, label %for.body, label %for.end -for.cond: ; preds = %for.body, %entry - %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] - %cmp = icmp slt i32 %i.0, %n - br i1 %cmp, label %for.body, label %for.end - -for.body: ; preds = %for.cond - %idxprom = sext i32 %i.0 to i64 +for.body: ; preds = %entry, %for.body + %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ] + %idxprom = sext i32 %i.02 to i64 %arrayidx = getelementptr inbounds i32* %b, i64 %idxprom %0 = load i32* %arrayidx, align 4 %mul = mul nsw i32 %0, 3 - %idxprom1 = sext i32 %i.0 to i64 + %idxprom1 = sext i32 %i.02 to i64 %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %idxprom1 store i32 %mul, i32 addrspace(1)* %arrayidx2, align 4 - %inc = add nsw i32 %i.0, 1 - br label %for.cond + %inc = add nsw i32 %i.02, 1 + %cmp = icmp slt i32 %inc, %n + br i1 %cmp, label %for.body, label %for.end -for.end: ; preds = %for.cond +for.end: ; preds = %for.body, %entry ret void } @@ -119,25 +113,23 @@ define void @bar2(i32* noalias %a, i32 addrspace(1)* noalias %b, i32 %n) #0 { ; CHECK: ret entry: - br label %for.cond - -for.cond: ; preds = %for.body, %entry - %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] - %cmp = icmp slt i32 %i.0, %n - br i1 %cmp, label %for.body, label %for.end + %cmp1 = icmp slt i32 0, %n + br i1 %cmp1, label %for.body, label %for.end -for.body: ; preds = %for.cond - %idxprom = sext i32 %i.0 to i64 +for.body: ; preds = %entry, %for.body + %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ] + %idxprom = sext i32 %i.02 to i64 %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %idxprom %0 = load i32 addrspace(1)* %arrayidx, align 4 %mul = mul nsw i32 %0, 3 - %idxprom1 = sext i32 %i.0 to i64 + %idxprom1 = sext i32 %i.02 to i64 %arrayidx2 = getelementptr inbounds i32* %a, i64 %idxprom1 store i32 %mul, i32* %arrayidx2, align 4 - %inc = add nsw i32 %i.0, 1 - br label %for.cond + %inc = add nsw i32 %i.02, 1 + %cmp = icmp slt i32 %inc, %n + br i1 %cmp, label %for.body, label %for.end -for.end: ; preds = %for.cond +for.end: ; preds = %for.body, %entry ret void } @@ -149,25 +141,23 @@ define void @arst0(i32* %b, i32 %n) #0 { ; CHECK: ret entry: - br label %for.cond - -for.cond: ; preds = %for.body, %entry - %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] - %cmp = icmp slt i32 %i.0, %n - br i1 %cmp, label %for.body, label %for.end + %cmp1 = icmp slt i32 0, %n + br i1 %cmp1, label %for.body, label %for.end -for.body: ; preds = %for.cond - %idxprom = sext i32 %i.0 to i64 +for.body: ; preds = %entry, %for.body + %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ] + %idxprom = sext i32 %i.02 to i64 %arrayidx = getelementptr inbounds i32* %b, i64 %idxprom %0 = load i32* %arrayidx, align 4 %mul = mul nsw i32 %0, 3 - %idxprom1 = sext i32 %i.0 to i64 + %idxprom1 = sext i32 %i.02 to i64 %arrayidx2 = getelementptr inbounds [1024 x i32] addrspace(1)* @g_as1, i64 0, i64 %idxprom1 store i32 %mul, i32 addrspace(1)* %arrayidx2, align 4 - %inc = add nsw i32 %i.0, 1 - br label %for.cond + %inc = add nsw i32 %i.02, 1 + %cmp = icmp slt i32 %inc, %n + br i1 %cmp, label %for.body, label %for.end -for.end: ; preds = %for.cond +for.end: ; preds = %for.body, %entry ret void } @@ -180,25 +170,23 @@ define void @arst1(i32* %b, i32 %n) #0 { ; CHECK: ret entry: - br label %for.cond - -for.cond: ; preds = %for.body, %entry - %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] - %cmp = icmp slt i32 %i.0, %n - br i1 %cmp, label %for.body, label %for.end + %cmp1 = icmp slt i32 0, %n + br i1 %cmp1, label %for.body, label %for.end -for.body: ; preds = %for.cond - %idxprom = sext i32 %i.0 to i64 +for.body: ; preds = %entry, %for.body + %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ] + %idxprom = sext i32 %i.02 to i64 %arrayidx = getelementptr inbounds [1024 x i32] addrspace(1)* @g_as1, i64 0, i64 %idxprom %0 = load i32 addrspace(1)* %arrayidx, align 4 %mul = mul nsw i32 %0, 3 - %idxprom1 = sext i32 %i.0 to i64 + %idxprom1 = sext i32 %i.02 to i64 %arrayidx2 = getelementptr inbounds i32* %b, i64 %idxprom1 store i32 %mul, i32* %arrayidx2, align 4 - %inc = add nsw i32 %i.0, 1 - br label %for.cond + %inc = add nsw i32 %i.02, 1 + %cmp = icmp slt i32 %inc, %n + br i1 %cmp, label %for.body, label %for.end -for.end: ; preds = %for.cond +for.end: ; preds = %for.body, %entry ret void } @@ -210,25 +198,23 @@ define void @aoeu(i32 %n) #0 { ; CHECK: ret entry: - br label %for.cond + %cmp1 = icmp slt i32 0, %n + br i1 %cmp1, label %for.body, label %for.end -for.cond: ; preds = %for.body, %entry - %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] - %cmp = icmp slt i32 %i.0, %n - br i1 %cmp, label %for.body, label %for.end - -for.body: ; preds = %for.cond - %idxprom = sext i32 %i.0 to i64 +for.body: ; preds = %entry, %for.body + %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ] + %idxprom = sext i32 %i.02 to i64 %arrayidx = getelementptr inbounds [1024 x i32] addrspace(2)* @q_as2, i64 0, i64 %idxprom %0 = load i32 addrspace(2)* %arrayidx, align 4 %mul = mul nsw i32 %0, 3 - %idxprom1 = sext i32 %i.0 to i64 + %idxprom1 = sext i32 %i.02 to i64 %arrayidx2 = getelementptr inbounds [1024 x i32] addrspace(1)* @g_as1, i64 0, i64 %idxprom1 store i32 %mul, i32 addrspace(1)* %arrayidx2, align 4 - %inc = add nsw i32 %i.0, 1 - br label %for.cond + %inc = add nsw i32 %i.02, 1 + %cmp = icmp slt i32 %inc, %n + br i1 %cmp, label %for.body, label %for.end -for.end: ; preds = %for.cond +for.end: ; preds = %for.body, %entry ret void } diff --git a/test/Transforms/LoopVectorize/runtime-check-readonly-address-space.ll b/test/Transforms/LoopVectorize/runtime-check-readonly-address-space.ll index 212b37cceab3..4e98ec504f5b 100644 --- a/test/Transforms/LoopVectorize/runtime-check-readonly-address-space.ll +++ b/test/Transforms/LoopVectorize/runtime-check-readonly-address-space.ll @@ -8,26 +8,24 @@ define void @add_ints_1_1_1(i32 addrspace(1)* %a, i32 addrspace(1)* %b, i32 addr ; CHECK-LABEL: @add_ints_1_1_1( ; CHECK: <4 x i32> ; CHECK: ret -entry: - br label %for.cond -for.cond: ; preds = %for.body, %entry - %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ] - %cmp = icmp ult i64 %i.0, 200 - br i1 %cmp, label %for.body, label %for.end +entry: + br label %for.body -for.body: ; preds = %for.cond - %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.0 +for.body: ; preds = %entry, %for.body + %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ] + %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.01 %0 = load i32 addrspace(1)* %arrayidx, align 4 - %arrayidx1 = getelementptr inbounds i32 addrspace(1)* %c, i64 %i.0 + %arrayidx1 = getelementptr inbounds i32 addrspace(1)* %c, i64 %i.01 %1 = load i32 addrspace(1)* %arrayidx1, align 4 %add = add nsw i32 %0, %1 - %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %i.0 + %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %i.01 store i32 %add, i32 addrspace(1)* %arrayidx2, align 4 - %inc = add i64 %i.0, 1 - br label %for.cond + %inc = add i64 %i.01, 1 + %cmp = icmp ult i64 %inc, 200 + br i1 %cmp, label %for.body, label %for.end -for.end: ; preds = %for.cond +for.end: ; preds = %for.body ret void } @@ -35,26 +33,24 @@ define void @add_ints_as_1_0_0(i32 addrspace(1)* %a, i32* %b, i32* %c) #0 { ; CHECK-LABEL: @add_ints_as_1_0_0( ; CHECK-NOT: <4 x i32> ; CHECK: ret -entry: - br label %for.cond -for.cond: ; preds = %for.body, %entry - %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ] - %cmp = icmp ult i64 %i.0, 200 - br i1 %cmp, label %for.body, label %for.end +entry: + br label %for.body -for.body: ; preds = %for.cond - %arrayidx = getelementptr inbounds i32* %b, i64 %i.0 +for.body: ; preds = %entry, %for.body + %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ] + %arrayidx = getelementptr inbounds i32* %b, i64 %i.01 %0 = load i32* %arrayidx, align 4 - %arrayidx1 = getelementptr inbounds i32* %c, i64 %i.0 + %arrayidx1 = getelementptr inbounds i32* %c, i64 %i.01 %1 = load i32* %arrayidx1, align 4 %add = add nsw i32 %0, %1 - %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %i.0 + %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %i.01 store i32 %add, i32 addrspace(1)* %arrayidx2, align 4 - %inc = add i64 %i.0, 1 - br label %for.cond + %inc = add i64 %i.01, 1 + %cmp = icmp ult i64 %inc, 200 + br i1 %cmp, label %for.body, label %for.end -for.end: ; preds = %for.cond +for.end: ; preds = %for.body ret void } @@ -62,26 +58,24 @@ define void @add_ints_as_0_1_0(i32* %a, i32 addrspace(1)* %b, i32* %c) #0 { ; CHECK-LABEL: @add_ints_as_0_1_0( ; CHECK-NOT: <4 x i32> ; CHECK: ret -entry: - br label %for.cond -for.cond: ; preds = %for.body, %entry - %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ] - %cmp = icmp ult i64 %i.0, 200 - br i1 %cmp, label %for.body, label %for.end +entry: + br label %for.body -for.body: ; preds = %for.cond - %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.0 +for.body: ; preds = %entry, %for.body + %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ] + %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.01 %0 = load i32 addrspace(1)* %arrayidx, align 4 - %arrayidx1 = getelementptr inbounds i32* %c, i64 %i.0 + %arrayidx1 = getelementptr inbounds i32* %c, i64 %i.01 %1 = load i32* %arrayidx1, align 4 %add = add nsw i32 %0, %1 - %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.0 + %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.01 store i32 %add, i32* %arrayidx2, align 4 - %inc = add i64 %i.0, 1 - br label %for.cond + %inc = add i64 %i.01, 1 + %cmp = icmp ult i64 %inc, 200 + br i1 %cmp, label %for.body, label %for.end -for.end: ; preds = %for.cond +for.end: ; preds = %for.body ret void } @@ -89,26 +83,24 @@ define void @add_ints_as_0_1_1(i32* %a, i32 addrspace(1)* %b, i32 addrspace(1)* ; CHECK-LABEL: @add_ints_as_0_1_1( ; CHECK-NOT: <4 x i32> ; CHECK: ret -entry: - br label %for.cond -for.cond: ; preds = %for.body, %entry - %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ] - %cmp = icmp ult i64 %i.0, 200 - br i1 %cmp, label %for.body, label %for.end +entry: + br label %for.body -for.body: ; preds = %for.cond - %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.0 +for.body: ; preds = %entry, %for.body + %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ] + %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.01 %0 = load i32 addrspace(1)* %arrayidx, align 4 - %arrayidx1 = getelementptr inbounds i32 addrspace(1)* %c, i64 %i.0 + %arrayidx1 = getelementptr inbounds i32 addrspace(1)* %c, i64 %i.01 %1 = load i32 addrspace(1)* %arrayidx1, align 4 %add = add nsw i32 %0, %1 - %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.0 + %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.01 store i32 %add, i32* %arrayidx2, align 4 - %inc = add i64 %i.0, 1 - br label %for.cond + %inc = add i64 %i.01, 1 + %cmp = icmp ult i64 %inc, 200 + br i1 %cmp, label %for.body, label %for.end -for.end: ; preds = %for.cond +for.end: ; preds = %for.body ret void } @@ -116,26 +108,24 @@ define void @add_ints_as_0_1_2(i32* %a, i32 addrspace(1)* %b, i32 addrspace(2)* ; CHECK-LABEL: @add_ints_as_0_1_2( ; CHECK-NOT: <4 x i32> ; CHECK: ret -entry: - br label %for.cond -for.cond: ; preds = %for.body, %entry - %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ] - %cmp = icmp ult i64 %i.0, 200 - br i1 %cmp, label %for.body, label %for.end +entry: + br label %for.body -for.body: ; preds = %for.cond - %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.0 +for.body: ; preds = %entry, %for.body + %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ] + %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.01 %0 = load i32 addrspace(1)* %arrayidx, align 4 - %arrayidx1 = getelementptr inbounds i32 addrspace(2)* %c, i64 %i.0 + %arrayidx1 = getelementptr inbounds i32 addrspace(2)* %c, i64 %i.01 %1 = load i32 addrspace(2)* %arrayidx1, align 4 %add = add nsw i32 %0, %1 - %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.0 + %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.01 store i32 %add, i32* %arrayidx2, align 4 - %inc = add i64 %i.0, 1 - br label %for.cond + %inc = add i64 %i.01, 1 + %cmp = icmp ult i64 %inc, 200 + br i1 %cmp, label %for.body, label %for.end -for.end: ; preds = %for.cond +for.end: ; preds = %for.body ret void } diff --git a/test/Transforms/LoopVectorize/unsized-pointee-crash.ll b/test/Transforms/LoopVectorize/unsized-pointee-crash.ll new file mode 100644 index 000000000000..5cc98378b952 --- /dev/null +++ b/test/Transforms/LoopVectorize/unsized-pointee-crash.ll @@ -0,0 +1,24 @@ +; RUN: opt -S -loop-vectorize < %s | FileCheck %s +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; CHECK-LABEL: @fn1 +define void @fn1() { +entry: + br label %for.body + +for.body: + %b.05 = phi i32 (...)* [ undef, %entry ], [ %1, %for.body ] + %a.04 = phi i32 [ 0, %entry ], [ %inc, %for.body ] + %0 = bitcast i32 (...)* %b.05 to i8* + %add.ptr = getelementptr i8* %0, i64 1 + %1 = bitcast i8* %add.ptr to i32 (...)* +; CHECK: %[[cst:.*]] = bitcast i32 (...)* {{.*}} to i8* +; CHECK-NEXT: %[[gep:.*]] = getelementptr i8* %[[cst]], i64 1 + %inc = add nsw i32 %a.04, 1 + %exitcond = icmp eq i32 %a.04, 63 + br i1 %exitcond, label %for.end, label %for.body + +for.end: + ret void +} diff --git a/test/Transforms/LoopVectorize/vect.stats.ll b/test/Transforms/LoopVectorize/vect.stats.ll index 92ec24f726ee..9adf2bb6cf14 100644 --- a/test/Transforms/LoopVectorize/vect.stats.ll +++ b/test/Transforms/LoopVectorize/vect.stats.ll @@ -13,53 +13,47 @@ target triple = "x86_64-unknown-linux-gnu" define void @vectorized(float* nocapture %a, i64 %size) { entry: - %cmp1 = icmp sgt i64 %size, 0 - br i1 %cmp1, label %for.header, label %for.end + %cmp1 = icmp sle i64 %size, 0 + %cmp21 = icmp sgt i64 0, %size + %or.cond = or i1 %cmp1, %cmp21 + br i1 %or.cond, label %for.end, label %for.body -for.header: - %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] - %cmp2 = icmp sgt i64 %indvars.iv, %size - br i1 %cmp2, label %for.end, label %for.body - -for.body: - - %arrayidx = getelementptr inbounds float* %a, i64 %indvars.iv +for.body: ; preds = %entry, %for.body + %indvars.iv2 = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] + %arrayidx = getelementptr inbounds float* %a, i64 %indvars.iv2 %0 = load float* %arrayidx, align 4 %mul = fmul float %0, %0 store float %mul, float* %arrayidx, align 4 + %indvars.iv.next = add nuw nsw i64 %indvars.iv2, 1 + %cmp2 = icmp sgt i64 %indvars.iv.next, %size + br i1 %cmp2, label %for.end, label %for.body - %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 - br label %for.header - -for.end: +for.end: ; preds = %entry, %for.body ret void } define void @not_vectorized(float* nocapture %a, i64 %size) { entry: - %cmp1 = icmp sgt i64 %size, 0 - br i1 %cmp1, label %for.header, label %for.end + %cmp1 = icmp sle i64 %size, 0 + %cmp21 = icmp sgt i64 0, %size + %or.cond = or i1 %cmp1, %cmp21 + br i1 %or.cond, label %for.end, label %for.body -for.header: - %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] - %cmp2 = icmp sgt i64 %indvars.iv, %size - br i1 %cmp2, label %for.end, label %for.body - -for.body: - - %0 = add nsw i64 %indvars.iv, -5 +for.body: ; preds = %entry, %for.body + %indvars.iv2 = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] + %0 = add nsw i64 %indvars.iv2, -5 %arrayidx = getelementptr inbounds float* %a, i64 %0 %1 = load float* %arrayidx, align 4 - %2 = add nsw i64 %indvars.iv, 2 + %2 = add nsw i64 %indvars.iv2, 2 %arrayidx2 = getelementptr inbounds float* %a, i64 %2 %3 = load float* %arrayidx2, align 4 %mul = fmul float %1, %3 - %arrayidx4 = getelementptr inbounds float* %a, i64 %indvars.iv + %arrayidx4 = getelementptr inbounds float* %a, i64 %indvars.iv2 store float %mul, float* %arrayidx4, align 4 + %indvars.iv.next = add nuw nsw i64 %indvars.iv2, 1 + %cmp2 = icmp sgt i64 %indvars.iv.next, %size + br i1 %cmp2, label %for.end, label %for.body - %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 - br label %for.header - -for.end: +for.end: ; preds = %entry, %for.body ret void }
\ No newline at end of file diff --git a/test/Transforms/SROA/phi-and-select.ll b/test/Transforms/SROA/phi-and-select.ll index 8d82964dcbd1..946bc40b0587 100644 --- a/test/Transforms/SROA/phi-and-select.ll +++ b/test/Transforms/SROA/phi-and-select.ll @@ -501,3 +501,37 @@ end: ; CHECK-NOT: load ; CHECK: ret float %[[phi]] } + +%struct.S = type { i32 } + +; Verifies we fixed PR20822. We have a foldable PHI feeding a speculatable PHI +; which requires the rewriting of the speculated PHI to handle insertion +; when the incoming pointer is itself from a PHI node. We would previously +; insert a bitcast instruction *before* a PHI, producing an invalid module; +; make sure we insert *after* the first non-PHI instruction. +define void @PR20822() { +; CHECK-LABEL: @PR20822( +entry: + %f = alloca %struct.S, align 4 +; CHECK: %[[alloca:.*]] = alloca +; CHECK: %[[cast:.*]] = bitcast i32* %[[alloca]] to %struct.S* + br i1 undef, label %if.end, label %for.cond + +for.cond: ; preds = %for.cond, %entry + br label %if.end + +if.end: ; preds = %for.cond, %entry + %f2 = phi %struct.S* [ %f, %entry ], [ %f, %for.cond ] +; CHECK: phi {{.*}} %[[cast]] +; CHECK: phi i32 + phi i32 [ undef, %entry ], [ undef, %for.cond ] + br i1 undef, label %if.then5, label %if.then2 + +if.then2: ; preds = %if.end + br label %if.then5 + +if.then5: ; preds = %if.then2, %if.end + %f1 = phi %struct.S* [ undef, %if.then2 ], [ %f2, %if.end ] + store %struct.S undef, %struct.S* %f1, align 4 + ret void +} |
