diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-29 16:25:25 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-29 16:25:25 +0000 |
| commit | ab44ce3d598882e51a25eb82eb7ae6308de85ae6 (patch) | |
| tree | 568d786a59d49bef961dcb9bd09d422701b9da5b /test/Transforms/LoopStrengthReduce | |
| parent | b5630dbadf9a2a06754194387d6b0fd9962a67f1 (diff) | |
Notes
Diffstat (limited to 'test/Transforms/LoopStrengthReduce')
| -rw-r--r-- | test/Transforms/LoopStrengthReduce/X86/incorrect-offset-scaling.ll | 12 | ||||
| -rw-r--r-- | test/Transforms/LoopStrengthReduce/X86/lsr-expand-quadratic.ll (renamed from test/Transforms/LoopStrengthReduce/lsr-expand-quadratic.ll) | 26 | ||||
| -rw-r--r-- | test/Transforms/LoopStrengthReduce/nonintegral.ll | 45 | ||||
| -rw-r--r-- | test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll | 4 |
4 files changed, 73 insertions, 14 deletions
diff --git a/test/Transforms/LoopStrengthReduce/X86/incorrect-offset-scaling.ll b/test/Transforms/LoopStrengthReduce/X86/incorrect-offset-scaling.ll index 3adb8bcf514d..00c3222b0051 100644 --- a/test/Transforms/LoopStrengthReduce/X86/incorrect-offset-scaling.ll +++ b/test/Transforms/LoopStrengthReduce/X86/incorrect-offset-scaling.ll @@ -25,7 +25,7 @@ L2: ; preds = %idxend.8 if6: ; preds = %idxend.8 %r2 = add i64 %0, -1 %r3 = load i64, i64* %1, align 8 -; CHECK-NOT: %r2 +; CHECK: %r2 = add i64 %0, -1 ; CHECK: %r3 = load i64 br label %ib @@ -36,13 +36,11 @@ ib: ; preds = %if6 %r4 = mul i64 %r3, %r0 %r5 = add i64 %r2, %r4 %r6 = icmp ult i64 %r5, undef -; CHECK: [[MUL1:%[0-9]+]] = mul i64 %lsr.iv, %r3 -; CHECK: [[ADD1:%[0-9]+]] = add i64 [[MUL1]], -1 -; CHECK: add i64 %{{.}}, [[ADD1]] -; CHECK: %r6 +; CHECK: %r4 = mul i64 %r3, %lsr.iv +; CHECK: %r5 = add i64 %r2, %r4 +; CHECK: %r6 = icmp ult i64 %r5, undef +; CHECK: %r7 = getelementptr i64, i64* undef, i64 %r5 %r7 = getelementptr i64, i64* undef, i64 %r5 store i64 1, i64* %r7, align 8 -; CHECK: [[MUL2:%[0-9]+]] = mul i64 %lsr.iv, %r3 -; CHECK: [[ADD2:%[0-9]+]] = add i64 [[MUL2]], -1 br label %L } diff --git a/test/Transforms/LoopStrengthReduce/lsr-expand-quadratic.ll b/test/Transforms/LoopStrengthReduce/X86/lsr-expand-quadratic.ll index aa688d999e60..a7731bfcec56 100644 --- a/test/Transforms/LoopStrengthReduce/lsr-expand-quadratic.ll +++ b/test/Transforms/LoopStrengthReduce/X86/lsr-expand-quadratic.ll @@ -1,5 +1,14 @@ +; REQUIRES: x86 ; RUN: opt -loop-reduce -S < %s | FileCheck %s +; Strength reduction analysis here relies on IV Users analysis, that +; only finds users among instructions with types that are treated as +; legal by the data layout. When running this test on pure non-x86 +; configs (for example, ARM 64), it gets confused with the target +; triple and uses a default data layout instead. This default layout +; does not have any legal types (even i32), so the transformation +; does not happen. + 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" target triple = "x86_64-apple-macosx" @@ -7,16 +16,23 @@ target triple = "x86_64-apple-macosx" ; ; SCEV expander cannot expand quadratic recurrences outside of the ; loop. This recurrence depends on %sub.us, so can't be expanded. +; We cannot fold SCEVUnknown (sub.us) with recurrences since it is +; declared after the loop. ; ; CHECK-LABEL: @test2 ; CHECK-LABEL: test2.loop: -; CHECK: %lsr.iv = phi i32 [ %lsr.iv.next, %test2.loop ], [ -16777216, %entry ] -; CHECK: %lsr.iv.next = add nsw i32 %lsr.iv, 16777216 +; CHECK: %lsr.iv1 = phi i32 [ %lsr.iv.next2, %test2.loop ], [ -16777216, %entry ] +; CHECK: %lsr.iv = phi i32 [ %lsr.iv.next, %test2.loop ], [ -1, %entry ] +; CHECK: %lsr.iv.next = add nsw i32 %lsr.iv, 1 +; CHECK: %lsr.iv.next2 = add nsw i32 %lsr.iv1, 16777216 ; ; CHECK-LABEL: for.end: -; CHECK: %sub.cond.us = sub nsw i32 %inc1115.us, %sub.us -; CHECK: %sext.us = mul i32 %lsr.iv.next, %sub.cond.us -; CHECK: %f = ashr i32 %sext.us, 24 +; CHECK: %tobool.us = icmp eq i32 %lsr.iv.next2, 0 +; CHECK: %sub.us = select i1 %tobool.us, i32 0, i32 0 +; CHECK: %1 = sub i32 0, %sub.us +; CHECK: %2 = add i32 %1, %lsr.iv.next +; CHECK: %sext.us = mul i32 %lsr.iv.next2, %2 +; CHECK: %f = ashr i32 %sext.us, 24 ; CHECK: ret i32 %f define i32 @test2() { entry: diff --git a/test/Transforms/LoopStrengthReduce/nonintegral.ll b/test/Transforms/LoopStrengthReduce/nonintegral.ll new file mode 100644 index 000000000000..5648e3aa74af --- /dev/null +++ b/test/Transforms/LoopStrengthReduce/nonintegral.ll @@ -0,0 +1,45 @@ +; RUN: opt -S -loop-reduce < %s | FileCheck %s + +; Address Space 10 is non-integral. The optimizer is not allowed to use +; ptrtoint/inttoptr instructions. Make sure that this doesn't happen +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:10:11:12" +target triple = "x86_64-unknown-linux-gnu" + +define void @japi1__unsafe_getindex_65028(i64 addrspace(10)* %arg) { +; CHECK-NOT: inttoptr +; CHECK-NOT: ptrtoint +; How exactly SCEV chooses to materialize isn't all that important, as +; long as it doesn't try to round-trip through integers. As of this writing, +; it emits a byte-wise gep, which is fine. +; CHECK: getelementptr i64, i64 addrspace(10)* {{.*}}, i64 {{.*}} +top: + br label %L86 + +L86: ; preds = %L86, %top + %i.0 = phi i64 [ 0, %top ], [ %tmp, %L86 ] + %tmp = add i64 %i.0, 1 + br i1 undef, label %L86, label %if29 + +if29: ; preds = %L86 + %tmp1 = shl i64 %tmp, 1 + %tmp2 = add i64 %tmp1, -2 + br label %if31 + +if31: ; preds = %if38, %if29 + %"#temp#1.sroa.0.022" = phi i64 [ 0, %if29 ], [ %tmp3, %if38 ] + br label %L119 + +L119: ; preds = %L119, %if31 + %i5.0 = phi i64 [ %"#temp#1.sroa.0.022", %if31 ], [ %tmp3, %L119 ] + %tmp3 = add i64 %i5.0, 1 + br i1 undef, label %L119, label %if38 + +if38: ; preds = %L119 + %tmp4 = add i64 %tmp2, %i5.0 + %tmp5 = getelementptr i64, i64 addrspace(10)* %arg, i64 %tmp4 + %tmp6 = load i64, i64 addrspace(10)* %tmp5 + br i1 undef, label %done, label %if31 + +done: ; preds = %if38 + ret void +} diff --git a/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll b/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll index fbf55fd81d23..cbf177c0d4b9 100644 --- a/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll +++ b/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll @@ -25,6 +25,8 @@ define void @_Z15IntegerToStringjjR7Vector2(i32 %i, i32 %radix, %struct.Vector2* entry: %buffer = alloca [33 x i16], align 16 %add.ptr = getelementptr inbounds [33 x i16], [33 x i16]* %buffer, i64 0, i64 33 + %sub.ptr.lhs.cast = ptrtoint i16* %add.ptr to i64 + %sub.ptr.rhs.cast = ptrtoint i16* %add.ptr to i64 br label %do.body do.body: ; preds = %do.body, %entry @@ -46,8 +48,6 @@ do.body: ; preds = %do.body, %entry do.end: ; preds = %do.body %xap.0 = inttoptr i64 %0 to i1* %cap.0 = ptrtoint i1* %xap.0 to i64 - %sub.ptr.lhs.cast = ptrtoint i16* %add.ptr to i64 - %sub.ptr.rhs.cast = ptrtoint i16* %incdec.ptr to i64 %sub.ptr.sub = sub i64 %sub.ptr.lhs.cast, %sub.ptr.rhs.cast %sub.ptr.div39 = lshr exact i64 %sub.ptr.sub, 1 %conv11 = trunc i64 %sub.ptr.div39 to i32 |
