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 3 4declare float @llvm.sqrt.f32(float) nounwind readonly 5declare float @llvm.fma.f32(float, float, float) nounwind readonly 6declare float @llvm.fmuladd.f32(float, float, float) nounwind readonly 7declare float @llvm.fabs.f32(float) nounwind readonly 8declare float @llvm.minnum.f32(float, float) nounwind readonly 9declare float @llvm.maxnum.f32(float, float) nounwind readonly 10 11; ALL-LABEL: @fdiv_test( 12; EXPENSIVE: select i1 %cmp, double %div, double 0.0 13; CHEAP-NOT: select 14 15define double @fdiv_test(double %a, double %b) { 16entry: 17 %cmp = fcmp ogt double %a, 0.0 18 br i1 %cmp, label %cond.true, label %cond.end 19 20cond.true: 21 %div = fdiv double %b, %a 22 br label %cond.end 23 24cond.end: 25 %cond = phi double [ %div, %cond.true ], [ 0.0, %entry ] 26 ret double %cond 27} 28 29; ALL-LABEL: @sqrt_test( 30; ALL: select 31define void @sqrt_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind { 32entry: 33 %cmp.i = fcmp olt float %a, 0.000000e+00 34 br i1 %cmp.i, label %test_sqrt.exit, label %cond.else.i 35 36cond.else.i: ; preds = %entry 37 %0 = tail call float @llvm.sqrt.f32(float %a) nounwind readnone 38 br label %test_sqrt.exit 39 40test_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 43 ret void 44} 45 46; ALL-LABEL: @fabs_test( 47; ALL: select 48define void @fabs_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind { 49entry: 50 %cmp.i = fcmp olt float %a, 0.000000e+00 51 br i1 %cmp.i, label %test_fabs.exit, label %cond.else.i 52 53cond.else.i: ; preds = %entry 54 %0 = tail call float @llvm.fabs.f32(float %a) nounwind readnone 55 br label %test_fabs.exit 56 57test_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 60 ret void 61} 62 63; ALL-LABEL: @fma_test( 64; ALL: select 65define void @fma_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind { 66entry: 67 %cmp.i = fcmp olt float %a, 0.000000e+00 68 br i1 %cmp.i, label %test_fma.exit, label %cond.else.i 69 70cond.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 73 74test_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 77 ret void 78} 79 80; ALL-LABEL: @fmuladd_test( 81; ALL: select 82define void @fmuladd_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind { 83entry: 84 %cmp.i = fcmp olt float %a, 0.000000e+00 85 br i1 %cmp.i, label %test_fmuladd.exit, label %cond.else.i 86 87cond.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 90 91test_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 94 ret void 95} 96 97; ALL-LABEL: @minnum_test( 98; ALL: select 99define void @minnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind { 100entry: 101 %cmp.i = fcmp olt float %a, 0.000000e+00 102 br i1 %cmp.i, label %test_minnum.exit, label %cond.else.i 103 104cond.else.i: ; preds = %entry 105 %0 = tail call float @llvm.minnum.f32(float %a, float %b) nounwind readnone 106 br label %test_minnum.exit 107 108test_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 111 ret void 112} 113 114; ALL-LABEL: @maxnum_test( 115; ALL: select 116define void @maxnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind { 117entry: 118 %cmp.i = fcmp olt float %a, 0.000000e+00 119 br i1 %cmp.i, label %test_maxnum.exit, label %cond.else.i 120 121cond.else.i: ; preds = %entry 122 %0 = tail call float @llvm.maxnum.f32(float %a, float %b) nounwind readnone 123 br label %test_maxnum.exit 124 125test_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 128 ret void 129} 130