1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s
3 ; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -speculate-one-expensive-inst=false < %s | FileCheck %s
5 declare float @llvm.sqrt.f32(float) nounwind readonly
6 declare float @llvm.fma.f32(float, float, float) nounwind readonly
7 declare float @llvm.fmuladd.f32(float, float, float) nounwind readonly
8 declare float @llvm.fabs.f32(float) nounwind readonly
9 declare float @llvm.minnum.f32(float, float) nounwind readonly
10 declare float @llvm.maxnum.f32(float, float) nounwind readonly
11 declare float @llvm.minimum.f32(float, float) nounwind readonly
12 declare float @llvm.maximum.f32(float, float) nounwind readonly
14 define double @fdiv_test(double %a, double %b) {
15 ; CHECK-LABEL: @fdiv_test(
17 ; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt double [[A:%.*]], 0.000000e+00
18 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[B:%.*]], [[A]]
19 ; CHECK-NEXT: [[COND:%.*]] = select nsz i1 [[CMP]], double [[DIV]], double 0.000000e+00
20 ; CHECK-NEXT: ret double [[COND]]
23 %cmp = fcmp ogt double %a, 0.0
24 br i1 %cmp, label %cond.true, label %cond.end
27 %div = fdiv double %b, %a
31 %cond = phi nsz double [ %div, %cond.true ], [ 0.0, %entry ]
35 define void @sqrt_test(ptr addrspace(1) noalias nocapture %out, float %a) nounwind {
36 ; CHECK-LABEL: @sqrt_test(
38 ; CHECK-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
39 ; CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.sqrt.f32(float [[A]]) #[[ATTR2:[0-9]+]]
40 ; CHECK-NEXT: [[COND_I:%.*]] = select afn i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
41 ; CHECK-NEXT: store float [[COND_I]], ptr addrspace(1) [[OUT:%.*]], align 4
42 ; CHECK-NEXT: ret void
45 %cmp.i = fcmp olt float %a, 0.000000e+00
46 br i1 %cmp.i, label %test_sqrt.exit, label %cond.else.i
48 cond.else.i: ; preds = %entry
49 %0 = tail call float @llvm.sqrt.f32(float %a) nounwind readnone
50 br label %test_sqrt.exit
52 test_sqrt.exit: ; preds = %cond.else.i, %entry
53 %cond.i = phi afn float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
54 store float %cond.i, ptr addrspace(1) %out, align 4
58 define void @fabs_test(ptr addrspace(1) noalias nocapture %out, float %a) nounwind {
59 ; CHECK-LABEL: @fabs_test(
61 ; CHECK-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
62 ; CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.fabs.f32(float [[A]]) #[[ATTR2]]
63 ; CHECK-NEXT: [[COND_I:%.*]] = select reassoc i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
64 ; CHECK-NEXT: store float [[COND_I]], ptr addrspace(1) [[OUT:%.*]], align 4
65 ; CHECK-NEXT: ret void
68 %cmp.i = fcmp olt float %a, 0.000000e+00
69 br i1 %cmp.i, label %test_fabs.exit, label %cond.else.i
71 cond.else.i: ; preds = %entry
72 %0 = tail call float @llvm.fabs.f32(float %a) nounwind readnone
73 br label %test_fabs.exit
75 test_fabs.exit: ; preds = %cond.else.i, %entry
76 %cond.i = phi reassoc float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
77 store float %cond.i, ptr addrspace(1) %out, align 4
81 define void @fma_test(ptr addrspace(1) noalias nocapture %out, float %a, float %b, float %c) nounwind {
82 ; CHECK-LABEL: @fma_test(
84 ; CHECK-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
85 ; CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.fma.f32(float [[A]], float [[B:%.*]], float [[C:%.*]]) #[[ATTR2]]
86 ; CHECK-NEXT: [[COND_I:%.*]] = select reassoc nsz i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
87 ; CHECK-NEXT: store float [[COND_I]], ptr addrspace(1) [[OUT:%.*]], align 4
88 ; CHECK-NEXT: ret void
91 %cmp.i = fcmp olt float %a, 0.000000e+00
92 br i1 %cmp.i, label %test_fma.exit, label %cond.else.i
94 cond.else.i: ; preds = %entry
95 %0 = tail call float @llvm.fma.f32(float %a, float %b, float %c) nounwind readnone
96 br label %test_fma.exit
98 test_fma.exit: ; preds = %cond.else.i, %entry
99 %cond.i = phi nsz reassoc float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
100 store float %cond.i, ptr addrspace(1) %out, align 4
104 define void @fmuladd_test(ptr addrspace(1) noalias nocapture %out, float %a, float %b, float %c) nounwind {
105 ; CHECK-LABEL: @fmuladd_test(
107 ; CHECK-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
108 ; CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.fmuladd.f32(float [[A]], float [[B:%.*]], float [[C:%.*]]) #[[ATTR2]]
109 ; CHECK-NEXT: [[COND_I:%.*]] = select ninf i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
110 ; CHECK-NEXT: store float [[COND_I]], ptr addrspace(1) [[OUT:%.*]], align 4
111 ; CHECK-NEXT: ret void
114 %cmp.i = fcmp olt float %a, 0.000000e+00
115 br i1 %cmp.i, label %test_fmuladd.exit, label %cond.else.i
117 cond.else.i: ; preds = %entry
118 %0 = tail call float @llvm.fmuladd.f32(float %a, float %b, float %c) nounwind readnone
119 br label %test_fmuladd.exit
121 test_fmuladd.exit: ; preds = %cond.else.i, %entry
122 %cond.i = phi ninf float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
123 store float %cond.i, ptr addrspace(1) %out, align 4
127 define void @minnum_test(ptr addrspace(1) noalias nocapture %out, float %a, float %b) nounwind {
128 ; CHECK-LABEL: @minnum_test(
130 ; CHECK-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
131 ; CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.minnum.f32(float [[A]], float [[B:%.*]]) #[[ATTR2]]
132 ; CHECK-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
133 ; CHECK-NEXT: store float [[COND_I]], ptr addrspace(1) [[OUT:%.*]], align 4
134 ; CHECK-NEXT: ret void
137 %cmp.i = fcmp olt float %a, 0.000000e+00
138 br i1 %cmp.i, label %test_minnum.exit, label %cond.else.i
140 cond.else.i: ; preds = %entry
141 %0 = tail call float @llvm.minnum.f32(float %a, float %b) nounwind readnone
142 br label %test_minnum.exit
144 test_minnum.exit: ; preds = %cond.else.i, %entry
145 %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
146 store float %cond.i, ptr addrspace(1) %out, align 4
150 define void @maxnum_test(ptr addrspace(1) noalias nocapture %out, float %a, float %b) nounwind {
151 ; CHECK-LABEL: @maxnum_test(
153 ; CHECK-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
154 ; CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.maxnum.f32(float [[A]], float [[B:%.*]]) #[[ATTR2]]
155 ; CHECK-NEXT: [[COND_I:%.*]] = select ninf nsz i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
156 ; CHECK-NEXT: store float [[COND_I]], ptr addrspace(1) [[OUT:%.*]], align 4
157 ; CHECK-NEXT: ret void
160 %cmp.i = fcmp olt float %a, 0.000000e+00
161 br i1 %cmp.i, label %test_maxnum.exit, label %cond.else.i
163 cond.else.i: ; preds = %entry
164 %0 = tail call float @llvm.maxnum.f32(float %a, float %b) nounwind readnone
165 br label %test_maxnum.exit
167 test_maxnum.exit: ; preds = %cond.else.i, %entry
168 %cond.i = phi ninf nsz float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
169 store float %cond.i, ptr addrspace(1) %out, align 4
173 define void @minimum_test(ptr addrspace(1) noalias nocapture %out, float %a, float %b) nounwind {
174 ; CHECK-LABEL: @minimum_test(
176 ; CHECK-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
177 ; CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.minimum.f32(float [[A]], float [[B:%.*]]) #[[ATTR2]]
178 ; CHECK-NEXT: [[COND_I:%.*]] = select reassoc i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
179 ; CHECK-NEXT: store float [[COND_I]], ptr addrspace(1) [[OUT:%.*]], align 4
180 ; CHECK-NEXT: ret void
183 %cmp.i = fcmp olt float %a, 0.000000e+00
184 br i1 %cmp.i, label %test_minimum.exit, label %cond.else.i
186 cond.else.i: ; preds = %entry
187 %0 = tail call float @llvm.minimum.f32(float %a, float %b) nounwind readnone
188 br label %test_minimum.exit
190 test_minimum.exit: ; preds = %cond.else.i, %entry
191 %cond.i = phi reassoc float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
192 store float %cond.i, ptr addrspace(1) %out, align 4
196 define void @maximum_test(ptr addrspace(1) noalias nocapture %out, float %a, float %b) nounwind {
197 ; CHECK-LABEL: @maximum_test(
199 ; CHECK-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00
200 ; CHECK-NEXT: [[TMP0:%.*]] = tail call float @llvm.maximum.f32(float [[A]], float [[B:%.*]]) #[[ATTR2]]
201 ; CHECK-NEXT: [[COND_I:%.*]] = select nsz i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]]
202 ; CHECK-NEXT: store float [[COND_I]], ptr addrspace(1) [[OUT:%.*]], align 4
203 ; CHECK-NEXT: ret void
206 %cmp.i = fcmp olt float %a, 0.000000e+00
207 br i1 %cmp.i, label %test_maximum.exit, label %cond.else.i
209 cond.else.i: ; preds = %entry
210 %0 = tail call float @llvm.maximum.f32(float %a, float %b) nounwind readnone
211 br label %test_maximum.exit
213 test_maximum.exit: ; preds = %cond.else.i, %entry
214 %cond.i = phi nsz float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
215 store float %cond.i, ptr addrspace(1) %out, align 4