1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt < %s -passes=inline -inline-threshold=20 -S | FileCheck %s
3 ; RUN: opt < %s -passes='cgscc(inline)' -inline-threshold=20 -S | FileCheck %s
5 ; Make sure there are no crashes when calling computeKnownFPClass with
6 ; un-inserted cloned instructions.
8 ; Hit computeKnownFPClass in a context where the denormal mode is
9 ; queried for the function for an operand not in a parent function.
11 define i1 @simplify_fcmp_ord_fsub_caller(double nofpclass(zero nan) %i0, double nofpclass(zero nan) %i1) {
12 ; CHECK-LABEL: define i1 @simplify_fcmp_ord_fsub_caller
13 ; CHECK-SAME: (double nofpclass(nan zero) [[I0:%.*]], double nofpclass(nan zero) [[I1:%.*]]) {
14 ; CHECK-NEXT: [[SUB_DOUBLE_SUB_I:%.*]] = fsub double [[I0]], [[I1]]
15 ; CHECK-NEXT: [[CMP_I:%.*]] = fcmp ord double [[SUB_DOUBLE_SUB_I]], 0.000000e+00
16 ; CHECK-NEXT: ret i1 [[CMP_I]]
18 %call = call i1 @simplify_fcmp_ord_fsub_callee(double %i0, double %i1)
22 ; Make sure we hit the denormal query in isKnownNeverLogicalZero
23 define internal i1 @simplify_fcmp_ord_fsub_callee(double %a, double %b) {
24 %sub.double.sub = fsub double %a, %b
25 %cmp = fcmp ord double %sub.double.sub, 0.0
29 define i1 @simplify_fcmp_ord_fdiv_caller(double nofpclass(zero nan inf) %i0, double nofpclass(zero nan inf) %i1) {
30 ; CHECK-LABEL: define i1 @simplify_fcmp_ord_fdiv_caller
31 ; CHECK-SAME: (double nofpclass(nan inf zero) [[I0:%.*]], double nofpclass(nan inf zero) [[I1:%.*]]) {
32 ; CHECK-NEXT: [[SUB_DOUBLE_SUB_I:%.*]] = fdiv double [[I0]], [[I1]]
33 ; CHECK-NEXT: ret i1 true
35 %call = call i1 @simplify_fcmp_ord_fdiv_callee(double %i0, double %i1)
39 ; Make sure we hit the denormal query in isKnownNeverLogicalZero
40 define internal i1 @simplify_fcmp_ord_fdiv_callee(double %a, double %b) {
41 %sub.double.sub = fdiv double %a, %b
42 %cmp = fcmp ord double %sub.double.sub, 0.0
46 define i1 @simplify_fcmp_ord_frem_caller(double nofpclass(zero nan inf) %i0, double nofpclass(zero nan inf) %i1) {
47 ; CHECK-LABEL: define i1 @simplify_fcmp_ord_frem_caller
48 ; CHECK-SAME: (double nofpclass(nan inf zero) [[I0:%.*]], double nofpclass(nan inf zero) [[I1:%.*]]) {
49 ; CHECK-NEXT: [[SUB_DOUBLE_SUB_I:%.*]] = frem double [[I0]], [[I1]]
50 ; CHECK-NEXT: ret i1 true
52 %call = call i1 @simplify_fcmp_ord_frem_callee(double %i0, double %i1)
56 ; Make sure we hit the denormal query in isKnownNeverLogicalZero
57 define internal i1 @simplify_fcmp_ord_frem_callee(double %a, double %b) {
58 %sub.double.sub = frem double %a, %b
59 %cmp = fcmp ord double %sub.double.sub, 0.0
63 define i1 @simplify_fcmp_ord_fmul_caller(double nofpclass(zero nan inf) %i0, double nofpclass(zero nan inf) %i1) {
64 ; CHECK-LABEL: define i1 @simplify_fcmp_ord_fmul_caller
65 ; CHECK-SAME: (double nofpclass(nan inf zero) [[I0:%.*]], double nofpclass(nan inf zero) [[I1:%.*]]) {
66 ; CHECK-NEXT: [[SUB_DOUBLE_SUB_I:%.*]] = fmul double [[I0]], [[I1]]
67 ; CHECK-NEXT: ret i1 true
69 %call = call i1 @simplify_fcmp_ord_fmul_callee(double %i0, double %i1)
73 ; Make sure we hit the denormal query in isKnownNeverLogicalZero
74 define internal i1 @simplify_fcmp_ord_fmul_callee(double %a, double %b) {
75 %sub.double.sub = fmul double %a, %b
76 %cmp = fcmp ord double %sub.double.sub, 0.0
80 define i1 @simplify_fcmp_ord_sqrt_caller(double nofpclass(zero nan) %i0) {
81 ; CHECK-LABEL: define i1 @simplify_fcmp_ord_sqrt_caller
82 ; CHECK-SAME: (double nofpclass(nan zero) [[I0:%.*]]) {
83 ; CHECK-NEXT: [[SUB_DOUBLE_SUB_I:%.*]] = call double @llvm.sqrt.f64(double [[I0]])
84 ; CHECK-NEXT: [[CMP_I:%.*]] = fcmp ord double [[SUB_DOUBLE_SUB_I]], 0.000000e+00
85 ; CHECK-NEXT: ret i1 [[CMP_I]]
87 %call = call i1 @simplify_fcmp_ord_sqrt_callee(double %i0)
91 ; Make sure we hit the denormal query in isKnownNeverLogicalZero
92 define internal i1 @simplify_fcmp_ord_sqrt_callee(double %a) {
93 %sub.double.sub = call double @llvm.sqrt.f64(double %a)
94 %cmp = fcmp ord double %sub.double.sub, 0.0
98 declare double @llvm.sqrt.f64(double)
100 define i1 @simplify_fcmp_ord_canonicalize_caller(double nofpclass(zero nan) %i0) {
101 ; CHECK-LABEL: define i1 @simplify_fcmp_ord_canonicalize_caller
102 ; CHECK-SAME: (double nofpclass(nan zero) [[I0:%.*]]) {
103 ; CHECK-NEXT: [[SUB_DOUBLE_SUB_I:%.*]] = call double @llvm.canonicalize.f64(double [[I0]])
104 ; CHECK-NEXT: ret i1 true
106 %call = call i1 @simplify_fcmp_ord_canonicalize_callee(double %i0)
110 ; Make sure we hit the denormal query in isKnownNeverLogicalZero
111 define internal i1 @simplify_fcmp_ord_canonicalize_callee(double %a) {
112 %sub.double.sub = call double @llvm.canonicalize.f64(double %a)
113 %cmp = fcmp ord double %sub.double.sub, 0.0
117 declare double @llvm.canonicalize.f64(double)
119 define i1 @simplify_fcmp_ord_log_caller(double nofpclass(zero nan) %i0) {
120 ; CHECK-LABEL: define i1 @simplify_fcmp_ord_log_caller
121 ; CHECK-SAME: (double nofpclass(nan zero) [[I0:%.*]]) {
122 ; CHECK-NEXT: [[SUB_DOUBLE_SUB_I:%.*]] = call double @llvm.log.f64(double [[I0]])
123 ; CHECK-NEXT: [[CMP_I:%.*]] = fcmp ord double [[SUB_DOUBLE_SUB_I]], 0.000000e+00
124 ; CHECK-NEXT: ret i1 [[CMP_I]]
126 %call = call i1 @simplify_fcmp_ord_log_callee(double %i0)
130 ; Make sure we hit the denormal query in isKnownNeverLogicalZero
131 define internal i1 @simplify_fcmp_ord_log_callee(double %a) {
132 %sub.double.sub = call double @llvm.log.f64(double %a)
133 %cmp = fcmp ord double %sub.double.sub, 0.0
137 declare double @llvm.log.f64(double)
139 declare float @llvm.maxnum.f32(float, float) #0
140 declare <4 x float> @foo() #1
142 define void @caller_maxnum() {
143 ; CHECK-LABEL: define void @caller_maxnum() {
145 ; CHECK-NEXT: [[I1_I:%.*]] = call <4 x float> @foo()
146 ; CHECK-NEXT: [[I2_I:%.*]] = extractelement <4 x float> [[I1_I]], i64 0
147 ; CHECK-NEXT: [[I3_I:%.*]] = fmul float [[I2_I]], 0.000000e+00
148 ; CHECK-NEXT: [[I4_I:%.*]] = call float @llvm.maxnum.f32(float [[I3_I]], float 0.000000e+00)
149 ; CHECK-NEXT: [[I5_I:%.*]] = call float @llvm.maxnum.f32(float [[I4_I]], float [[I2_I]])
150 ; CHECK-NEXT: ret void
153 call void @callee_maxnum()
157 define internal void @callee_maxnum() {
159 %i1 = call <4 x float> @foo()
160 %i2 = extractelement <4 x float> %i1, i64 0
161 %i3 = fmul float %i2, 0.000000e+00
162 %i4 = call float @llvm.maxnum.f32(float %i3, float 0.000000e+00)
163 %i5 = call float @llvm.maxnum.f32(float %i4, float %i2)
164 %i6 = fcmp olt float %i5, 0.000000e+00
168 define i1 @simplify_fcmp_ord_ldexp_caller(double nofpclass(zero inf) %i0) {
169 ; CHECK-LABEL: define i1 @simplify_fcmp_ord_ldexp_caller
170 ; CHECK-SAME: (double nofpclass(inf zero) [[I0:%.*]]) {
171 ; CHECK-NEXT: [[LDEXP_I:%.*]] = call double @llvm.ldexp.f64.i32(double [[I0]], i32 42)
172 ; CHECK-NEXT: [[CMP_I:%.*]] = fcmp one double [[LDEXP_I]], 0x7FF0000000000000
173 ; CHECK-NEXT: ret i1 [[CMP_I]]
175 %call = call i1 @simplify_fcmp_ord_ldexp_callee(double %i0)
179 define internal i1 @simplify_fcmp_ord_ldexp_callee(double %a) {
180 %ldexp = call double @llvm.ldexp.f64.i32(double %a, i32 42)
181 %cmp = fcmp one double %ldexp, 0x7FF0000000000000
185 declare double @llvm.ldexp.f64.i32(double, i32)
187 define i1 @simplify_fcmp_ord_frexp_caller(double nofpclass(zero inf) %i0) {
188 ; CHECK-LABEL: define i1 @simplify_fcmp_ord_frexp_caller
189 ; CHECK-SAME: (double nofpclass(inf zero) [[I0:%.*]]) {
190 ; CHECK-NEXT: [[FREXP_I:%.*]] = call { double, i32 } @llvm.frexp.f64.i32(double [[I0]])
191 ; CHECK-NEXT: [[FREXP_0_I:%.*]] = extractvalue { double, i32 } [[FREXP_I]], 0
192 ; CHECK-NEXT: [[CMP_I:%.*]] = fcmp one double [[FREXP_0_I]], 0x7FF0000000000000
193 ; CHECK-NEXT: ret i1 [[CMP_I]]
195 %call = call i1 @simplify_fcmp_ord_frexp_callee(double %i0)
199 define internal i1 @simplify_fcmp_ord_frexp_callee(double %a) {
200 %frexp = call { double, i32 } @llvm.frexp.f64.i32(double %a)
201 %frexp.0 = extractvalue { double, i32 } %frexp, 0
202 %cmp = fcmp one double %frexp.0, 0x7FF0000000000000
206 declare { double, i32 } @llvm.frexp.f64.i32(double)
208 attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
209 attributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) }