summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/fast-math-scalarization.ll
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2016-03-01 19:35:52 +0000
committerOwen Anderson <resistor@mac.com>2016-03-01 19:35:52 +0000
commit7ea02fc7879ccfa9aba47c0dec7d57e8fbeb3b9e (patch)
treeb70ac649bf2480bdf65e8c49174eed1bd09fae7c /llvm/test/Transforms/InstCombine/fast-math-scalarization.ll
parentb3a7935d549c1d73729a4666ec6133e80658ce34 (diff)
downloadbcm5719-llvm-7ea02fc7879ccfa9aba47c0dec7d57e8fbeb3b9e.tar.gz
bcm5719-llvm-7ea02fc7879ccfa9aba47c0dec7d57e8fbeb3b9e.zip
Fix an issue where fast math flags were dropped during scalarization.
Most portions of InstCombine properly propagate fast math flags, but apparently the vector scalarization section was overlooked. llvm-svn: 262376
Diffstat (limited to 'llvm/test/Transforms/InstCombine/fast-math-scalarization.ll')
-rw-r--r--llvm/test/Transforms/InstCombine/fast-math-scalarization.ll39
1 files changed, 39 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/fast-math-scalarization.ll b/llvm/test/Transforms/InstCombine/fast-math-scalarization.ll
new file mode 100644
index 00000000000..406ebebfdd2
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/fast-math-scalarization.ll
@@ -0,0 +1,39 @@
+; RUN: opt -instcombine -S < %s | FileCheck %s
+
+; CHECK-LABEL: test_scalarize_phi
+; CHECK: fmul fast float
+define void @test_scalarize_phi(i32 * %n, float * %inout) {
+entry:
+ %0 = load volatile float, float * %inout, align 4
+ %splat.splatinsert = insertelement <4 x float> undef, float %0, i32 0
+ %splat.splat = shufflevector <4 x float> %splat.splatinsert, <4 x float> undef, <4 x i32> zeroinitializer
+ %splat.splatinsert1 = insertelement <4 x float> undef, float 3.0, i32 0
+ br label %for.cond
+
+for.cond:
+ %x.0 = phi <4 x float> [ %splat.splat, %entry ], [ %mul, %for.body ]
+ %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+ %1 = load i32, i32 * %n, align 4
+ %cmp = icmp ne i32 %i.0, %1
+ br i1 %cmp, label %for.body, label %for.end
+
+for.body:
+ %2 = extractelement <4 x float> %x.0, i32 1
+ store volatile float %2, float * %inout, align 4
+ %mul = fmul fast <4 x float> %x.0, <float 0x4002A3D700000000, float 0x4002A3D700000000, float 0x4002A3D700000000, float 0x4002A3D700000000>
+ %inc = add nsw i32 %i.0, 1
+ br label %for.cond
+
+for.end:
+ ret void
+}
+
+; CHECK-LABEL: test_extract_element_fastmath
+; CHECK: fadd fast float
+define float @test_extract_element_fastmath(<4 x float> %x) #0 {
+entry:
+ %add = fadd fast <4 x float> %x, <float 0x4002A3D700000000, float 0x4002A3D700000000, float 0x4002A3D700000000, float 0x4002A3D700000000>
+ %0 = extractelement <4 x float> %add, i32 2
+ ret float %0
+}
+
OpenPOWER on IntegriCloud