1; RUN: opt -passes=early-cse -S < %s | FileCheck %s 2 3; We allow either sign to provide flexibility for mathlib 4; implementations. The POSIX standard is not strict here. 5 6define float @callatan0() { 7; CHECK-LABEL: @callatan0( 8; CHECK-NEXT: ret float {{-?}}0.000000e+00 9; 10 %call = call float @atanf(float -0.0) 11 ret float %call 12} 13 14; TODO: constant should be folded 15define float @callatanInf() { 16; CHECK-LABEL: @callatanInf( 17; CHECK-NEXT: [[CALL:%.*]] = call float @atanf(float 0x7FF0000000000000) 18; CHECK-NEXT: ret float [[CALL]] 19; 20 %call = call float @atanf(float 0x7FF0000000000000) 21 ret float %call 22} 23 24; TODO: constant should be folded 25define float @callatanNaN() { 26; CHECK-LABEL: @callatanNaN( 27; CHECK-NEXT: [[CALL:%.*]] = call float @atanf(float 0x7FF8000000000000) 28; CHECK-NEXT: ret float [[CALL]] 29; 30 %call = call float @atanf(float 0x7FF8000000000000) 31 ret float %call 32} 33 34; POSIX: May fail with Range Error. We choose not to fail. 35define float @callatanDenorm() { 36; CHECK-LABEL: @callatanDenorm( 37; CHECK-NEXT: ret float 0x37A16C2000000000 38; 39 %call = call float @atanf(float 0x37A16C2000000000) 40 ret float %call 41} 42 43; TODO: long double calls currently not folded 44define x86_fp80 @atanl_x86(x86_fp80 %x) { 45; CHECK-LABEL: @atanl_x86( 46; CHECK-NEXT: [[CALL:%.*]] = call x86_fp80 @atanl(x86_fp80 noundef 0xK3FFF8CCCCCCCCCCCCCCD) 47; CHECK-NEXT: ret x86_fp80 [[CALL]] 48; 49 %call = call x86_fp80 @atanl(x86_fp80 noundef 0xK3FFF8CCCCCCCCCCCCCCD) 50 ret x86_fp80 %call 51} 52 53; This is not folded because it is known to set errno on some systems. 54 55define float @callatan2_00() { 56; CHECK-LABEL: @callatan2_00( 57; CHECK-NEXT: [[CALL:%.*]] = call float @atan2f(float 0.000000e+00, float 0.000000e+00) 58; CHECK-NEXT: ret float [[CALL]] 59; 60 %call = call float @atan2f(float 0.0, float 0.0) 61 ret float %call 62} 63 64; This is not folded because it is known to set errno on some systems. 65 66define float @callatan2_n00() { 67; CHECK-LABEL: @callatan2_n00( 68; CHECK-NEXT: [[CALL:%.*]] = call float @atan2f(float -0.000000e+00, float 0.000000e+00) 69; CHECK-NEXT: ret float [[CALL]] 70; 71 %call = call float @atan2f(float -0.0, float 0.0) 72 ret float %call 73} 74 75; This is not folded because it is known to set errno on some systems. 76 77define float @callatan2_0n0() { 78; CHECK-LABEL: @callatan2_0n0( 79; CHECK-NEXT: [[CALL:%.*]] = call float @atan2f(float 0.000000e+00, float -0.000000e+00) 80; CHECK-NEXT: ret float [[CALL]] 81; 82 %call = call float @atan2f(float 0.0, float -0.0) 83 ret float %call 84} 85 86; This is not folded because it is known to set errno on some systems. 87 88define float @callatan2_n0n0() { 89; CHECK-LABEL: @callatan2_n0n0( 90; CHECK-NEXT: [[CALL:%.*]] = call float @atan2f(float -0.000000e+00, float -0.000000e+00) 91; CHECK-NEXT: ret float [[CALL]] 92; 93 %call = call float @atan2f(float -0.0, float -0.0) 94 ret float %call 95} 96 97define float @callatan2_x0() { 98; CHECK-LABEL: @callatan2_x0( 99; CHECK-NEXT: ret float 0x3FF921FB60000000 100; 101 %call = call float @atan2f(float 1.0, float -0.000000e+00) 102 ret float %call 103} 104 105define float @callatan2_0x() { 106; CHECK-LABEL: @callatan2_0x( 107; CHECK-NEXT: ret float -0.000000e+00 108; 109 %call = call float @atan2f(float -0.0, float 1.0) 110 ret float %call 111} 112 113define float @callatan2_xx() { 114; CHECK-LABEL: @callatan2_xx( 115; CHECK-NEXT: ret float 0xBFE921FB60000000 116; 117 %call = call float @atan2f(float -1.0, float 1.0) 118 ret float %call 119} 120 121define float @callatan2_denorm() { 122; CHECK-LABEL: @callatan2_denorm( 123; CHECK-NEXT: ret float 0x37A16C2000000000 124; 125 %call = call float @atan2f(float 0x39B4484C00000000, float 1.0e+10) 126 ret float %call 127} 128 129define float @callatan2_flush_to_zero() { 130; CHECK-LABEL: @callatan2_flush_to_zero( 131; CHECK-NEXT: ret float 0.000000e+00 132; 133 %call = call float @atan2f(float 0x39B4484C00000000, float 0x4415AF1D80000000) 134 ret float %call 135} 136 137define float @callatan2_NaN() { 138; CHECK-LABEL: @callatan2_NaN( 139; CHECK-NEXT: ret float 0x7FF8000000000000 140; 141 %call = call float @atan2f(float 0x7FF8000000000000, float 0x7FF8000000000000) 142 ret float %call 143} 144 145define float @callatan2_Inf() { 146; CHECK-LABEL: @callatan2_Inf( 147; CHECK-NEXT: ret float 0x3FE921FB60000000 148; 149 %call = call float @atan2f(float 0x7FF0000000000000, float 0x7FF0000000000000) 150 ret float %call 151} 152 153declare dso_local float @atanf(float) #0 154declare dso_local x86_fp80 @atanl(x86_fp80) #0 155 156declare dso_local float @atan2f(float, float) #0 157 158attributes #0 = { nofree nounwind willreturn } 159