1 ; RUN: opt -S -simplifycfg -phi-node-folding-threshold=2 < %s | FileCheck %s
3 declare float @llvm.sqrt.f32(float) nounwind readonly
4 declare float @llvm.fma.f32(float, float, float) nounwind readonly
5 declare float @llvm.fmuladd.f32(float, float, float) nounwind readonly
6 declare float @llvm.fabs.f32(float) nounwind readonly
7 declare float @llvm.minnum.f32(float, float) nounwind readonly
8 declare float @llvm.maxnum.f32(float, float) nounwind readonly
10 ; FIXME: This is intended to be a temporary test. As discussed in
11 ; D12882, we actually do want to speculate even expensive operations
12 ; in SimplifyCFG because it can expose more optimizations for other
13 ; passes. Therefore, we either need to adjust SimplifyCFG's
14 ; calculations that use the TTI cost model or use a different cost
15 ; model for deciding which ops should be speculated in SimplifyCFG.
16 ; We should also be using the TTI cost model later - for example in
17 ; CodeGenPrepare - to potentially undo this speculation.
19 ; Do not speculate fdiv by default because it is generally expensive.
21 ; CHECK-LABEL: @fdiv_test(
23 define double @fdiv_test(double %a, double %b) {
25 %cmp = fcmp ogt double %a, 0.0
26 br i1 %cmp, label %cond.true, label %cond.end
29 %div = fdiv double %b, %a
33 %cond = phi double [ %div, %cond.true ], [ 0.0, %entry ]
37 ; CHECK-LABEL: @sqrt_test(
39 define void @sqrt_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
41 %cmp.i = fcmp olt float %a, 0.000000e+00
42 br i1 %cmp.i, label %test_sqrt.exit, label %cond.else.i
44 cond.else.i: ; preds = %entry
45 %0 = tail call float @llvm.sqrt.f32(float %a) nounwind readnone
46 br label %test_sqrt.exit
48 test_sqrt.exit: ; preds = %cond.else.i, %entry
49 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
50 store float %cond.i, float addrspace(1)* %out, align 4
54 ; CHECK-LABEL: @fabs_test(
56 define void @fabs_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
58 %cmp.i = fcmp olt float %a, 0.000000e+00
59 br i1 %cmp.i, label %test_fabs.exit, label %cond.else.i
61 cond.else.i: ; preds = %entry
62 %0 = tail call float @llvm.fabs.f32(float %a) nounwind readnone
63 br label %test_fabs.exit
65 test_fabs.exit: ; preds = %cond.else.i, %entry
66 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
67 store float %cond.i, float addrspace(1)* %out, align 4
71 ; CHECK-LABEL: @fma_test(
73 define void @fma_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
75 %cmp.i = fcmp olt float %a, 0.000000e+00
76 br i1 %cmp.i, label %test_fma.exit, label %cond.else.i
78 cond.else.i: ; preds = %entry
79 %0 = tail call float @llvm.fma.f32(float %a, float %b, float %c) nounwind readnone
80 br label %test_fma.exit
82 test_fma.exit: ; preds = %cond.else.i, %entry
83 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
84 store float %cond.i, float addrspace(1)* %out, align 4
88 ; CHECK-LABEL: @fmuladd_test(
90 define void @fmuladd_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
92 %cmp.i = fcmp olt float %a, 0.000000e+00
93 br i1 %cmp.i, label %test_fmuladd.exit, label %cond.else.i
95 cond.else.i: ; preds = %entry
96 %0 = tail call float @llvm.fmuladd.f32(float %a, float %b, float %c) nounwind readnone
97 br label %test_fmuladd.exit
99 test_fmuladd.exit: ; preds = %cond.else.i, %entry
100 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
101 store float %cond.i, float addrspace(1)* %out, align 4
105 ; CHECK-LABEL: @minnum_test(
107 define void @minnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
109 %cmp.i = fcmp olt float %a, 0.000000e+00
110 br i1 %cmp.i, label %test_minnum.exit, label %cond.else.i
112 cond.else.i: ; preds = %entry
113 %0 = tail call float @llvm.minnum.f32(float %a, float %b) nounwind readnone
114 br label %test_minnum.exit
116 test_minnum.exit: ; preds = %cond.else.i, %entry
117 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
118 store float %cond.i, float addrspace(1)* %out, align 4
122 ; CHECK-LABEL: @maxnum_test(
124 define void @maxnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
126 %cmp.i = fcmp olt float %a, 0.000000e+00
127 br i1 %cmp.i, label %test_maxnum.exit, label %cond.else.i
129 cond.else.i: ; preds = %entry
130 %0 = tail call float @llvm.maxnum.f32(float %a, float %b) nounwind readnone
131 br label %test_maxnum.exit
133 test_maxnum.exit: ; preds = %cond.else.i, %entry
134 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
135 store float %cond.i, float addrspace(1)* %out, align 4