xref: /aosp_15_r20/external/llvm/test/Transforms/InstCombine/fast-math-scalarization.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -instcombine -S < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_scalarize_phi
4*9880d681SAndroid Build Coastguard Worker; CHECK: fmul fast float
5*9880d681SAndroid Build Coastguard Workerdefine void @test_scalarize_phi(i32 * %n, float * %inout) {
6*9880d681SAndroid Build Coastguard Workerentry:
7*9880d681SAndroid Build Coastguard Worker  %0 = load volatile float, float * %inout, align 4
8*9880d681SAndroid Build Coastguard Worker  %splat.splatinsert = insertelement <4 x float> undef, float %0, i32 0
9*9880d681SAndroid Build Coastguard Worker  %splat.splat = shufflevector <4 x float> %splat.splatinsert, <4 x float> undef, <4 x i32> zeroinitializer
10*9880d681SAndroid Build Coastguard Worker  %splat.splatinsert1 = insertelement <4 x float> undef, float 3.0, i32 0
11*9880d681SAndroid Build Coastguard Worker  br label %for.cond
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Workerfor.cond:
14*9880d681SAndroid Build Coastguard Worker  %x.0 = phi <4 x float> [ %splat.splat, %entry ], [ %mul, %for.body ]
15*9880d681SAndroid Build Coastguard Worker  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
16*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32 * %n, align 4
17*9880d681SAndroid Build Coastguard Worker  %cmp = icmp ne i32 %i.0, %1
18*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %for.body, label %for.end
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Workerfor.body:
21*9880d681SAndroid Build Coastguard Worker  %2 = extractelement <4 x float> %x.0, i32 1
22*9880d681SAndroid Build Coastguard Worker  store volatile float %2, float * %inout, align 4
23*9880d681SAndroid Build Coastguard Worker  %mul = fmul fast <4 x float> %x.0, <float 0x4002A3D700000000, float 0x4002A3D700000000, float 0x4002A3D700000000, float 0x4002A3D700000000>
24*9880d681SAndroid Build Coastguard Worker  %inc = add nsw i32 %i.0, 1
25*9880d681SAndroid Build Coastguard Worker  br label %for.cond
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workerfor.end:
28*9880d681SAndroid Build Coastguard Worker  ret void
29*9880d681SAndroid Build Coastguard Worker}
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_extract_element_fastmath
32*9880d681SAndroid Build Coastguard Worker; CHECK: fadd fast float
33*9880d681SAndroid Build Coastguard Workerdefine float @test_extract_element_fastmath(<4 x float> %x) #0 {
34*9880d681SAndroid Build Coastguard Workerentry:
35*9880d681SAndroid Build Coastguard Worker  %add = fadd fast <4 x float> %x, <float 0x4002A3D700000000, float 0x4002A3D700000000, float 0x4002A3D700000000, float 0x4002A3D700000000>
36*9880d681SAndroid Build Coastguard Worker  %0 = extractelement <4 x float> %add, i32 2
37*9880d681SAndroid Build Coastguard Worker  ret float %0
38*9880d681SAndroid Build Coastguard Worker}
39*9880d681SAndroid Build Coastguard Worker
40