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 4 5; Make sure there are no crashes when calling computeKnownFPClass with 6; un-inserted cloned instructions. 7 8; Hit computeKnownFPClass in a context where the denormal mode is 9; queried for the function for an operand not in a parent function. 10 11define 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]] 17; 18 %call = call i1 @simplify_fcmp_ord_fsub_callee(double %i0, double %i1) 19 ret i1 %call 20} 21 22; Make sure we hit the denormal query in isKnownNeverLogicalZero 23define 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 26 ret i1 %cmp 27} 28 29define 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 34; 35 %call = call i1 @simplify_fcmp_ord_fdiv_callee(double %i0, double %i1) 36 ret i1 %call 37} 38 39; Make sure we hit the denormal query in isKnownNeverLogicalZero 40define 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 43 ret i1 %cmp 44} 45 46define 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 51; 52 %call = call i1 @simplify_fcmp_ord_frem_callee(double %i0, double %i1) 53 ret i1 %call 54} 55 56; Make sure we hit the denormal query in isKnownNeverLogicalZero 57define 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 60 ret i1 %cmp 61} 62 63define 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 68; 69 %call = call i1 @simplify_fcmp_ord_fmul_callee(double %i0, double %i1) 70 ret i1 %call 71} 72 73; Make sure we hit the denormal query in isKnownNeverLogicalZero 74define 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 77 ret i1 %cmp 78} 79 80define 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]] 86; 87 %call = call i1 @simplify_fcmp_ord_sqrt_callee(double %i0) 88 ret i1 %call 89} 90 91; Make sure we hit the denormal query in isKnownNeverLogicalZero 92define 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 95 ret i1 %cmp 96} 97 98declare double @llvm.sqrt.f64(double) 99 100define 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 105; 106 %call = call i1 @simplify_fcmp_ord_canonicalize_callee(double %i0) 107 ret i1 %call 108} 109 110; Make sure we hit the denormal query in isKnownNeverLogicalZero 111define 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 114 ret i1 %cmp 115} 116 117declare double @llvm.canonicalize.f64(double) 118 119define 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]] 125; 126 %call = call i1 @simplify_fcmp_ord_log_callee(double %i0) 127 ret i1 %call 128} 129 130; Make sure we hit the denormal query in isKnownNeverLogicalZero 131define 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 134 ret i1 %cmp 135} 136 137declare double @llvm.log.f64(double) 138 139declare float @llvm.maxnum.f32(float, float) #0 140declare <4 x float> @foo() #1 141 142define void @caller_maxnum() { 143; CHECK-LABEL: define void @caller_maxnum() { 144; CHECK-NEXT: bb: 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 151; 152bb: 153 call void @callee_maxnum() 154 ret void 155} 156 157define internal void @callee_maxnum() { 158bb: 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 165 ret void 166} 167 168define 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]] 174; 175 %call = call i1 @simplify_fcmp_ord_ldexp_callee(double %i0) 176 ret i1 %call 177} 178 179define 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 182 ret i1 %cmp 183} 184 185declare double @llvm.ldexp.f64.i32(double, i32) 186 187define 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]] 194; 195 %call = call i1 @simplify_fcmp_ord_frexp_callee(double %i0) 196 ret i1 %call 197} 198 199define 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 203 ret i1 %cmp 204} 205 206declare { double, i32 } @llvm.frexp.f64.i32(double) 207 208attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } 209attributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) } 210