From 9eed0bee3dcda9978ffad6df3e4af1db7d3ffab0 Mon Sep 17 00:00:00 2001 From: Matthew Simpson Date: Wed, 26 Apr 2017 16:23:02 +0000 Subject: [LV] Handle external uses of floating-point induction variables Reference: https://bugs.llvm.org/show_bug.cgi?id=32758 Differential Revision: https://reviews.llvm.org/D32445 llvm-svn: 301428 --- .../LoopVectorize/X86/float-induction-x86.ll | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'llvm/test/Transforms/LoopVectorize/X86/float-induction-x86.ll') diff --git a/llvm/test/Transforms/LoopVectorize/X86/float-induction-x86.ll b/llvm/test/Transforms/LoopVectorize/X86/float-induction-x86.ll index 08ac64e52d4..b5e914500fb 100644 --- a/llvm/test/Transforms/LoopVectorize/X86/float-induction-x86.ll +++ b/llvm/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" } -- cgit v1.2.3