336 lines · plain
1; RUN: opt %s -passes=instcombine -S -mtriple=i386-pc-windows-msvc18 | FileCheck %s --check-prefixes=CHECK,MSVCXX,MSVC322; RUN: opt %s -passes=instcombine -S -mtriple=i386-pc-windows-msvc | FileCheck %s --check-prefixes=CHECK,MSVC19,MSVC513; RUN: opt %s -passes=instcombine -S -mtriple=x86_64-pc-windows-msvc17 | FileCheck %s --check-prefixes=CHECK,MSVCXX,MSVC644; RUN: opt %s -passes=instcombine -S -mtriple=x86_64-pc-win32 | FileCheck %s --check-prefixes=CHECK,MSVC19,MSVC835; RUN: opt %s -passes=instcombine -S -mtriple=i386-pc-mingw32 | FileCheck %s --check-prefixes=CHECK,MINGW326; RUN: opt %s -passes=instcombine -S -mtriple=x86_64-pc-mingw32 | FileCheck %s --check-prefixes=CHECK,MINGW647 8; x86 win32 msvcrt does not provide entry points for single-precision libm.9; x86-64 win32 msvcrt does, but with exceptions10; msvcrt does not provide all of C99 math, but mingw32 does.11 12declare double @acos(double %x)13define float @float_acos(float %x) nounwind readnone {14; CHECK-LABEL: @float_acos(15; MSVCXX-NOT: float @acosf16; MSVCXX: double @acos17; MSVC19-NOT: float @acosf18; MSVC19: double @acos19 %1 = fpext float %x to double20 %2 = call double @acos(double %1)21 %3 = fptrunc double %2 to float22 ret float %323}24 25declare double @asin(double %x)26define float @float_asin(float %x) nounwind readnone {27; CHECK-LABEL: @float_asin(28; MSVCXX-NOT: float @asinf29; MSVCXX: double @asin30; MSVC19-NOT: float @asinf31; MSVC19: double @asin32 %1 = fpext float %x to double33 %2 = call double @asin(double %1)34 %3 = fptrunc double %2 to float35 ret float %336}37 38declare double @atan(double %x)39define float @float_atan(float %x) nounwind readnone {40; CHECK-LABEL: @float_atan(41; MSVCXX-NOT: float @atanf42; MSVCXX: double @atan43; MSVC19-NOT: float @atanf44; MSVC19: double @atan45 %1 = fpext float %x to double46 %2 = call double @atan(double %1)47 %3 = fptrunc double %2 to float48 ret float %349}50 51declare double @atan2(double %x, double %y)52define float @float_atan2(float %x, float %y) nounwind readnone {53; CHECK-LABEL: @float_atan2(54; MSVCXX-NOT: float @atan2f55; MSVCXX: double @atan256; MSVC19-NOT: float @atan2f57; MSVC19: double @atan258 %1 = fpext float %x to double59 %2 = fpext float %y to double60 %3 = call double @atan2(double %1, double %2)61 %4 = fptrunc double %3 to float62 ret float %463}64 65declare double @ceil(double %x)66define float @float_ceil(float %x) nounwind readnone {67; CHECK-LABEL: @float_ceil(68; MSVCXX-NOT: float @ceilf69; MSVCXX: float @llvm.ceil.f3270; MSVC19-NOT: double @ceil71; MSVC19: float @llvm.ceil.f3272; MINGW32-NOT: double @ceil73; MINGW32: float @llvm.ceil.f3274; MINGW64-NOT: double @ceil75; MINGW64: float @llvm.ceil.f3276 %1 = fpext float %x to double77 %2 = call double @ceil(double %1)78 %3 = fptrunc double %2 to float79 ret float %380}81 82declare double @_copysign(double %x)83define float @float_copysign(float %x) nounwind readnone {84; CHECK-LABEL: @float_copysign(85; MSVCXX-NOT: float @_copysignf86; MSVCXX: double @_copysign87; MSVC19-NOT: float @_copysignf88; MSVC19: double @_copysign89 %1 = fpext float %x to double90 %2 = call double @_copysign(double %1)91 %3 = fptrunc double %2 to float92 ret float %393}94 95declare double @cos(double %x)96define float @float_cos(float %x) nounwind readnone {97; CHECK-LABEL: @float_cos(98; MSVCXX-NOT: float @cosf99; MSVCXX: double @cos100; MSVC19-NOT: float @cosf101; MSVC19: double @cos102 %1 = fpext float %x to double103 %2 = call double @cos(double %1)104 %3 = fptrunc double %2 to float105 ret float %3106}107 108declare double @cosh(double %x)109define float @float_cosh(float %x) nounwind readnone {110; CHECK-LABEL: @float_cosh(111; MSVCXX-NOT: float @coshf112; MSVCXX: double @cosh113; MSVC19-NOT: float @coshf114; MSVC19: double @cosh115 %1 = fpext float %x to double116 %2 = call double @cosh(double %1)117 %3 = fptrunc double %2 to float118 ret float %3119}120 121declare double @exp(double %x, double %y)122define float @float_exp(float %x, float %y) nounwind readnone {123; CHECK-LABEL: @float_exp(124; MSVCXX-NOT: float @expf125; MSVCXX: double @exp126; MSVC19-NOT: float @expf127; MSVC19: double @exp128 %1 = fpext float %x to double129 %2 = fpext float %y to double130 %3 = call double @exp(double %1, double %2)131 %4 = fptrunc double %3 to float132 ret float %4133}134 135declare double @fabs(double %x, double %y)136define float @float_fabs(float %x, float %y) nounwind readnone {137; CHECK-LABEL: @float_fabs(138; MSVCXX-NOT: float @fabsf139; MSVCXX: double @fabs140; MSVC19-NOT: float @fabsf141; MSVC19: double @fabs142 %1 = fpext float %x to double143 %2 = fpext float %y to double144 %3 = call double @fabs(double %1, double %2)145 %4 = fptrunc double %3 to float146 ret float %4147}148 149declare double @floor(double %x)150define float @float_floor(float %x) nounwind readnone {151; CHECK-LABEL: @float_floor(152; MSVCXX-NOT: float @floorf153; MSVCXX: float @llvm.floor.f32154; MSVC19-NOT: double @floor155; MSVC19: float @llvm.floor.f32156; MINGW32-NOT: double @floor157; MINGW32: float @llvm.floor.f32158; MINGW64-NOT: double @floor159; MINGW64: float @llvm.floor.f32160 %1 = fpext float %x to double161 %2 = call double @floor(double %1)162 %3 = fptrunc double %2 to float163 ret float %3164}165 166declare double @fmod(double %x, double %y)167define float @float_fmod(float %x, float %y) nounwind readnone {168; MSVCXX-LABEL: @float_fmod(169; MSVCXX-NOT: float @fmodf170; MSVCXX: double @fmod171; MSVC19-NOT: float @fmodf172; MSVC19: double @fmod173 %1 = fpext float %x to double174 %2 = fpext float %y to double175 %3 = call double @fmod(double %1, double %2)176 %4 = fptrunc double %3 to float177 ret float %4178}179 180declare double @log(double %x)181define float @float_log(float %x) nounwind readnone {182; CHECK-LABEL: @float_log(183; MSVCXX-NOT: float @logf184; MSVCXX: double @log185; MSVC19-NOT: float @logf186; MSVC19: double @log187 %1 = fpext float %x to double188 %2 = call double @log(double %1)189 %3 = fptrunc double %2 to float190 ret float %3191}192 193declare double @logb(double %x)194define float @float_logb(float %x) nounwind readnone {195; CHECK-LABEL: @float_logb(196; MSVCXX-NOT: float @logbf197; MSVCXX: double @logb198; MSVC19-NOT: float @logbf199; MSVC19: double @logb200 %1 = fpext float %x to double201 %2 = call double @logb(double %1)202 %3 = fptrunc double %2 to float203 ret float %3204}205 206declare double @pow(double %x, double %y)207define float @float_pow(float %x, float %y) nounwind readnone {208; CHECK-LABEL: @float_pow(209; MSVCXX-NOT: float @powf210; MSVCXX: double @pow211; MSVC19-NOT: float @powf212; MSVC19: double @pow213 %1 = fpext float %x to double214 %2 = fpext float %y to double215 %3 = call double @pow(double %1, double %2)216 %4 = fptrunc double %3 to float217 ret float %4218}219 220declare double @sin(double %x)221define float @float_sin(float %x) nounwind readnone {222; CHECK-LABEL: @float_sin(223; MSVCXX-NOT: float @sinf224; MSVCXX: double @sin225; MSVC19-NOT: float @sinf226; MSVC19: double @sin227 %1 = fpext float %x to double228 %2 = call double @sin(double %1)229 %3 = fptrunc double %2 to float230 ret float %3231}232 233declare double @sinh(double %x)234define float @float_sinh(float %x) nounwind readnone {235; CHECK-LABEL: @float_sinh(236; MSVCXX-NOT: float @sinhf237; MSVCXX: double @sinh238; MSVC19-NOT: float @sinhf239; MSVC19: double @sinh240 %1 = fpext float %x to double241 %2 = call double @sinh(double %1)242 %3 = fptrunc double %2 to float243 ret float %3244}245 246declare double @sqrt(double %x)247define float @float_sqrt(float %x) nounwind readnone {248; CHECK-LABEL: @float_sqrt(249; MSVC32-NOT: float @sqrtf250; MSVC32: double @sqrt251; MSVC51-NOT: float @sqrtf252; MSVC51: double @sqrt253; MSVC64-NOT: double @sqrt254; MSVC64: float @sqrtf255; MSVC83-NOT: double @sqrt256; MSVC83: float @sqrtf257; MINGW32-NOT: double @sqrt258; MINGW32: float @sqrtf259; MINGW64-NOT: double @sqrt260; MINGW64: float @sqrtf261 %1 = fpext float %x to double262 %2 = call double @sqrt(double %1)263 %3 = fptrunc double %2 to float264 ret float %3265}266 267declare double @tan(double %x)268define float @float_tan(float %x) nounwind readnone {269; CHECK-LABEL: @float_tan(270; MSVCXX-NOT: float @tanf271; MSVCXX: double @tan272; MSVC19-NOT: float @tanf273; MSVC19: double @tan274 %1 = fpext float %x to double275 %2 = call double @tan(double %1)276 %3 = fptrunc double %2 to float277 ret float %3278}279 280declare double @tanh(double %x)281define float @float_tanh(float %x) nounwind readnone {282; CHECK-LABEL: @float_tanh(283; MSVCXX-NOT: float @tanhf284; MSVCXX: double @tanh285; MSVC19-NOT: float @tanhf286; MSVC19: double @tanh287 %1 = fpext float %x to double288 %2 = call double @tanh(double %1)289 %3 = fptrunc double %2 to float290 ret float %3291}292 293; win32 does not have roundf; mingw32 does294declare double @round(double %x)295define float @float_round(float %x) nounwind readnone {296; CHECK-LABEL: @float_round(297; MSVCXX-NOT: double @roundf298; MSVCXX: double @round299; MSVC19-NOT: double @round300; MSVC19: float @llvm.round.f32301; MINGW32-NOT: double @round302; MINGW32: float @llvm.round.f32303; MINGW64-NOT: double @round304; MINGW64: float @llvm.round.f32305 %1 = fpext float %x to double306 %2 = call double @round(double %1)307 %3 = fptrunc double %2 to float308 ret float %3309}310 311declare float @powf(float, float)312 313; win32 lacks sqrtf & fabsf, win64 lacks fabsf, but314; calls to the intrinsics can be emitted instead.315define float @float_powsqrt(float %x) nounwind readnone {316; CHECK-LABEL: @float_powsqrt(317; MSVC32-NOT: float @sqrtf318; MSVC32: float @powf319; MSVC51-NOT: float @sqrtf320; MSVC51: float @powf321; MSVC64-NOT: float @powf322; MSVC64: float @sqrtf323; MSVC64: float @llvm.fabs.f32(324; MSVC83-NOT: float @powf325; MSVC83: float @sqrtf326; MSVC83: float @llvm.fabs.f32(327; MINGW32-NOT: float @powf328; MINGW32: float @sqrtf329; MINGW32: float @llvm.fabs.f32330; MINGW64-NOT: float @powf331; MINGW64: float @sqrtf332; MINGW64: float @llvm.fabs.f32(333 %1 = call ninf float @powf(float %x, float 0.5)334 ret float %1335}336