From 98f356cd74ad9c2323c3dabd28f5d58fb6151adb Mon Sep 17 00:00:00 2001 From: Evandro Menezes Date: Mon, 4 Feb 2019 23:34:50 +0000 Subject: [PATCH] Revert "[PATCH] [TargetLibraryInfo] Update run time support for Windows" This reverts accidental commit ff5527718d5d3b9966f6e8948866c0dc15ffcf3c. llvm-svn: 353118 --- llvm/lib/Analysis/TargetLibraryInfo.cpp | 112 ++++++++++----------- .../InstCombine/double-float-shrink-1.ll | 12 +-- .../InstCombine/double-float-shrink-2.ll | 57 ++++++++--- llvm/test/Transforms/InstCombine/pow-1.ll | 16 +-- llvm/test/Transforms/InstCombine/win-math.ll | 37 +++---- 5 files changed, 126 insertions(+), 108 deletions(-) diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp index 050a73e..e0ee8d4 100644 --- a/llvm/lib/Analysis/TargetLibraryInfo.cpp +++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp @@ -160,39 +160,7 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, } if (T.isOSWindows() && !T.isOSCygMing()) { - bool is64 = (T.getArch() == Triple::aarch64 || - T.getArch() == Triple::x86_64); - - // Win32 does not support float math functions, in general. - if (!is64) { - TLI.setUnavailable(LibFunc_acosf); - TLI.setUnavailable(LibFunc_asinf); - TLI.setUnavailable(LibFunc_atanf); - TLI.setUnavailable(LibFunc_atan2f); - TLI.setUnavailable(LibFunc_ceilf); - TLI.setUnavailable(LibFunc_cosf); - TLI.setUnavailable(LibFunc_coshf); - TLI.setUnavailable(LibFunc_expf); - TLI.setUnavailable(LibFunc_floorf); - TLI.setUnavailable(LibFunc_fmodf); - TLI.setUnavailable(LibFunc_logf); - TLI.setUnavailable(LibFunc_log10f); - TLI.setUnavailable(LibFunc_modff); - TLI.setUnavailable(LibFunc_powf); - TLI.setUnavailable(LibFunc_sinf); - TLI.setUnavailable(LibFunc_sinhf); - TLI.setUnavailable(LibFunc_sqrtf); - TLI.setUnavailable(LibFunc_tanf); - TLI.setUnavailable(LibFunc_tanhf); - } - TLI.setUnavailable(LibFunc_copysignf); - TLI.setUnavailable(LibFunc_fabsf); - TLI.setUnavailable(LibFunc_fmaxf); - TLI.setUnavailable(LibFunc_fminf); - TLI.setUnavailable(LibFunc_frexpf); - TLI.setUnavailable(LibFunc_ldexpf); - - // Win32 does not support long double. + // Win32 does not support long double TLI.setUnavailable(LibFunc_acosl); TLI.setUnavailable(LibFunc_asinl); TLI.setUnavailable(LibFunc_atanl); @@ -202,15 +170,16 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, TLI.setUnavailable(LibFunc_cosl); TLI.setUnavailable(LibFunc_coshl); TLI.setUnavailable(LibFunc_expl); + TLI.setUnavailable(LibFunc_fabsf); // Win32 and Win64 both lack fabsf TLI.setUnavailable(LibFunc_fabsl); TLI.setUnavailable(LibFunc_floorl); TLI.setUnavailable(LibFunc_fmaxl); TLI.setUnavailable(LibFunc_fminl); TLI.setUnavailable(LibFunc_fmodl); TLI.setUnavailable(LibFunc_frexpl); + TLI.setUnavailable(LibFunc_ldexpf); TLI.setUnavailable(LibFunc_ldexpl); TLI.setUnavailable(LibFunc_logl); - TLI.setUnavailable(LibFunc_log10l); TLI.setUnavailable(LibFunc_modfl); TLI.setUnavailable(LibFunc_powl); TLI.setUnavailable(LibFunc_sinl); @@ -219,61 +188,80 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, TLI.setUnavailable(LibFunc_tanl); TLI.setUnavailable(LibFunc_tanhl); - // Win32 does not support C89 math functions, in general. - // acosh + // Win32 only has C89 math + TLI.setUnavailable(LibFunc_acosh); TLI.setUnavailable(LibFunc_acoshf); TLI.setUnavailable(LibFunc_acoshl); - // asinh + TLI.setUnavailable(LibFunc_asinh); TLI.setUnavailable(LibFunc_asinhf); TLI.setUnavailable(LibFunc_asinhl); - // atanh + TLI.setUnavailable(LibFunc_atanh); TLI.setUnavailable(LibFunc_atanhf); TLI.setUnavailable(LibFunc_atanhl); TLI.setUnavailable(LibFunc_cabs); TLI.setUnavailable(LibFunc_cabsf); TLI.setUnavailable(LibFunc_cabsl); - // cbrt + TLI.setUnavailable(LibFunc_cbrt); TLI.setUnavailable(LibFunc_cbrtf); TLI.setUnavailable(LibFunc_cbrtl); - // exp2 + TLI.setUnavailable(LibFunc_exp2); TLI.setUnavailable(LibFunc_exp2f); TLI.setUnavailable(LibFunc_exp2l); - // expm1 + TLI.setUnavailable(LibFunc_expm1); TLI.setUnavailable(LibFunc_expm1f); TLI.setUnavailable(LibFunc_expm1l); - // log1p - TLI.setUnavailable(LibFunc_log1pf); - TLI.setUnavailable(LibFunc_log1pl); - // log2 + TLI.setUnavailable(LibFunc_log2); TLI.setUnavailable(LibFunc_log2f); TLI.setUnavailable(LibFunc_log2l); - // logb - if (!is64) - TLI.setUnavailable(LibFunc_logbf); + TLI.setUnavailable(LibFunc_log1p); + TLI.setUnavailable(LibFunc_log1pf); + TLI.setUnavailable(LibFunc_log1pl); + TLI.setUnavailable(LibFunc_logb); + TLI.setUnavailable(LibFunc_logbf); TLI.setUnavailable(LibFunc_logbl); - // nearbyint + TLI.setUnavailable(LibFunc_nearbyint); TLI.setUnavailable(LibFunc_nearbyintf); TLI.setUnavailable(LibFunc_nearbyintl); - // rint + TLI.setUnavailable(LibFunc_rint); TLI.setUnavailable(LibFunc_rintf); TLI.setUnavailable(LibFunc_rintl); - // round + TLI.setUnavailable(LibFunc_round); TLI.setUnavailable(LibFunc_roundf); TLI.setUnavailable(LibFunc_roundl); - // trunc + TLI.setUnavailable(LibFunc_trunc); TLI.setUnavailable(LibFunc_truncf); TLI.setUnavailable(LibFunc_truncl); - // Win32 supports some C89 and C99 math functions, but with mangled names. + // Win32 provides some C99 math with mangled names TLI.setAvailableWithName(LibFunc_copysign, "_copysign"); - if (is64) - TLI.setAvailableWithName(LibFunc_logbf, "_logbf"); - // Win32 does not support these C99 functions. - TLI.setUnavailable(LibFunc_atoll); - TLI.setUnavailable(LibFunc_llabs); + if (T.getArch() == Triple::x86) { + // Win32 on x86 implements single-precision math functions as macros + TLI.setUnavailable(LibFunc_acosf); + TLI.setUnavailable(LibFunc_asinf); + TLI.setUnavailable(LibFunc_atanf); + TLI.setUnavailable(LibFunc_atan2f); + TLI.setUnavailable(LibFunc_ceilf); + TLI.setUnavailable(LibFunc_copysignf); + TLI.setUnavailable(LibFunc_cosf); + TLI.setUnavailable(LibFunc_coshf); + TLI.setUnavailable(LibFunc_expf); + TLI.setUnavailable(LibFunc_floorf); + TLI.setUnavailable(LibFunc_fminf); + TLI.setUnavailable(LibFunc_fmaxf); + TLI.setUnavailable(LibFunc_fmodf); + TLI.setUnavailable(LibFunc_logf); + TLI.setUnavailable(LibFunc_log10f); + TLI.setUnavailable(LibFunc_modff); + TLI.setUnavailable(LibFunc_powf); + TLI.setUnavailable(LibFunc_sinf); + TLI.setUnavailable(LibFunc_sinhf); + TLI.setUnavailable(LibFunc_sqrtf); + TLI.setUnavailable(LibFunc_tanf); + TLI.setUnavailable(LibFunc_tanhf); + } - // Win32 does not support these functions, but they are + // Win32 does *not* provide these functions, but they are // generally available on POSIX-compliant systems: TLI.setUnavailable(LibFunc_access); TLI.setUnavailable(LibFunc_bcmp); @@ -329,6 +317,12 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, TLI.setUnavailable(LibFunc_utime); TLI.setUnavailable(LibFunc_utimes); TLI.setUnavailable(LibFunc_write); + + // Win32 does *not* provide provide these functions, but they are + // specified by C99: + TLI.setUnavailable(LibFunc_atoll); + TLI.setUnavailable(LibFunc_frexpf); + TLI.setUnavailable(LibFunc_llabs); } switch (T.getOS()) { diff --git a/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll b/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll index 84af12d..e3dc6bb 100644 --- a/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll +++ b/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll @@ -335,9 +335,9 @@ define double @log2_test2(float %f) { define float @logb_test1(float %f) { ; CHECK-LABEL: @logb_test1( -; LIN64-NEXT: [[LOGBF:%.*]] = call fast float @logbf(float [[F:%.*]]) -; LIN64-NEXT: ret float [[LOGBF]] -; WIN32: [[LOGBF:%.*]] = call fast double @logb(double [[F:%.*]]) +; LINUX-NEXT: [[LOGBF:%.*]] = call fast float @logbf(float [[F:%.*]]) +; LINUX-NEXT: ret float [[LOGBF]] +; WIN96: [[LOGBF:%.*]] = call fast double @logb(double [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @logb(double %conv) @@ -498,9 +498,9 @@ define double @tanh_test2(float %f) { ; flags are propagated for shrunken *binary* double FP calls. define float @max1(float %a, float %b) { ; CHECK-LABEL: @max1( -; LINUX-NEXT: [[FMAXF:%.*]] = call arcp float @fmaxf(float [[A:%.*]], float [[B:%.*]]) -; LINUX-NEXT: ret float [[FMAXF]] -; WIN96: [[FMAXF:%.*]] = call arcp double @fmax(double [[A:%.*]], double [[B:%.*]]) +; LIN64-NEXT: [[FMAXF:%.*]] = call arcp float @fmaxf(float [[A:%.*]], float [[B:%.*]]) +; LIN64-NEXT: ret float [[FMAXF]] +; WIN32: [[FMAXF:%.*]] = call arcp double @fmax(double [[A:%.*]], double [[B:%.*]]) ; %c = fpext float %a to double %d = fpext float %b to double diff --git a/llvm/test/Transforms/InstCombine/double-float-shrink-2.ll b/llvm/test/Transforms/InstCombine/double-float-shrink-2.ll index 76e497b..d509953 100644 --- a/llvm/test/Transforms/InstCombine/double-float-shrink-2.ll +++ b/llvm/test/Transforms/InstCombine/double-float-shrink-2.ll @@ -1,10 +1,10 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -instcombine -S -mtriple "i386-pc-linux" | FileCheck %s -; RUN: opt < %s -instcombine -S -mtriple "i386-pc-win32" | FileCheck %s -; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-win32" | FileCheck %s -; RUN: opt < %s -instcombine -S -mtriple "i386-pc-mingw32" | FileCheck %s -; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-mingw32" | FileCheck %s -; RUN: opt < %s -instcombine -S -mtriple "sparc-sun-solaris" | FileCheck %s +; RUN: opt < %s -instcombine -S -mtriple "i386-pc-linux" | FileCheck --check-prefixes=CHECK,DO-SIMPLIFY %s +; RUN: opt < %s -instcombine -S -mtriple "i386-pc-win32" | FileCheck --check-prefixes=CHECK,DONT-SIMPLIFY %s +; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-win32" | FileCheck --check-prefixes=CHECK,C89-SIMPLIFY %s +; RUN: opt < %s -instcombine -S -mtriple "i386-pc-mingw32" | FileCheck --check-prefixes=CHECK,DO-SIMPLIFY %s +; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-mingw32" | FileCheck --check-prefixes=CHECK,DO-SIMPLIFY %s +; RUN: opt < %s -instcombine -S -mtriple "sparc-sun-solaris" | FileCheck --check-prefixes=CHECK,DO-SIMPLIFY %s ; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-win32" -enable-debugify 2>&1 | FileCheck --check-prefix=DBG-VALID %s declare double @floor(double) @@ -61,8 +61,19 @@ define float @test_shrink_libcall_ceil(float %C) { define float @test_shrink_libcall_round(float %C) { ; CHECK-LABEL: @test_shrink_libcall_round( -; CHECK-NEXT: [[F:%.*]] = call float @llvm.round.f32(float [[C:%.*]]) -; CHECK-NEXT: ret float [[F]] + +; DO-SIMPLIFY-NEXT: [[F:%.*]] = call float @llvm.round.f32(float [[C:%.*]]) +; DO-SIMPLIFY-NEXT: ret float [[F]] +; +; DONT-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double +; DONT-SIMPLIFY-NEXT: [[E:%.*]] = call double @round(double [[D]]) +; DONT-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float +; DONT-SIMPLIFY-NEXT: ret float [[F]] +; +; C89-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double +; C89-SIMPLIFY-NEXT: [[E:%.*]] = call double @round(double [[D]]) +; C89-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float +; C89-SIMPLIFY-NEXT: ret float [[F]] ; %D = fpext float %C to double ; --> roundf @@ -73,8 +84,19 @@ define float @test_shrink_libcall_round(float %C) { define float @test_shrink_libcall_nearbyint(float %C) { ; CHECK-LABEL: @test_shrink_libcall_nearbyint( -; CHECK-NEXT: [[F:%.*]] = call float @llvm.nearbyint.f32(float [[C:%.*]]) -; CHECK-NEXT: ret float [[F]] + +; DO-SIMPLIFY-NEXT: [[F:%.*]] = call float @llvm.nearbyint.f32(float [[C:%.*]]) +; DO-SIMPLIFY-NEXT: ret float [[F]] +; +; DONT-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double +; DONT-SIMPLIFY-NEXT: [[E:%.*]] = call double @nearbyint(double [[D]]) +; DONT-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float +; DONT-SIMPLIFY-NEXT: ret float [[F]] +; +; C89-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double +; C89-SIMPLIFY-NEXT: [[E:%.*]] = call double @nearbyint(double [[D]]) +; C89-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float +; C89-SIMPLIFY-NEXT: ret float [[F]] ; %D = fpext float %C to double ; --> nearbyintf @@ -85,8 +107,19 @@ define float @test_shrink_libcall_nearbyint(float %C) { define float @test_shrink_libcall_trunc(float %C) { ; CHECK-LABEL: @test_shrink_libcall_trunc( -; CHECK-NEXT: [[F:%.*]] = call float @llvm.trunc.f32(float [[C:%.*]]) -; CHECK-NEXT: ret float [[F]] + +; DO-SIMPLIFY-NEXT: [[F:%.*]] = call float @llvm.trunc.f32(float [[C:%.*]]) +; DO-SIMPLIFY-NEXT: ret float [[F]] +; +; DONT-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double +; DONT-SIMPLIFY-NEXT: [[E:%.*]] = call double @trunc(double [[D]]) +; DONT-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float +; DONT-SIMPLIFY-NEXT: ret float [[F]] +; +; C89-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double +; C89-SIMPLIFY-NEXT: [[E:%.*]] = call double @trunc(double [[D]]) +; C89-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float +; C89-SIMPLIFY-NEXT: ret float [[F]] ; %D = fpext float %C to double ; --> truncf diff --git a/llvm/test/Transforms/InstCombine/pow-1.ll b/llvm/test/Transforms/InstCombine/pow-1.ll index 868450c..85f61b8 100644 --- a/llvm/test/Transforms/InstCombine/pow-1.ll +++ b/llvm/test/Transforms/InstCombine/pow-1.ll @@ -73,9 +73,11 @@ define float @test_simplify3(float %x) { define double @test_simplify3n(double %x) { ; CHECK-LABEL: @test_simplify3n( -; CHECK-NEXT: [[MUL:%.*]] = fmul double [[X:%.*]], -2.000000e+00 -; CHECK-NEXT: [[EXP2:%.*]] = call double @exp2(double [[MUL]]) [[NUW_RO:#[0-9]+]] -; CHECK-NEXT: ret double [[EXP2]] +; ANY-NEXT: [[MUL:%.*]] = fmul double [[X:%.*]], -2.000000e+00 +; ANY-NEXT: [[EXP2:%.*]] = call double @exp2(double [[MUL]]) [[NUW_RO]] +; ANY-NEXT: ret double [[EXP2]] +; WIN-NEXT: [[POW:%.*]] = call double @pow(double 2.500000e-01, double [[X:%.*]]) +; WIN-NEXT: ret double [[POW]] ; %retval = call double @pow(double 0.25, double %x) ret double %retval @@ -106,8 +108,10 @@ define <2 x double> @test_simplify3vn(<2 x double> %x) { define double @test_simplify4(double %x) { ; CHECK-LABEL: @test_simplify4( -; CHECK-NEXT: [[EXP2:%.*]] = call double @exp2(double [[X:%.*]]) [[NUW_RO]] -; CHECK-NEXT: ret double [[EXP2]] +; ANY-NEXT: [[EXP2:%.*]] = call double @exp2(double [[X:%.*]]) [[NUW_RO]] +; ANY-NEXT: ret double [[EXP2]] +; WIN-NEXT: [[POW:%.*]] = call double @pow(double 2.000000e+00, double [[X:%.*]]) +; WIN-NEXT: ret double [[POW]] ; %retval = call double @pow(double 2.0, double %x) ret double %retval @@ -191,7 +195,7 @@ define <2 x double> @test_simplify6v(<2 x double> %x) { define float @test_simplify7(float %x) { ; CHECK-LABEL: @test_simplify7( ; ANY-NEXT: [[SQRTF:%.*]] = call float @sqrtf(float [[X:%.*]]) [[NUW_RO]] -; WIN-NEXT: [[SQRTF:%.*]] = call float @sqrtf(float [[X:%.*]]) [[NUW_RO]] +; WIN-NEXT: [[SQRTF:%.*]] = call float @sqrtf(float [[X:%.*]]) [[NUW_RO:#[0-9]+]] ; CHECK-NEXT: [[ABS:%.*]] = call float @llvm.fabs.f32(float [[SQRTF]]) ; CHECK-NEXT: [[ISINF:%.*]] = fcmp oeq float [[X]], 0xFFF0000000000000 ; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[ISINF]], float 0x7FF0000000000000, float [[ABS]] diff --git a/llvm/test/Transforms/InstCombine/win-math.ll b/llvm/test/Transforms/InstCombine/win-math.ll index e305596..4f774e5 100644 --- a/llvm/test/Transforms/InstCombine/win-math.ll +++ b/llvm/test/Transforms/InstCombine/win-math.ll @@ -1,11 +1,11 @@ -; RUN: opt < %s -O2 -S -mtriple=i386-pc-win32 | FileCheck %s --check-prefixes=CHECK,WIN32 -; RUN: opt < %s -O2 -S -mtriple=x86_64-pc-win32 | FileCheck %s --check-prefixes=CHECK,WIN64 -; RUN: opt < %s -O2 -S -mtriple=i386-pc-mingw32 | FileCheck %s --check-prefixes=CHECK,MINGW32 -; RUN: opt < %s -O2 -S -mtriple=x86_64-pc-mingw32 | FileCheck %s --check-prefixes=CHECK,MINGW64 +; RUN: opt -O2 -S -mtriple=i386-pc-win32 < %s | FileCheck %s --check-prefixes=CHECK,WIN32 +; RUN: opt -O2 -S -mtriple=x86_64-pc-win32 < %s | FileCheck %s --check-prefixes=CHECK,WIN64 +; RUN: opt -O2 -S -mtriple=i386-pc-mingw32 < %s | FileCheck %s --check-prefixes=CHECK,MINGW32 +; RUN: opt -O2 -S -mtriple=x86_64-pc-mingw32 < %s | FileCheck %s --check-prefixes=CHECK,MINGW64 ; x86 win32 msvcrt does not provide entry points for single-precision libm. -; x86-64 win32 msvcrt does, but with exceptions -; msvcrt does not provide all of C99 math, but mingw32 does. +; x86-64 win32 msvcrt does (except for fabsf) +; msvcrt does not provide C99 math, but mingw32 does. declare double @acos(double %x) define float @float_acos(float %x) nounwind readnone { @@ -188,19 +188,6 @@ define float @float_log(float %x) nounwind readnone { ret float %3 } -declare double @logb(double %x) -define float @float_logb(float %x) nounwind readnone { -; CHECK-LABEL: @float_logb( -; WIN32-NOT: float @logbf -; WIN32: double @logb -; WIN64-NOT: float @logbf -; WIN64: double @logb - %1 = fpext float %x to double - %2 = call double @logb(double %1) - %3 = fptrunc double %2 to float - ret float %3 -} - declare double @pow(double %x, double %y) define float @float_pow(float %x, float %y) nounwind readnone { ; CHECK-LABEL: @float_pow( @@ -284,14 +271,14 @@ define float @float_tanh(float %x) nounwind readnone { ret float %3 } -; win32 does not have roundf; mingw32 does +; win32 does not have round; mingw32 does declare double @round(double %x) define float @float_round(float %x) nounwind readnone { ; CHECK-LABEL: @float_round( -; WIN32-NOT: double @round -; WIN32: float @llvm.round.f32 -; WIN64-NOT: double @round -; WIN64: float @llvm.round.f32 +; WIN32-NOT: float @roundf +; WIN32: double @round +; WIN64-NOT: float @roundf +; WIN64: double @round ; MINGW32-NOT: double @round ; MINGW32: float @llvm.round.f32 ; MINGW64-NOT: double @round @@ -304,7 +291,7 @@ define float @float_round(float %x) nounwind readnone { declare float @powf(float, float) -; win32 lacks sqrtf & fabsf, win64 lacks fabsf, but +; win32 lacks sqrtf&fabsf, win64 lacks fabsf, but ; calls to the intrinsics can be emitted instead. define float @float_powsqrt(float %x) nounwind readnone { ; CHECK-LABEL: @float_powsqrt( -- 2.7.4