1 ; RUN: opt -S -simplifycfg < %s | FileCheck %s --check-prefix=EXPENSIVE --check-prefix=ALL
2 ; RUN: opt -S -simplifycfg -speculate-one-expensive-inst=false < %s | FileCheck %s --check-prefix=CHEAP --check-prefix=ALL
4 declare float @llvm.sqrt.f32(float) nounwind readonly
5 declare float @llvm.fma.f32(float, float, float) nounwind readonly
6 declare float @llvm.fmuladd.f32(float, float, float) nounwind readonly
7 declare float @llvm.fabs.f32(float) nounwind readonly
8 declare float @llvm.minnum.f32(float, float) nounwind readonly
9 declare float @llvm.maxnum.f32(float, float) nounwind readonly
11 ; ALL-LABEL: @fdiv_test(
12 ; EXPENSIVE: select i1 %cmp, double %div, double 0.0
15 define double @fdiv_test(double %a, double %b) {
17 %cmp = fcmp ogt double %a, 0.0
18 br i1 %cmp, label %cond.true, label %cond.end
21 %div = fdiv double %b, %a
25 %cond = phi double [ %div, %cond.true ], [ 0.0, %entry ]
29 ; ALL-LABEL: @sqrt_test(
31 define void @sqrt_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
33 %cmp.i = fcmp olt float %a, 0.000000e+00
34 br i1 %cmp.i, label %test_sqrt.exit, label %cond.else.i
36 cond.else.i: ; preds = %entry
37 %0 = tail call float @llvm.sqrt.f32(float %a) nounwind readnone
38 br label %test_sqrt.exit
40 test_sqrt.exit: ; preds = %cond.else.i, %entry
41 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
42 store float %cond.i, float addrspace(1)* %out, align 4
46 ; ALL-LABEL: @fabs_test(
48 define void @fabs_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
50 %cmp.i = fcmp olt float %a, 0.000000e+00
51 br i1 %cmp.i, label %test_fabs.exit, label %cond.else.i
53 cond.else.i: ; preds = %entry
54 %0 = tail call float @llvm.fabs.f32(float %a) nounwind readnone
55 br label %test_fabs.exit
57 test_fabs.exit: ; preds = %cond.else.i, %entry
58 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
59 store float %cond.i, float addrspace(1)* %out, align 4
63 ; ALL-LABEL: @fma_test(
65 define void @fma_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
67 %cmp.i = fcmp olt float %a, 0.000000e+00
68 br i1 %cmp.i, label %test_fma.exit, label %cond.else.i
70 cond.else.i: ; preds = %entry
71 %0 = tail call float @llvm.fma.f32(float %a, float %b, float %c) nounwind readnone
72 br label %test_fma.exit
74 test_fma.exit: ; preds = %cond.else.i, %entry
75 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
76 store float %cond.i, float addrspace(1)* %out, align 4
80 ; ALL-LABEL: @fmuladd_test(
82 define void @fmuladd_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
84 %cmp.i = fcmp olt float %a, 0.000000e+00
85 br i1 %cmp.i, label %test_fmuladd.exit, label %cond.else.i
87 cond.else.i: ; preds = %entry
88 %0 = tail call float @llvm.fmuladd.f32(float %a, float %b, float %c) nounwind readnone
89 br label %test_fmuladd.exit
91 test_fmuladd.exit: ; preds = %cond.else.i, %entry
92 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
93 store float %cond.i, float addrspace(1)* %out, align 4
97 ; ALL-LABEL: @minnum_test(
99 define void @minnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
101 %cmp.i = fcmp olt float %a, 0.000000e+00
102 br i1 %cmp.i, label %test_minnum.exit, label %cond.else.i
104 cond.else.i: ; preds = %entry
105 %0 = tail call float @llvm.minnum.f32(float %a, float %b) nounwind readnone
106 br label %test_minnum.exit
108 test_minnum.exit: ; preds = %cond.else.i, %entry
109 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
110 store float %cond.i, float addrspace(1)* %out, align 4
114 ; ALL-LABEL: @maxnum_test(
116 define void @maxnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
118 %cmp.i = fcmp olt float %a, 0.000000e+00
119 br i1 %cmp.i, label %test_maxnum.exit, label %cond.else.i
121 cond.else.i: ; preds = %entry
122 %0 = tail call float @llvm.maxnum.f32(float %a, float %b) nounwind readnone
123 br label %test_maxnum.exit
125 test_maxnum.exit: ; preds = %cond.else.i, %entry
126 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
127 store float %cond.i, float addrspace(1)* %out, align 4