1 ; RUN: opt -S -simplifycfg -phi-node-folding-threshold=2 < %s | FileCheck %s 2 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 9 10 ; CHECK-LABEL: @sqrt_test( 11 ; CHECK: select 12 define void @sqrt_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind { 13 entry: 14 %cmp.i = fcmp olt float %a, 0.000000e+00 15 br i1 %cmp.i, label %test_sqrt.exit, label %cond.else.i 16 17 cond.else.i: ; preds = %entry 18 %0 = tail call float @llvm.sqrt.f32(float %a) nounwind readnone 19 br label %test_sqrt.exit 20 21 test_sqrt.exit: ; preds = %cond.else.i, %entry 22 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ] 23 store float %cond.i, float addrspace(1)* %out, align 4 24 ret void 25 } 26 27 ; CHECK-LABEL: @fabs_test( 28 ; CHECK: select 29 define void @fabs_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind { 30 entry: 31 %cmp.i = fcmp olt float %a, 0.000000e+00 32 br i1 %cmp.i, label %test_fabs.exit, label %cond.else.i 33 34 cond.else.i: ; preds = %entry 35 %0 = tail call float @llvm.fabs.f32(float %a) nounwind readnone 36 br label %test_fabs.exit 37 38 test_fabs.exit: ; preds = %cond.else.i, %entry 39 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ] 40 store float %cond.i, float addrspace(1)* %out, align 4 41 ret void 42 } 43 44 ; CHECK-LABEL: @fma_test( 45 ; CHECK: select 46 define void @fma_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind { 47 entry: 48 %cmp.i = fcmp olt float %a, 0.000000e+00 49 br i1 %cmp.i, label %test_fma.exit, label %cond.else.i 50 51 cond.else.i: ; preds = %entry 52 %0 = tail call float @llvm.fma.f32(float %a, float %b, float %c) nounwind readnone 53 br label %test_fma.exit 54 55 test_fma.exit: ; preds = %cond.else.i, %entry 56 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ] 57 store float %cond.i, float addrspace(1)* %out, align 4 58 ret void 59 } 60 61 ; CHECK-LABEL: @fmuladd_test( 62 ; CHECK: select 63 define void @fmuladd_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind { 64 entry: 65 %cmp.i = fcmp olt float %a, 0.000000e+00 66 br i1 %cmp.i, label %test_fmuladd.exit, label %cond.else.i 67 68 cond.else.i: ; preds = %entry 69 %0 = tail call float @llvm.fmuladd.f32(float %a, float %b, float %c) nounwind readnone 70 br label %test_fmuladd.exit 71 72 test_fmuladd.exit: ; preds = %cond.else.i, %entry 73 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ] 74 store float %cond.i, float addrspace(1)* %out, align 4 75 ret void 76 } 77 78 ; CHECK-LABEL: @minnum_test( 79 ; CHECK: select 80 define void @minnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind { 81 entry: 82 %cmp.i = fcmp olt float %a, 0.000000e+00 83 br i1 %cmp.i, label %test_minnum.exit, label %cond.else.i 84 85 cond.else.i: ; preds = %entry 86 %0 = tail call float @llvm.minnum.f32(float %a, float %b) nounwind readnone 87 br label %test_minnum.exit 88 89 test_minnum.exit: ; preds = %cond.else.i, %entry 90 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ] 91 store float %cond.i, float addrspace(1)* %out, align 4 92 ret void 93 } 94 95 ; CHECK-LABEL: @maxnum_test( 96 ; CHECK: select 97 define void @maxnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind { 98 entry: 99 %cmp.i = fcmp olt float %a, 0.000000e+00 100 br i1 %cmp.i, label %test_maxnum.exit, label %cond.else.i 101 102 cond.else.i: ; preds = %entry 103 %0 = tail call float @llvm.maxnum.f32(float %a, float %b) nounwind readnone 104 br label %test_maxnum.exit 105 106 test_maxnum.exit: ; preds = %cond.else.i, %entry 107 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ] 108 store float %cond.i, float addrspace(1)* %out, align 4 109 ret void 110 } 111