blob: 5655d5d788218486883a847eaf16855f1a0f0444 [file] [log] [blame]
David Majnemerfccf5c62016-01-27 02:59:41 +00001; 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 Arsenaultee364ee2014-01-31 00:09:00 +00003
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
Matt Arsenault85cbc7e2014-08-29 16:01:17 +00007declare float @llvm.fabs.f32(float) nounwind readonly
Matt Arsenaultd6511b42014-10-21 23:00:20 +00008declare float @llvm.minnum.f32(float, float) nounwind readonly
9declare float @llvm.maxnum.f32(float, float) nounwind readonly
Matt Arsenaultee364ee2014-01-31 00:09:00 +000010
David Majnemerfccf5c62016-01-27 02:59:41 +000011; ALL-LABEL: @fdiv_test(
12; EXPENSIVE: select i1 %cmp, double %div, double 0.0
13; CHEAP-NOT: select
Sanjay Patel13e8bbc2015-09-23 22:28:18 +000014
Sanjay Patel13e8bbc2015-09-23 22:28:18 +000015define 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
David Majnemerfccf5c62016-01-27 02:59:41 +000029; ALL-LABEL: @sqrt_test(
30; ALL: select
Matt Arsenaultee364ee2014-01-31 00:09:00 +000031define 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
David Majnemerfccf5c62016-01-27 02:59:41 +000046; ALL-LABEL: @fabs_test(
47; ALL: select
Matt Arsenault85cbc7e2014-08-29 16:01:17 +000048define 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}
Matt Arsenaultee364ee2014-01-31 00:09:00 +000062
David Majnemerfccf5c62016-01-27 02:59:41 +000063; ALL-LABEL: @fma_test(
64; ALL: select
Matt Arsenaultee364ee2014-01-31 00:09:00 +000065define 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
David Majnemerfccf5c62016-01-27 02:59:41 +000080; ALL-LABEL: @fmuladd_test(
81; ALL: select
Matt Arsenaultee364ee2014-01-31 00:09:00 +000082define 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
David Majnemerfccf5c62016-01-27 02:59:41 +000097; ALL-LABEL: @minnum_test(
98; ALL: select
Matt Arsenaultd6511b42014-10-21 23:00:20 +000099define 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
David Majnemerfccf5c62016-01-27 02:59:41 +0000114; ALL-LABEL: @maxnum_test(
115; ALL: select
Matt Arsenaultd6511b42014-10-21 23:00:20 +0000116define 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}