diff options
author | Abdoulaye Walsimou Gaye <awg@embtoolkit.org> | 2013-06-12 21:27:20 +0200 |
---|---|---|
committer | Abdoulaye Walsimou Gaye <awg@embtoolkit.org> | 2013-06-12 21:27:20 +0200 |
commit | 46ef71a74329a0777e3464c65927cd3e59c928d6 (patch) | |
tree | e8c06aeb70dcbe18acdf6db1f88a1452ac1dca68 /test/Transforms | |
parent | 32c493313c30abe0830e95dc92c7ad1c2241ba57 (diff) | |
parent | ce337502f5a88500df9ab2f59ab48f97be0b4395 (diff) | |
download | llvm-46ef71a74329a0777e3464c65927cd3e59c928d6.tar.gz llvm-46ef71a74329a0777e3464c65927cd3e59c928d6.tar.bz2 llvm-46ef71a74329a0777e3464c65927cd3e59c928d6.tar.xz |
Merge branch 'release_33' of git://github.com/llvm-mirror/llvm into embtk-support-release-3.3
Diffstat (limited to 'test/Transforms')
-rw-r--r-- | test/Transforms/LoopUnroll/scevunroll.ll | 50 | ||||
-rw-r--r-- | test/Transforms/LoopUnroll/unloop.ll | 34 | ||||
-rw-r--r-- | test/Transforms/LoopVectorize/lcssa-crash.ll | 11 | ||||
-rw-r--r-- | test/Transforms/LoopVectorize/no_outside_user.ll | 41 | ||||
-rw-r--r-- | test/Transforms/LoopVectorize/value-ptr-bug.ll | 50 |
5 files changed, 164 insertions, 22 deletions
diff --git a/test/Transforms/LoopUnroll/scevunroll.ll b/test/Transforms/LoopUnroll/scevunroll.ll index 99b3a7d861..308a036316 100644 --- a/test/Transforms/LoopUnroll/scevunroll.ll +++ b/test/Transforms/LoopUnroll/scevunroll.ll @@ -66,13 +66,16 @@ exit2: ; SCEV properly unrolls multi-exit loops. ; +; SCEV cannot currently unroll this loop. +; It should ideally detect a trip count of 5. +; rdar:14038809 [SCEV]: Optimize trip count computation for multi-exit loops. ; CHECK: @multiExit -; CHECK: getelementptr i32* %base, i32 10 -; CHECK-NEXT: load i32* -; CHECK: br i1 false, label %l2.10, label %exit1 -; CHECK: l2.10: -; CHECK-NOT: br -; CHECK: ret i32 +; CHECKFIXME: getelementptr i32* %base, i32 10 +; CHECKFIXME-NEXT: load i32* +; CHECKFIXME: br i1 false, label %l2.10, label %exit1 +; CHECKFIXME: l2.10: +; CHECKFIXME-NOT: br +; CHECKFIXME: ret i32 define i32 @multiExit(i32* %base) nounwind { entry: br label %l1 @@ -170,3 +173,38 @@ for.body87: br label %for.body87 } +; PR16130: clang produces incorrect code with loop/expression at -O2 +; rdar:14036816 loop-unroll makes assumptions about undefined behavior +; +; The loop latch is assumed to exit after the first iteration because +; of the induction variable's NSW flag. However, the loop latch's +; equality test is skipped and the loop exits after the second +; iteration via the early exit. So loop unrolling cannot assume that +; the loop latch's exit count of zero is an upper bound on the number +; of iterations. +; +; CHECK: @nsw_latch +; CHECK: for.body: +; CHECK: %b.03 = phi i32 [ 0, %entry ], [ %add, %for.cond ] +; CHECK: return: +; CHECK: %b.03.lcssa = phi i32 [ %b.03, %for.body ], [ %b.03, %for.cond ] +define void @nsw_latch(i32* %a) nounwind { +entry: + br label %for.body + +for.body: ; preds = %for.cond, %entry + %b.03 = phi i32 [ 0, %entry ], [ %add, %for.cond ] + %tobool = icmp eq i32 %b.03, 0 + %add = add nsw i32 %b.03, 8 + br i1 %tobool, label %for.cond, label %return + +for.cond: ; preds = %for.body + %cmp = icmp eq i32 %add, 13 + br i1 %cmp, label %return, label %for.body + +return: ; preds = %for.body, %for.cond + %b.03.lcssa = phi i32 [ %b.03, %for.body ], [ %b.03, %for.cond ] + %retval.0 = phi i32 [ 1, %for.body ], [ 0, %for.cond ] + store i32 %b.03.lcssa, i32* %a, align 4 + ret void +} diff --git a/test/Transforms/LoopUnroll/unloop.ll b/test/Transforms/LoopUnroll/unloop.ll index 5a9cacda44..9a938cc287 100644 --- a/test/Transforms/LoopUnroll/unloop.ll +++ b/test/Transforms/LoopUnroll/unloop.ll @@ -21,8 +21,8 @@ outer: inner: %iv = phi i32 [ 0, %outer ], [ %inc, %tail ] %inc = add i32 %iv, 1 - %wbucond = call zeroext i1 @check() - br i1 %wbucond, label %outer.backedge, label %tail + call zeroext i1 @check() + br i1 true, label %outer.backedge, label %tail tail: br i1 false, label %inner, label %exit @@ -126,25 +126,27 @@ return: ; Ensure that only the middle loop is removed and rely on verify-loopinfo to ; check soundness. ; -; CHECK: @unloopDeepNested +; This test must be disabled until trip count computation can be optimized... +; rdar:14038809 [SCEV]: Optimize trip count computation for multi-exit loops. +; CHECKFIXME: @unloopDeepNested ; Inner-inner loop control. -; CHECK: while.cond.us.i: -; CHECK: br i1 %cmp.us.i, label %next_data.exit, label %while.body.us.i -; CHECK: if.then.us.i: -; CHECK: br label %while.cond.us.i +; CHECKFIXME: while.cond.us.i: +; CHECKFIXME: br i1 %cmp.us.i, label %next_data.exit, label %while.body.us.i +; CHECKFIXME: if.then.us.i: +; CHECKFIXME: br label %while.cond.us.i ; Inner loop tail. -; CHECK: if.else.i: -; CHECK: br label %while.cond.outer.i +; CHECKFIXME: if.else.i: +; CHECKFIXME: br label %while.cond.outer.i ; Middle loop control (removed). -; CHECK: valid_data.exit: -; CHECK-NOT: br -; CHECK: %cmp = call zeroext i1 @check() +; CHECKFIXME: valid_data.exit: +; CHECKFIXME-NOT: br +; CHECKFIXME: %cmp = call zeroext i1 @check() ; Outer loop control. -; CHECK: copy_data.exit: -; CHECK: br i1 %cmp38, label %if.then39, label %while.cond.outer +; CHECKFIXME: copy_data.exit: +; CHECKFIXME: br i1 %cmp38, label %if.then39, label %while.cond.outer ; Outer-outer loop tail. -; CHECK: while.cond.outer.outer.backedge: -; CHECK: br label %while.cond.outer.outer +; CHECKFIXME: while.cond.outer.outer.backedge: +; CHECKFIXME: br label %while.cond.outer.outer define void @unloopDeepNested() nounwind { for.cond8.preheader.i: %cmp113.i = call zeroext i1 @check() diff --git a/test/Transforms/LoopVectorize/lcssa-crash.ll b/test/Transforms/LoopVectorize/lcssa-crash.ll index 06b3b08aa0..de6be54849 100644 --- a/test/Transforms/LoopVectorize/lcssa-crash.ll +++ b/test/Transforms/LoopVectorize/lcssa-crash.ll @@ -27,3 +27,14 @@ for.end.i.i.i: unreachable } +; PR16139 +define void @test2(i8* %x) { +entry: + indirectbr i8* %x, [ label %L0, label %L1 ] + +L0: + br label %L0 + +L1: + ret void +} diff --git a/test/Transforms/LoopVectorize/no_outside_user.ll b/test/Transforms/LoopVectorize/no_outside_user.ll new file mode 100644 index 0000000000..6f0357c5e5 --- /dev/null +++ b/test/Transforms/LoopVectorize/no_outside_user.ll @@ -0,0 +1,41 @@ +; RUN: opt -S -loop-vectorize -force-vector-unroll=1 -force-vector-width=2 < %s | FileCheck %s + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128" + +@f = common global i32 0, align 4 +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 +@c = common global i32 0, align 4 +@a = common global i32 0, align 4 +@b = common global i32 0, align 4 +@e = common global i32 0, align 4 + +; We used to vectorize this loop. But it has a value that is used outside of the +; and is not a recognized reduction variable "tmp17". + +; CHECK-NOT: <2 x i32> + +define i32 @main() { +bb: + %b.promoted = load i32* @b, align 4 + br label %.lr.ph.i + +.lr.ph.i: + %tmp8 = phi i32 [ %tmp18, %bb16 ], [ %b.promoted, %bb ] + %tmp2 = icmp sgt i32 %tmp8, 10 + br i1 %tmp2, label %bb16, label %bb10 + +bb10: + br label %bb16 + +bb16: + %tmp17 = phi i32 [ 0, %bb10 ], [ 1, %.lr.ph.i ] + %tmp18 = add nsw i32 %tmp8, 1 + %tmp19 = icmp slt i32 %tmp18, 4 + br i1 %tmp19, label %.lr.ph.i, label %f1.exit.loopexit + +f1.exit.loopexit: + %.lcssa = phi i32 [ %tmp17, %bb16 ] + ret i32 %.lcssa +} + + diff --git a/test/Transforms/LoopVectorize/value-ptr-bug.ll b/test/Transforms/LoopVectorize/value-ptr-bug.ll new file mode 100644 index 0000000000..f376656f07 --- /dev/null +++ b/test/Transforms/LoopVectorize/value-ptr-bug.ll @@ -0,0 +1,50 @@ +; RUN: opt -S -loop-vectorize -force-vector-width=4 -force-vector-unroll=1 -dce -instcombine < %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" + +; PR16073 + +; Because we were caching value pointers accross a function call that could RAUW +; we would generate an undefined value store below: +; SCEVExpander::expandCodeFor would change a value (the start value of an +; induction) that we cached in the induction variable list. + +; CHECK: test_vh +; CHECK-NOT: store <4 x i8> undef + +define void @test_vh(i32* %ptr265, i32* %ptr266, i32 %sub267) { +entry: + br label %loop + +loop: + %inc = phi i32 [ %sub267, %entry ], [ %add, %loop] + %ext.inc = sext i32 %inc to i64 + %add.ptr265 = getelementptr inbounds i32* %ptr265, i64 %ext.inc + %add.ptr266 = getelementptr inbounds i32* %ptr266, i64 %ext.inc + %add = add i32 %inc, 9 + %cmp = icmp slt i32 %add, 140 + br i1 %cmp, label %block1, label %loop + +block1: + %sub267.lcssa = phi i32 [ %add, %loop ] + %add.ptr266.lcssa = phi i32* [ %add.ptr266, %loop ] + %add.ptr265.lcssa = phi i32* [ %add.ptr265, %loop ] + %tmp29 = bitcast i32* %add.ptr265.lcssa to i8* + %tmp30 = bitcast i32* %add.ptr266.lcssa to i8* + br label %do.body272 + +do.body272: + %row_width.5 = phi i32 [ %sub267.lcssa, %block1 ], [ %dec, %do.body272 ] + %sp.4 = phi i8* [ %tmp30, %block1 ], [ %incdec.ptr273, %do.body272 ] + %dp.addr.4 = phi i8* [ %tmp29, %block1 ], [ %incdec.ptr274, %do.body272 ] + %incdec.ptr273 = getelementptr inbounds i8* %sp.4, i64 1 + %tmp31 = load i8* %sp.4, align 1 + %incdec.ptr274 = getelementptr inbounds i8* %dp.addr.4, i64 1 + store i8 %tmp31, i8* %dp.addr.4, align 1 + %dec = add i32 %row_width.5, -1 + %cmp276 = icmp eq i32 %dec, 0 + br i1 %cmp276, label %loop.exit, label %do.body272 + +loop.exit: + ret void +} |