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