diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-26 19:45:00 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-26 19:45:00 +0000 |
commit | 12f3ca4cdb95b193af905a00e722a4dcb40b3de3 (patch) | |
tree | ae1a7fcfc24a8d4b23206c57121c3f361d4b7f84 /test/Transforms/LoopVectorize | |
parent | d99dafe2e4a385dd2a6c76da6d8258deb100657b (diff) |
Diffstat (limited to 'test/Transforms/LoopVectorize')
-rw-r--r-- | test/Transforms/LoopVectorize/X86/float-induction-x86.ll | 63 | ||||
-rw-r--r-- | test/Transforms/LoopVectorize/induction.ll | 24 | ||||
-rw-r--r-- | test/Transforms/LoopVectorize/phi-cost.ll | 86 |
3 files changed, 161 insertions, 12 deletions
diff --git a/test/Transforms/LoopVectorize/X86/float-induction-x86.ll b/test/Transforms/LoopVectorize/X86/float-induction-x86.ll index 08ac64e52d4fe..b5e914500fb4a 100644 --- a/test/Transforms/LoopVectorize/X86/float-induction-x86.ll +++ b/test/Transforms/LoopVectorize/X86/float-induction-x86.ll @@ -82,5 +82,68 @@ for.end: ; preds = %for.end.loopexit, % ret void } +; AUTO_VEC-LABEL: @external_use_with_fast_math( +; AUTO_VEC-NEXT: entry: +; AUTO_VEC-NEXT: [[TMP0:%.*]] = icmp sgt i64 %n, 1 +; AUTO_VEC-NEXT: [[SMAX:%.*]] = select i1 [[TMP0]], i64 %n, i64 1 +; AUTO_VEC: br i1 {{.*}}, label %for.body, label %min.iters.checked +; AUTO_VEC: min.iters.checked: +; AUTO_VEC-NEXT: [[N_VEC:%.*]] = and i64 [[SMAX]], 9223372036854775792 +; AUTO_VEC: br i1 {{.*}}, label %for.body, label %vector.body +; AUTO_VEC: middle.block: +; AUTO_VEC: [[TMP11:%.*]] = add nsw i64 [[N_VEC]], -1 +; AUTO_VEC-NEXT: [[CAST_CMO:%.*]] = sitofp i64 [[TMP11]] to double +; AUTO_VEC-NEXT: [[TMP12:%.*]] = fmul fast double [[CAST_CMO]], 3.000000e+00 +; AUTO_VEC-NEXT: br i1 {{.*}}, label %for.end, label %for.body +; AUTO_VEC: for.end: +; AUTO_VEC-NEXT: [[J_LCSSA:%.*]] = phi double [ [[TMP12]], %middle.block ], [ %j, %for.body ] +; AUTO_VEC-NEXT: ret double [[J_LCSSA]] +; +define double @external_use_with_fast_math(double* %a, i64 %n) { +entry: + br label %for.body + +for.body: + %i = phi i64 [ 0, %entry ], [%i.next, %for.body] + %j = phi double [ 0.0, %entry ], [ %j.next, %for.body ] + %tmp0 = getelementptr double, double* %a, i64 %i + store double %j, double* %tmp0 + %i.next = add i64 %i, 1 + %j.next = fadd fast double %j, 3.0 + %cond = icmp slt i64 %i.next, %n + br i1 %cond, label %for.body, label %for.end + +for.end: + %tmp1 = phi double [ %j, %for.body ] + ret double %tmp1 +} + +; AUTO_VEC-LABEL: @external_use_without_fast_math( +; AUTO_VEC: for.body: +; AUTO_VEC: [[J:%.*]] = phi double [ 0.000000e+00, %entry ], [ [[J_NEXT:%.*]], %for.body ] +; AUTO_VEC: [[J_NEXT]] = fadd double [[J]], 3.000000e+00 +; AUTO_VEC: br i1 {{.*}}, label %for.body, label %for.end +; AUTO_VEC: for.end: +; AUTO_VEC-NEXT: ret double [[J]] +; +define double @external_use_without_fast_math(double* %a, i64 %n) { +entry: + br label %for.body + +for.body: + %i = phi i64 [ 0, %entry ], [%i.next, %for.body] + %j = phi double [ 0.0, %entry ], [ %j.next, %for.body ] + %tmp0 = getelementptr double, double* %a, i64 %i + store double %j, double* %tmp0 + %i.next = add i64 %i, 1 + %j.next = fadd double %j, 3.0 + %cond = icmp slt i64 %i.next, %n + br i1 %cond, label %for.body, label %for.end + +for.end: + %tmp1 = phi double [ %j, %for.body ] + ret double %tmp1 +} + attributes #0 = { "no-nans-fp-math"="true" } attributes #1 = { "no-nans-fp-math"="false" } diff --git a/test/Transforms/LoopVectorize/induction.ll b/test/Transforms/LoopVectorize/induction.ll index 0d7d9fe0c1b8a..6507166dd1f25 100644 --- a/test/Transforms/LoopVectorize/induction.ll +++ b/test/Transforms/LoopVectorize/induction.ll @@ -309,59 +309,59 @@ for.end: ; ; CHECK-LABEL: @scalarize_induction_variable_05( ; CHECK: vector.body: -; CHECK: %index = phi i32 [ 0, %vector.ph ], [ %index.next, %pred.udiv.continue2 ] +; CHECK: %index = phi i32 [ 0, %vector.ph ], [ %index.next, %pred.udiv.continue{{[0-9]+}} ] ; CHECK: %[[I0:.+]] = add i32 %index, 0 ; CHECK: getelementptr inbounds i32, i32* %a, i32 %[[I0]] ; CHECK: pred.udiv.if: ; CHECK: udiv i32 {{.*}}, %[[I0]] -; CHECK: pred.udiv.if1: +; CHECK: pred.udiv.if{{[0-9]+}}: ; CHECK: %[[I1:.+]] = add i32 %index, 1 ; CHECK: udiv i32 {{.*}}, %[[I1]] ; ; UNROLL-NO_IC-LABEL: @scalarize_induction_variable_05( ; UNROLL-NO-IC: vector.body: -; UNROLL-NO-IC: %index = phi i32 [ 0, %vector.ph ], [ %index.next, %pred.udiv.continue11 ] +; UNROLL-NO-IC: %index = phi i32 [ 0, %vector.ph ], [ %index.next, %pred.udiv.continue{{[0-9]+}} ] ; UNROLL-NO-IC: %[[I0:.+]] = add i32 %index, 0 ; UNROLL-NO-IC: %[[I2:.+]] = add i32 %index, 2 ; UNROLL-NO-IC: getelementptr inbounds i32, i32* %a, i32 %[[I0]] ; UNROLL-NO-IC: getelementptr inbounds i32, i32* %a, i32 %[[I2]] ; UNROLL-NO-IC: pred.udiv.if: ; UNROLL-NO-IC: udiv i32 {{.*}}, %[[I0]] -; UNROLL-NO-IC: pred.udiv.if6: +; UNROLL-NO-IC: pred.udiv.if{{[0-9]+}}: ; UNROLL-NO-IC: %[[I1:.+]] = add i32 %index, 1 ; UNROLL-NO-IC: udiv i32 {{.*}}, %[[I1]] -; UNROLL-NO-IC: pred.udiv.if8: +; UNROLL-NO-IC: pred.udiv.if{{[0-9]+}}: ; UNROLL-NO-IC: udiv i32 {{.*}}, %[[I2]] -; UNROLL-NO-IC: pred.udiv.if10: +; UNROLL-NO-IC: pred.udiv.if{{[0-9]+}}: ; UNROLL-NO-IC: %[[I3:.+]] = add i32 %index, 3 ; UNROLL-NO-IC: udiv i32 {{.*}}, %[[I3]] ; ; IND-LABEL: @scalarize_induction_variable_05( ; IND: vector.body: -; IND: %index = phi i32 [ 0, %vector.ph ], [ %index.next, %pred.udiv.continue2 ] +; IND: %index = phi i32 [ 0, %vector.ph ], [ %index.next, %pred.udiv.continue{{[0-9]+}} ] ; IND: %[[E0:.+]] = sext i32 %index to i64 ; IND: getelementptr inbounds i32, i32* %a, i64 %[[E0]] ; IND: pred.udiv.if: ; IND: udiv i32 {{.*}}, %index -; IND: pred.udiv.if1: +; IND: pred.udiv.if{{[0-9]+}}: ; IND: %[[I1:.+]] = or i32 %index, 1 ; IND: udiv i32 {{.*}}, %[[I1]] ; ; UNROLL-LABEL: @scalarize_induction_variable_05( ; UNROLL: vector.body: -; UNROLL: %index = phi i32 [ 0, %vector.ph ], [ %index.next, %pred.udiv.continue11 ] +; UNROLL: %index = phi i32 [ 0, %vector.ph ], [ %index.next, %pred.udiv.continue{{[0-9]+}} ] ; UNROLL: %[[I2:.+]] = or i32 %index, 2 ; UNROLL: %[[E0:.+]] = sext i32 %index to i64 ; UNROLL: %[[G0:.+]] = getelementptr inbounds i32, i32* %a, i64 %[[E0]] ; UNROLL: getelementptr i32, i32* %[[G0]], i64 2 ; UNROLL: pred.udiv.if: ; UNROLL: udiv i32 {{.*}}, %index -; UNROLL: pred.udiv.if6: +; UNROLL: pred.udiv.if{{[0-9]+}}: ; UNROLL: %[[I1:.+]] = or i32 %index, 1 ; UNROLL: udiv i32 {{.*}}, %[[I1]] -; UNROLL: pred.udiv.if8: +; UNROLL: pred.udiv.if{{[0-9]+}}: ; UNROLL: udiv i32 {{.*}}, %[[I2]] -; UNROLL: pred.udiv.if10: +; UNROLL: pred.udiv.if{{[0-9]+}}: ; UNROLL: %[[I3:.+]] = or i32 %index, 3 ; UNROLL: udiv i32 {{.*}}, %[[I3]] diff --git a/test/Transforms/LoopVectorize/phi-cost.ll b/test/Transforms/LoopVectorize/phi-cost.ll new file mode 100644 index 0000000000000..5ccea66c76af4 --- /dev/null +++ b/test/Transforms/LoopVectorize/phi-cost.ll @@ -0,0 +1,86 @@ +; REQUIRES: asserts +; RUN: opt < %s -loop-vectorize -force-vector-width=2 -force-vector-interleave=1 -instcombine -debug-only=loop-vectorize -disable-output -print-after=instcombine 2>&1 | FileCheck %s + +target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128" + +; CHECK-LABEL: phi_two_incoming_values +; CHECK: LV: Found an estimated cost of 1 for VF 2 For instruction: %i = phi i64 [ %i.next, %if.end ], [ 0, %entry ] +; CHECK: LV: Found an estimated cost of 1 for VF 2 For instruction: %tmp5 = phi i32 [ %tmp1, %for.body ], [ %tmp4, %if.then ] +; CHECK: vector.body: +; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ] +; CHECK: [[WIDE_LOAD:%.*]] = load <2 x i32>, <2 x i32>* {{.*}} +; CHECK: [[TMP5:%.*]] = icmp sgt <2 x i32> [[WIDE_LOAD]], zeroinitializer +; CHECK-NEXT: [[TMP6:%.*]] = add <2 x i32> [[WIDE_LOAD]], <i32 1, i32 1> +; CHECK-NEXT: [[PREDPHI:%.*]] = select <2 x i1> [[TMP5]], <2 x i32> [[TMP6]], <2 x i32> [[WIDE_LOAD]] +; CHECK: store <2 x i32> [[PREDPHI]], <2 x i32>* {{.*}} +; CHECK-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], 2 +; +define void @phi_two_incoming_values(i32* %a, i32* %b, i64 %n) { +entry: + br label %for.body + +for.body: + %i = phi i64 [ %i.next, %if.end ], [ 0, %entry ] + %tmp0 = getelementptr inbounds i32, i32* %a, i64 %i + %tmp1 = load i32, i32* %tmp0, align 4 + %tmp2 = getelementptr inbounds i32, i32* %b, i64 %i + %tmp3 = icmp sgt i32 %tmp1, 0 + br i1 %tmp3, label %if.then, label %if.end + +if.then: + %tmp4 = add i32 %tmp1, 1 + br label %if.end + +if.end: + %tmp5 = phi i32 [ %tmp1, %for.body ], [ %tmp4, %if.then ] + store i32 %tmp5, i32* %tmp2, align 4 + %i.next = add i64 %i, 1 + %cond = icmp eq i64 %i, %n + br i1 %cond, label %for.end, label %for.body + +for.end: + ret void +} + +; CHECK-LABEL: phi_three_incoming_values +; CHECK: LV: Found an estimated cost of 1 for VF 2 For instruction: %i = phi i64 [ %i.next, %if.end ], [ 0, %entry ] +; CHECK: LV: Found an estimated cost of 2 for VF 2 For instruction: %tmp8 = phi i32 [ 9, %for.body ], [ 3, %if.then ], [ %tmp7, %if.else ] +; CHECK: vector.body: +; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ] +; CHECK: [[PREDPHI:%.*]] = select <2 x i1> {{.*}}, <2 x i32> <i32 3, i32 3>, <2 x i32> <i32 9, i32 9> +; CHECK: [[PREDPHI7:%.*]] = select <2 x i1> {{.*}}, <2 x i32> {{.*}}, <2 x i32> [[PREDPHI]] +; CHECK: store <2 x i32> [[PREDPHI7]], <2 x i32>* {{.*}} +; CHECK-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], 2 +; +define void @phi_three_incoming_values(i32* %a, i32* %b, i64 %n) { +entry: + br label %for.body + +for.body: + %i = phi i64 [ %i.next, %if.end ], [ 0, %entry ] + %tmp0 = getelementptr inbounds i32, i32* %a, i64 %i + %tmp1 = load i32, i32* %tmp0, align 4 + %tmp2 = getelementptr inbounds i32, i32* %b, i64 %i + %tmp3 = load i32, i32* %tmp2, align 4 + %tmp4 = icmp sgt i32 %tmp1, %tmp3 + br i1 %tmp4, label %if.then, label %if.end + +if.then: + %tmp5 = icmp sgt i32 %tmp1, 19 + br i1 %tmp5, label %if.end, label %if.else + +if.else: + %tmp6 = icmp slt i32 %tmp3, 4 + %tmp7 = select i1 %tmp6, i32 4, i32 5 + br label %if.end + +if.end: + %tmp8 = phi i32 [ 9, %for.body ], [ 3, %if.then ], [ %tmp7, %if.else ] + store i32 %tmp8, i32* %tmp0, align 4 + %i.next = add i64 %i, 1 + %cond = icmp eq i64 %i, %n + br i1 %cond, label %for.end, label %for.body + +for.end: + ret void +} |