From: Evandro Menezes Date: Mon, 11 Feb 2019 22:12:01 +0000 (+0000) Subject: [TargetLibraryInfo] Update run time support for Windows X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=12946fbd9dbd3a1dd38c0e26b4263b94b3b0a523;p=llvm [TargetLibraryInfo] Update run time support for Windows It seems that, since VC19, the `float` C99 math functions are supported for all targets, unlike the C89 ones. According to the discussion at https://reviews.llvm.org/D57625. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353758 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/TargetLibraryInfo.cpp b/lib/Analysis/TargetLibraryInfo.cpp index 608ac6680e6..29e460ec785 100644 --- a/lib/Analysis/TargetLibraryInfo.cpp +++ b/lib/Analysis/TargetLibraryInfo.cpp @@ -172,26 +172,26 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, hasPartialC99 = (Major == 0 || Major >= 19); } - // Latest targets support float math functions, in part. - bool hasPartialFloat = (T.getArch() == Triple::aarch64 || - T.getArch() == Triple::arm || + // Latest targets support C89 math functions, in part. + bool isARM = (T.getArch() == Triple::aarch64 || + T.getArch() == Triple::arm); + bool hasPartialFloat = (isARM || T.getArch() == Triple::x86_64); - // Win32 does not support float math functions, in general. + // Win32 does not support float C89 math functions, in general. if (!hasPartialFloat) { TLI.setUnavailable(LibFunc_acosf); TLI.setUnavailable(LibFunc_asinf); - TLI.setUnavailable(LibFunc_atanf); TLI.setUnavailable(LibFunc_atan2f); + TLI.setUnavailable(LibFunc_atanf); 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_fmodf); - TLI.setUnavailable(LibFunc_logf); TLI.setUnavailable(LibFunc_log10f); + TLI.setUnavailable(LibFunc_logf); TLI.setUnavailable(LibFunc_modff); TLI.setUnavailable(LibFunc_powf); TLI.setUnavailable(LibFunc_sinf); @@ -200,31 +200,27 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, TLI.setUnavailable(LibFunc_tanf); TLI.setUnavailable(LibFunc_tanhf); } - TLI.setUnavailable(LibFunc_fabsf); - TLI.setUnavailable(LibFunc_fmaxf); - TLI.setUnavailable(LibFunc_fminf); + if (!isARM) + TLI.setUnavailable(LibFunc_fabsf); TLI.setUnavailable(LibFunc_frexpf); TLI.setUnavailable(LibFunc_ldexpf); - // Win32 does not support long double math functions. + // Win32 does not support long double C89 math functions. TLI.setUnavailable(LibFunc_acosl); TLI.setUnavailable(LibFunc_asinl); - TLI.setUnavailable(LibFunc_atanl); TLI.setUnavailable(LibFunc_atan2l); + TLI.setUnavailable(LibFunc_atanl); TLI.setUnavailable(LibFunc_ceill); - TLI.setUnavailable(LibFunc_copysignl); TLI.setUnavailable(LibFunc_cosl); TLI.setUnavailable(LibFunc_coshl); TLI.setUnavailable(LibFunc_expl); 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_ldexpl); - TLI.setUnavailable(LibFunc_logl); TLI.setUnavailable(LibFunc_log10l); + TLI.setUnavailable(LibFunc_logl); TLI.setUnavailable(LibFunc_modfl); TLI.setUnavailable(LibFunc_powl); TLI.setUnavailable(LibFunc_sinl); @@ -236,45 +232,53 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, // Win32 does not fully support C99 math functions. if (!hasPartialC99) { TLI.setUnavailable(LibFunc_acosh); + TLI.setUnavailable(LibFunc_acoshf); TLI.setUnavailable(LibFunc_asinh); + TLI.setUnavailable(LibFunc_asinhf); TLI.setUnavailable(LibFunc_atanh); + TLI.setUnavailable(LibFunc_atanhf); + TLI.setAvailableWithName(LibFunc_cabs, "_cabs"); + TLI.setUnavailable(LibFunc_cabsf); TLI.setUnavailable(LibFunc_cbrt); + TLI.setUnavailable(LibFunc_cbrtf); + TLI.setAvailableWithName(LibFunc_copysign, "_copysign"); + TLI.setAvailableWithName(LibFunc_copysignf, "_copysignf"); TLI.setUnavailable(LibFunc_exp2); + TLI.setUnavailable(LibFunc_exp2f); TLI.setUnavailable(LibFunc_expm1); + TLI.setUnavailable(LibFunc_expm1f); + TLI.setUnavailable(LibFunc_fmax); + TLI.setUnavailable(LibFunc_fmaxf); + TLI.setUnavailable(LibFunc_fmin); + TLI.setUnavailable(LibFunc_fminf); TLI.setUnavailable(LibFunc_log1p); + TLI.setUnavailable(LibFunc_log1pf); TLI.setUnavailable(LibFunc_log2); - TLI.setUnavailable(LibFunc_logb); - TLI.setUnavailable(LibFunc_nearbyint); + TLI.setUnavailable(LibFunc_log2f); + TLI.setAvailableWithName(LibFunc_logb, "_logb"); + if (hasPartialFloat) + TLI.setAvailableWithName(LibFunc_logbf, "_logbf"); + else + TLI.setUnavailable(LibFunc_logbf); TLI.setUnavailable(LibFunc_rint); + TLI.setUnavailable(LibFunc_rintf); TLI.setUnavailable(LibFunc_round); + TLI.setUnavailable(LibFunc_roundf); TLI.setUnavailable(LibFunc_trunc); + TLI.setUnavailable(LibFunc_truncf); } - // Win32 does not support float C99 math functions, in general. - TLI.setUnavailable(LibFunc_acoshf); - TLI.setUnavailable(LibFunc_asinhf); - TLI.setUnavailable(LibFunc_atanhf); - TLI.setUnavailable(LibFunc_cabsf); - TLI.setUnavailable(LibFunc_cbrtf); - TLI.setUnavailable(LibFunc_exp2f); - TLI.setUnavailable(LibFunc_expm1f); - TLI.setUnavailable(LibFunc_log1pf); - TLI.setUnavailable(LibFunc_log2f); - if (!hasPartialFloat || !hasPartialC99) - TLI.setUnavailable(LibFunc_logbf); - TLI.setUnavailable(LibFunc_nearbyintf); - TLI.setUnavailable(LibFunc_rintf); - TLI.setUnavailable(LibFunc_roundf); - TLI.setUnavailable(LibFunc_truncf); - // Win32 does not support long double C99 math functions. TLI.setUnavailable(LibFunc_acoshl); TLI.setUnavailable(LibFunc_asinhl); TLI.setUnavailable(LibFunc_atanhl); TLI.setUnavailable(LibFunc_cabsl); TLI.setUnavailable(LibFunc_cbrtl); + TLI.setUnavailable(LibFunc_copysignl); TLI.setUnavailable(LibFunc_exp2l); TLI.setUnavailable(LibFunc_expm1l); + TLI.setUnavailable(LibFunc_fmaxl); + TLI.setUnavailable(LibFunc_fminl); TLI.setUnavailable(LibFunc_log1pl); TLI.setUnavailable(LibFunc_log2l); TLI.setUnavailable(LibFunc_logbl); @@ -283,18 +287,6 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, TLI.setUnavailable(LibFunc_roundl); TLI.setUnavailable(LibFunc_truncl); - // Win32 supports some C89 and C99 math functions, but with mangled names. - TLI.setAvailableWithName(LibFunc_cabs, "_cabs"); - TLI.setAvailableWithName(LibFunc_copysign, "_copysign"); - if (hasPartialFloat) - TLI.setAvailableWithName(LibFunc_copysignf, "_copysignf"); - if (hasPartialFloat && hasPartialC99) - TLI.setAvailableWithName(LibFunc_logbf, "_logbf"); - - // Win32 does not support these C99 functions. - TLI.setUnavailable(LibFunc_atoll); - TLI.setUnavailable(LibFunc_llabs); - // Win32 does not support these functions, but // they are generally available on POSIX-compliant systems. TLI.setUnavailable(LibFunc_access); diff --git a/test/Transforms/InstCombine/double-float-shrink-1.ll b/test/Transforms/InstCombine/double-float-shrink-1.ll index d76c64d8ec8..e8f7f720b15 100644 --- a/test/Transforms/InstCombine/double-float-shrink-1.ll +++ b/test/Transforms/InstCombine/double-float-shrink-1.ll @@ -1,8 +1,8 @@ -; RUN: opt < %s -instcombine -S -mtriple x86_64-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK,LINUX,LINMS -; RUN: opt < %s -instcombine -S -mtriple x86_64-pc-win32 | FileCheck %s --check-prefixes=CHECK,MSVC,LINMS -; RUN: opt < %s -instcombine -S -mtriple x86_64-pc-windows-msvc16 | FileCheck %s --check-prefixes=CHECK,MSVC,MS64 -; RUN: opt < %s -instcombine -S -mtriple i386-pc-windows-msvc | FileCheck %s --check-prefixes=CHECK,MSVC,MS32 -; RUN: opt < %s -instcombine -S -mtriple i686-pc-windows-msvc17 | FileCheck %s --check-prefixes=CHECK,MSVC,MS32 +; RUN: opt < %s -instcombine -S -mtriple x86_64-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK,LINUX,ISC99 +; RUN: opt < %s -instcombine -S -mtriple x86_64-pc-win32 | FileCheck %s --check-prefixes=CHECK,ISC99 +; RUN: opt < %s -instcombine -S -mtriple x86_64-pc-windows-msvc16 | FileCheck %s --check-prefixes=CHECK,MS64,ISC89 +; RUN: opt < %s -instcombine -S -mtriple i386-pc-windows-msvc | FileCheck %s --check-prefixes=CHECK,ISC99 +; RUN: opt < %s -instcombine -S -mtriple i686-pc-windows-msvc17 | FileCheck %s --check-prefixes=CHECK,MS32,ISC89 ; Check for and against shrinkage when using the ; unsafe-fp-math function attribute on a math lib @@ -12,11 +12,10 @@ define float @acos_test1(float %f) { ; CHECK-LABEL: @acos_test1( -; LINMS-NEXT: [[ACOSF:%.*]] = call fast float @acosf(float [[F:%.*]]) -; LINMS-NEXT: ret float [[ACOSF]] -; MS64-NEXT: [[ACOSF:%.*]] = call fast float @acosf(float [[F:%.*]]) -; MS64-NEXT: ret float [[ACOSF]] +; LINUX-NEXT: [[ACOSF:%.*]] = call fast float @acosf(float [[F:%.*]]) +; LINUX-NEXT: ret float [[ACOSF]] ; MS32: [[ACOSF:%.*]] = call fast double @acos(double [[F:%.*]]) +; MS64-NEXT: [[ACOSF:%.*]] = call fast float @acosf(float [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @acos(double %conv) @@ -37,9 +36,9 @@ define double @acos_test2(float %f) { define float @acosh_test1(float %f) { ; CHECK-LABEL: @acosh_test1( -; LINUX-NEXT: [[ACOSHF:%.*]] = call fast float @acoshf(float [[F:%.*]]) -; LINUX-NEXT: ret float [[ACOSHF]] -; MSVC: [[ACOSHF:%.*]] = call fast double @acosh(double [[F:%.*]]) +; ISC99-NEXT: [[ACOSHF:%.*]] = call fast float @acoshf(float [[F:%.*]]) +; ISC99-NEXT: ret float [[ACOSHF]] +; ISC89: [[ACOSHF:%.*]] = call fast double @acosh(double [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @acosh(double %conv) @@ -60,11 +59,10 @@ define double @acosh_test2(float %f) { define float @asin_test1(float %f) { ; CHECK-LABEL: @asin_test1( -; LINMS-NEXT: [[ASINF:%.*]] = call fast float @asinf(float [[F:%.*]]) -; LINMS-NEXT: ret float [[ASINF]] -; MS64-NEXT: [[ASINF:%.*]] = call fast float @asinf(float [[F:%.*]]) -; MS64-NEXT: ret float [[ASINF]] +; LINUX-NEXT: [[ASINF:%.*]] = call fast float @asinf(float [[F:%.*]]) +; LINUX-NEXT: ret float [[ASINF]] ; MS32: [[ASINF:%.*]] = call fast double @asin(double [[F:%.*]]) +; MS64-NEXT: [[ASINF:%.*]] = call fast float @asinf(float [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @asin(double %conv) @@ -85,9 +83,9 @@ define double @asin_test2(float %f) { define float @asinh_test1(float %f) { ; CHECK-LABEL: @asinh_test1( -; LINUX-NEXT: [[ASINHF:%.*]] = call fast float @asinhf(float [[F:%.*]]) -; LINUX-NEXT: ret float [[ASINHF]] -; MSVC: [[ASINHF:%.*]] = call fast double @asinh(double [[F:%.*]]) +; ISC99-NEXT: [[ASINHF:%.*]] = call fast float @asinhf(float [[F:%.*]]) +; ISC99-NEXT: ret float [[ASINHF]] +; ISC89: [[ASINHF:%.*]] = call fast double @asinh(double [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @asinh(double %conv) @@ -108,11 +106,10 @@ define double @asinh_test2(float %f) { define float @atan_test1(float %f) { ; CHECK-LABEL: @atan_test1( -; LINMS-NEXT: [[ATANF:%.*]] = call fast float @atanf(float [[F:%.*]]) -; LINMS-NEXT: ret float [[ATANF]] -; MS64-NEXT: [[ATANF:%.*]] = call fast float @atanf(float [[F:%.*]]) -; MS64-NEXT: ret float [[ATANF]] +; LINUX-NEXT: [[ATANF:%.*]] = call fast float @atanf(float [[F:%.*]]) +; LINUX-NEXT: ret float [[ATANF]] ; MS32: [[ATANF:%.*]] = call fast double @atan(double [[F:%.*]]) +; MS64-NEXT: [[ATANF:%.*]] = call fast float @atanf(float [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @atan(double %conv) @@ -133,9 +130,9 @@ define double @atan_test2(float %f) { define float @atanh_test1(float %f) { ; CHECK-LABEL: @atanh_test1( -; LINUX-NEXT: [[ATANHF:%.*]] = call fast float @atanhf(float [[F:%.*]]) -; LINUX-NEXT: ret float [[ATANHF]] -; MSVC: [[ATANHF:%.*]] = call fast double @atanh(double [[F:%.*]]) +; ISC99-NEXT: [[ATANHF:%.*]] = call fast float @atanhf(float [[F:%.*]]) +; ISC99-NEXT: ret float [[ATANHF]] +; ISC89: [[ATANHF:%.*]] = call fast double @atanh(double [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @atanh(double %conv) @@ -156,9 +153,9 @@ define double @atanh_test2(float %f) { define float @cbrt_test1(float %f) { ; CHECK-LABEL: @cbrt_test1( -; LINUX-NEXT: [[CBRTF:%.*]] = call fast float @cbrtf(float [[F:%.*]]) -; LINUX-NEXT: ret float [[CBRTF]] -; MSVC: [[CBRTF:%.*]] = call fast double @cbrt(double [[F:%.*]]) +; ISC99-NEXT: [[CBRTF:%.*]] = call fast float @cbrtf(float [[F:%.*]]) +; ISC99-NEXT: ret float [[CBRTF]] +; ISC89: [[CBRTF:%.*]] = call fast double @cbrt(double [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @cbrt(double %conv) @@ -179,11 +176,10 @@ define double @cbrt_test2(float %f) { define float @exp_test1(float %f) { ; CHECK-LABEL: @exp_test1( -; LINMS-NEXT: [[EXPF:%.*]] = call fast float @expf(float [[F:%.*]]) -; LINMS-NEXT: ret float [[EXPF]] -; MS64-NEXT: [[EXPF:%.*]] = call fast float @expf(float [[F:%.*]]) -; MS64-NEXT: ret float [[EXPF]] +; LINUX-NEXT: [[EXPF:%.*]] = call fast float @expf(float [[F:%.*]]) +; LINUX-NEXT: ret float [[EXPF]] ; MS32: [[EXPF:%.*]] = call fast double @exp(double [[F:%.*]]) +; MS64-NEXT: [[EXPF:%.*]] = call fast float @expf(float [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @exp(double %conv) @@ -204,9 +200,9 @@ define double @exp_test2(float %f) { define float @expm1_test1(float %f) { ; CHECK-LABEL: @expm1_test1( -; LINUX-NEXT: [[EXPM1F:%.*]] = call fast float @expm1f(float [[F:%.*]]) -; LINUX-NEXT: ret float [[EXPM1F]] -; MSVC: [[EXPM1F:%.*]] = call fast double @expm1(double [[F:%.*]]) +; ISC99-NEXT: [[EXPM1F:%.*]] = call fast float @expm1f(float [[F:%.*]]) +; ISC99-NEXT: ret float [[EXPM1F]] +; ISC89: [[EXPM1F:%.*]] = call fast double @expm1(double [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @expm1(double %conv) @@ -253,11 +249,10 @@ define double @exp10_test2(float %f) { define float @log_test1(float %f) { ; CHECK-LABEL: @log_test1( -; LINMS-NEXT: [[LOGF:%.*]] = call fast float @logf(float [[F:%.*]]) -; LINMS-NEXT: ret float [[LOGF]] -; MS64-NEXT: [[LOGF:%.*]] = call fast float @logf(float [[F:%.*]]) -; MS64-NEXT: ret float [[LOGF]] +; LINUX-NEXT: [[LOGF:%.*]] = call fast float @logf(float [[F:%.*]]) +; LINUX-NEXT: ret float [[LOGF]] ; MS32: [[LOGF:%.*]] = call fast double @log(double [[F:%.*]]) +; MS64-NEXT: [[LOGF:%.*]] = call fast float @logf(float [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @log(double %conv) @@ -278,11 +273,10 @@ define double @log_test2(float %f) { define float @log10_test1(float %f) { ; CHECK-LABEL: @log10_test1( -; LINMS-NEXT: [[LOG10F:%.*]] = call fast float @log10f(float [[F:%.*]]) -; LINMS-NEXT: ret float [[LOG10F]] -; MS64-NEXT: [[LOG10F:%.*]] = call fast float @log10f(float [[F:%.*]]) -; MS64-NEXT: ret float [[LOG10F]] +; LINUX-NEXT: [[LOG10F:%.*]] = call fast float @log10f(float [[F:%.*]]) +; LINUX-NEXT: ret float [[LOG10F]] ; MS32: [[LOG10F:%.*]] = call fast double @log10(double [[F:%.*]]) +; MS64-NEXT: [[LOG10F:%.*]] = call fast float @log10f(float [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @log10(double %conv) @@ -303,9 +297,9 @@ define double @log10_test2(float %f) { define float @log1p_test1(float %f) { ; CHECK-LABEL: @log1p_test1( -; LINUX-NEXT: [[LOG1PF:%.*]] = call fast float @log1pf(float [[F:%.*]]) -; LINUX-NEXT: ret float [[LOG1PF]] -; MSVC: [[LOG1PF:%.*]] = call fast double @log1p(double [[F:%.*]]) +; ISC99-NEXT: [[LOG1PF:%.*]] = call fast float @log1pf(float [[F:%.*]]) +; ISC99-NEXT: ret float [[LOG1PF]] +; ISC89: [[LOG1PF:%.*]] = call fast double @log1p(double [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @log1p(double %conv) @@ -326,9 +320,9 @@ define double @log1p_test2(float %f) { define float @log2_test1(float %f) { ; CHECK-LABEL: @log2_test1( -; LINUX-NEXT: [[LOG2F:%.*]] = call fast float @log2f(float [[F:%.*]]) -; LINUX-NEXT: ret float [[LOG2F]] -; MSVC: [[LOG2F:%.*]] = call fast double @log2(double [[F:%.*]]) +; ISC99-NEXT: [[LOG2F:%.*]] = call fast float @log2f(float [[F:%.*]]) +; ISC99-NEXT: ret float [[LOG2F]] +; ISC89: [[LOG2F:%.*]] = call fast double @log2(double [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @log2(double %conv) @@ -349,9 +343,10 @@ define double @log2_test2(float %f) { define float @logb_test1(float %f) { ; CHECK-LABEL: @logb_test1( -; LINMS-NEXT: [[LOGBF:%.*]] = call fast float @logbf(float [[F:%.*]]) -; LINMS-NEXT: ret float [[LOGBF]] -; MS64: [[LOGBF:%.*]] = call fast double @logb(double [[F:%.*]]) +; LINUX-NEXT: [[LOGBF:%.*]] = call fast float @logbf(float [[F:%.*]]) +; LINUX-NEXT: ret float [[LOGBF]] +; MS32: [[POWF:%.*]] = call fast double @logb(double [[F:%.*]]) +; MS64-NEXT: [[LOGBF:%.*]] = call fast float @logbf(float [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @logb(double %conv) @@ -372,11 +367,10 @@ define double @logb_test2(float %f) { define float @pow_test1(float %f, float %g) { ; CHECK-LABEL: @pow_test1( -; LINMS-NEXT: [[POWF:%.*]] = call fast float @powf(float %f, float %g) -; LINMS-NEXT: ret float [[POWF]] -; MS64-NEXT: [[POWF:%.*]] = call fast float @powf(float %f, float %g) -; MS64-NEXT: ret float [[POWF]] +; LINUX-NEXT: [[POWF:%.*]] = call fast float @powf(float %f, float %g) +; LINUX-NEXT: ret float [[POWF]] ; MS32: [[POWF:%.*]] = call fast double @pow(double %df, double %dg) +; MS64-NEXT: [[POWF:%.*]] = call fast float @powf(float %f, float %g) ; %df = fpext float %f to double %dg = fpext float %g to double @@ -398,11 +392,10 @@ define double @pow_test2(float %f, float %g) { define float @sin_test1(float %f) { ; CHECK-LABEL: @sin_test1( -; LINMS-NEXT: [[SINF:%.*]] = call fast float @sinf(float [[F:%.*]]) -; LINMS-NEXT: ret float [[SINF]] -; MS64-NEXT: [[SINF:%.*]] = call fast float @sinf(float [[F:%.*]]) -; MS64-NEXT: ret float [[SINF]] +; LINUX-NEXT: [[SINF:%.*]] = call fast float @sinf(float [[F:%.*]]) +; LINUX-NEXT: ret float [[SINF]] ; MS32: [[SINF:%.*]] = call fast double @sin(double [[F:%.*]]) +; MS64-NEXT: [[SINF:%.*]] = call fast float @sinf(float [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @sin(double %conv) @@ -423,11 +416,10 @@ define double @sin_test2(float %f) { define float @sqrt_test1(float %f) { ; CHECK-LABEL: @sqrt_test1( -; LINMS-NEXT: [[SQRTF:%.*]] = call float @sqrtf(float [[F:%.*]]) -; LINMS-NEXT: ret float [[SQRTF]] -; MS64-NEXT: [[SQRTF:%.*]] = call float @sqrtf(float [[F:%.*]]) -; MS64-NEXT: ret float [[SQRTF]] +; LINUX-NEXT: [[SQRTF:%.*]] = call float @sqrtf(float [[F:%.*]]) +; LINUX-NEXT: ret float [[SQRTF]] ; MS32: [[SQRTF:%.*]] = call double @sqrt(double [[F:%.*]]) +; MS64-NEXT: [[SQRTF:%.*]] = call float @sqrtf(float [[F:%.*]]) ; %conv = fpext float %f to double %call = call double @sqrt(double %conv) @@ -448,11 +440,10 @@ define double @sqrt_test2(float %f) { define float @sqrt_int_test1(float %f) { ; CHECK-LABEL: @sqrt_int_test1( -; LINMS-NEXT: [[TMP1:%.*]] = call float @llvm.sqrt.f32(float [[F:%.*]]) -; LINMS-NEXT: ret float [[TMP1]] -; MS64-NEXT: [[TMP1:%.*]] = call float @llvm.sqrt.f32(float [[F:%.*]]) -; MS64-NEXT: ret float [[TMP1]] +; LINUX-NEXT: [[TMP1:%.*]] = call float @llvm.sqrt.f32(float [[F:%.*]]) +; LINUX-NEXT: ret float [[TMP1]] ; MS32: [[TMP1:%.*]] = call double @llvm.sqrt.f64(double [[F:%.*]]) +; MS64-NEXT: [[TMP1:%.*]] = call float @llvm.sqrt.f32(float [[F:%.*]]) ; %conv = fpext float %f to double %call = call double @llvm.sqrt.f64(double %conv) @@ -473,11 +464,10 @@ define double @sqrt_int_test2(float %f) { define float @tan_test1(float %f) { ; CHECK-LABEL: @tan_test1( -; LINMS-NEXT: [[TANF:%.*]] = call fast float @tanf(float [[F:%.*]]) -; LINMS-NEXT: ret float [[TANF]] -; MS64-NEXT: [[TANF:%.*]] = call fast float @tanf(float [[F:%.*]]) -; MS64-NEXT: ret float [[TANF]] +; LINUX-NEXT: [[TANF:%.*]] = call fast float @tanf(float [[F:%.*]]) +; LINUX-NEXT: ret float [[TANF]] ; MS32: [[TANF:%.*]] = call fast double @tan(double [[F:%.*]]) +; MS64-NEXT: [[TANF:%.*]] = call fast float @tanf(float [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @tan(double %conv) @@ -497,11 +487,10 @@ define double @tan_test2(float %f) { } define float @tanh_test1(float %f) { ; CHECK-LABEL: @tanh_test1( -; LINMS-NEXT: [[TANHF:%.*]] = call fast float @tanhf(float [[F:%.*]]) -; LINMS-NEXT: ret float [[TANHF]] -; MS64-NEXT: [[TANHF:%.*]] = call fast float @tanhf(float [[F:%.*]]) -; MS64-NEXT: ret float [[TANHF]] +; LINUX-NEXT: [[TANHF:%.*]] = call fast float @tanhf(float [[F:%.*]]) +; LINUX-NEXT: ret float [[TANHF]] ; MS32: [[TANHF:%.*]] = call fast double @tanh(double [[F:%.*]]) +; MS64-NEXT: [[TANHF:%.*]] = call fast float @tanhf(float [[F:%.*]]) ; %conv = fpext float %f to double %call = call fast double @tanh(double %conv) @@ -524,9 +513,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]] -; MSVC: [[FMAXF:%.*]] = call arcp double @fmax(double [[A:%.*]], double [[B:%.*]]) +; ISC99-NEXT: [[FMAXF:%.*]] = call arcp float @fmaxf(float [[A:%.*]], float [[B:%.*]]) +; ISC99-NEXT: ret float [[FMAXF]] +; ISC89: [[FMAXF:%.*]] = call arcp double @fmax(double [[A:%.*]], double [[B:%.*]]) ; %c = fpext float %a to double %d = fpext float %b to double diff --git a/test/Transforms/InstCombine/pow-1.ll b/test/Transforms/InstCombine/pow-1.ll index 91b5cf9f1c6..957e2488b72 100644 --- a/test/Transforms/InstCombine/pow-1.ll +++ b/test/Transforms/InstCombine/pow-1.ll @@ -10,9 +10,9 @@ ; RUN: opt -instcombine -S < %s -mtriple=arm-apple-watchos2.0 | FileCheck %s --check-prefixes=CHECK,ANY,CHECK-EXP10 ; rdar://7251832 ; RUN: opt -instcombine -S < %s -mtriple=i386-pc-windows-msvc18 | FileCheck %s --check-prefixes=CHECK,MSVC,VC32,CHECK-NO-EXP10 -; RUN: opt -instcombine -S < %s -mtriple=i386-pc-windows-msvc | FileCheck %s --check-prefixes=CHECK,MSVC,VC19,VC51,CHECK-NO-EXP10 -; RUN: opt -instcombine -S < %s -mtriple=x86_64-pc-windows-msvc18 | FileCheck %s --check-prefixes=CHECK,MSVC,VC64,VC83,CHECK-NO-EXP10 -; RUN: opt -instcombine -S < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s --check-prefixes=CHECK,MSVC,VC19,VC83,CHECK-NO-EXP10 +; RUN: opt -instcombine -S < %s -mtriple=i386-pc-windows-msvc | FileCheck %s --check-prefixes=CHECK,MSVC,VC51,VC19,CHECK-NO-EXP10 +; RUN: opt -instcombine -S < %s -mtriple=x86_64-pc-windows-msvc18 | FileCheck %s --check-prefixes=CHECK,MSVC,VC64,CHECK-NO-EXP10 +; RUN: opt -instcombine -S < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s --check-prefixes=CHECK,MSVC,VC83,VC19,CHECK-NO-EXP10 ; NOTE: The readonly attribute on the pow call should be preserved ; in the cases below where pow is transformed into another function call. @@ -30,9 +30,7 @@ define float @test_simplify1(float %x) { ; ANY-NEXT: ret float 1.000000e+00 ; VC32-NEXT: [[POW:%.*]] = call float @powf(float 1.000000e+00, float [[X:%.*]]) ; VC32-NEXT: ret float [[POW]] -; VC51-NEXT: [[POW:%.*]] = call float @powf(float 1.000000e+00, float [[X:%.*]]) -; VC51-NEXT: ret float [[POW]] -; VC83-NEXT: ret float 1.000000e+00 +; VC64-NEXT: ret float 1.000000e+00 ; %retval = call float @powf(float 1.0, float %x) ret float %retval @@ -72,8 +70,14 @@ define float @test_simplify3(float %x) { ; CHECK-LABEL: @test_simplify3( ; ANY-NEXT: [[EXP2F:%.*]] = call float @exp2f(float [[X:%.*]]) ; ANY-NEXT: ret float [[EXP2F]] -; MSVC-NEXT: [[POW:%.*]] = call float @powf(float 2.000000e+00, float [[X:%.*]]) -; MSVC-NEXT: ret float [[POW]] +; VC32-NEXT: [[POW:%.*]] = call float @powf(float 2.000000e+00, float [[X:%.*]]) +; VC32-NEXT: ret float [[POW]] +; VC51-NEXT: [[POW:%.*]] = call float @powf(float 2.000000e+00, float [[X:%.*]]) +; VC51-NEXT: ret float [[POW]] +; VC64-NEXT: [[POW:%.*]] = call float @powf(float 2.000000e+00, float [[X:%.*]]) +; VC64-NEXT: ret float [[POW]] +; VC83-NEXT: [[EXP2F:%.*]] = call float @exp2f(float [[X:%.*]]) +; VC83-NEXT: ret float [[EXP2F]] ; %retval = call float @powf(float 2.0, float %x) ret float %retval @@ -84,11 +88,13 @@ define double @test_simplify3n(double %x) { ; ANY-NEXT: [[MUL:%.*]] = fmul double [[X:%.*]], -2.000000e+00 ; ANY-NEXT: [[EXP2:%.*]] = call double @exp2(double [[MUL]]) ; ANY-NEXT: ret double [[EXP2]] -; VC64-NEXT: [[POW:%.*]] = call double @pow(double 2.500000e-01, double [[X:%.*]]) -; VC64-NEXT: ret double [[POW]] ; VC19-NEXT: [[MUL:%.*]] = fmul double [[X:%.*]], -2.000000e+00 ; VC19-NEXT: [[EXP2:%.*]] = call double @exp2(double [[MUL]]) ; VC19-NEXT: ret double [[EXP2]] +; VC32-NEXT: [[POW:%.*]] = call double @pow(double 2.500000e-01, double [[X:%.*]]) +; VC32-NEXT: ret double [[POW]] +; VC64-NEXT: [[POW:%.*]] = call double @pow(double 2.500000e-01, double [[X:%.*]]) +; VC64-NEXT: ret double [[POW]] ; %retval = call double @pow(double 0.25, double %x) ret double %retval @@ -121,10 +127,12 @@ define double @test_simplify4(double %x) { ; CHECK-LABEL: @test_simplify4( ; ANY-NEXT: [[EXP2:%.*]] = call double @exp2(double [[X:%.*]]) ; ANY-NEXT: ret double [[EXP2]] -; VC64-NEXT: [[POW:%.*]] = call double @pow(double 2.000000e+00, double [[X:%.*]]) -; VC64-NEXT: ret double [[POW]] ; VC19-NEXT: [[EXP2:%.*]] = call double @exp2(double [[X:%.*]]) ; VC19-NEXT: ret double [[EXP2]] +; VC32-NEXT: [[POW:%.*]] = call double @pow(double 2.000000e+00, double [[X:%.*]]) +; VC32-NEXT: ret double [[POW]] +; VC64-NEXT: [[POW:%.*]] = call double @pow(double 2.000000e+00, double [[X:%.*]]) +; VC64-NEXT: ret double [[POW]] ; %retval = call double @pow(double 2.0, double %x) ret double %retval @@ -135,8 +143,15 @@ define float @test_simplify4n(float %x) { ; ANY-NEXT: [[MUL:%.*]] = fmul float [[X:%.*]], 3.000000e+00 ; ANY-NEXT: [[EXP2F:%.*]] = call float @exp2f(float [[MUL]]) ; ANY-NEXT: ret float [[EXP2F]] -; MSVC-NEXT: [[POW:%.*]] = call float @powf(float 8.000000e+00, float [[X:%.*]]) -; MSVC-NEXT: ret float [[POW]] +; VC32-NEXT: [[POW:%.*]] = call float @powf(float 8.000000e+00, float [[X:%.*]]) +; VC32-NEXT: ret float [[POW]] +; VC51-NEXT: [[POW:%.*]] = call float @powf(float 8.000000e+00, float [[X:%.*]]) +; VC51-NEXT: ret float [[POW]] +; VC64-NEXT: [[POW:%.*]] = call float @powf(float 8.000000e+00, float [[X:%.*]]) +; VC64-NEXT: ret float [[POW]] +; VC83-NEXT: [[MUL:%.*]] = fmul float [[X:%.*]], 3.000000e+00 +; VC83-NEXT: [[EXP2F:%.*]] = call float @exp2f(float [[MUL]]) +; VC83-NEXT: ret float [[EXP2F]] ; %retval = call float @powf(float 8.0, float %x) ret float %retval @@ -174,6 +189,7 @@ define float @test_simplify5(float %x) { ; VC32-NEXT: ret float [[POW]] ; VC51-NEXT: [[POW:%.*]] = call float @powf(float [[X:%.*]], float 0.000000e+00) ; VC51-NEXT: ret float [[POW]] +; VC64-NEXT: ret float 1.000000e+00 ; VC83-NEXT: ret float 1.000000e+00 ; %retval = call float @powf(float %x, float 0.0) @@ -221,6 +237,11 @@ define float @test_simplify7(float %x) { ; VC32-NEXT: ret float [[POW]] ; VC51-NEXT: [[POW:%.*]] = call float @powf(float [[X:%.*]], float 5.000000e-01) ; VC51-NEXT: ret float [[POW]] +; VC64-NEXT: [[SQRTF:%.*]] = call float @sqrtf(float [[X:%.*]]) +; VC64-NEXT: [[ABS:%.*]] = call float @llvm.fabs.f32(float [[SQRTF]]) +; VC64-NEXT: [[ISINF:%.*]] = fcmp oeq float [[X]], 0xFFF0000000000000 +; VC64-NEXT: [[TMP1:%.*]] = select i1 [[ISINF]], float 0x7FF0000000000000, float [[ABS]] +; VC64-NEXT: ret float [[TMP1]] ; VC83-NEXT: [[SQRTF:%.*]] = call float @sqrtf(float [[X:%.*]]) ; VC83-NEXT: [[ABS:%.*]] = call float @llvm.fabs.f32(float [[SQRTF]]) ; VC83-NEXT: [[ISINF:%.*]] = fcmp oeq float [[X]], 0xFFF0000000000000 @@ -252,6 +273,7 @@ define float @test_simplify9(float %x) { ; VC32-NEXT: ret float [[POW]] ; VC51-NEXT: [[POW:%.*]] = call float @powf(float 0xFFF0000000000000, float 5.000000e-01) ; VC51-NEXT: ret float [[POW]] +; VC64-NEXT: ret float 0x7FF0000000000000 ; VC83-NEXT: ret float 0x7FF0000000000000 ; %retval = call float @powf(float 0xFFF0000000000000, float 0.5) @@ -275,6 +297,7 @@ define float @test_simplify11(float %x) { ; VC32-NEXT: ret float [[POW]] ; VC51-NEXT: [[POW:%.*]] = call float @powf(float [[X:%.*]], float 1.000000e+00) ; VC51-NEXT: ret float [[POW]] +; VC64-NEXT: ret float [[X:%.*]] ; VC83-NEXT: ret float [[X:%.*]] ; %retval = call float @powf(float %x, float 1.0) @@ -319,6 +342,8 @@ define float @pow2_strict(float %x) { ; VC32-NEXT: ret float [[POW]] ; VC51-NEXT: [[POW:%.*]] = call float @powf(float [[X:%.*]], float 2.000000e+00) ; VC51-NEXT: ret float [[POW]] +; VC64-NEXT: [[SQUARE:%.*]] = fmul float [[X:%.*]], [[X]] +; VC64-NEXT: ret float [[SQUARE]] ; VC83-NEXT: [[SQUARE:%.*]] = fmul float [[X:%.*]], [[X]] ; VC83-NEXT: ret float [[SQUARE]] ; @@ -367,6 +392,8 @@ define float @pow2_fast(float %x) { ; VC32-NEXT: ret float [[POW]] ; VC51-NEXT: [[POW:%.*]] = call fast float @powf(float [[X:%.*]], float 2.000000e+00) ; VC51-NEXT: ret float [[POW]] +; VC64-NEXT: [[SQUARE:%.*]] = fmul fast float [[X:%.*]], [[X]] +; VC64-NEXT: ret float [[SQUARE]] ; VC83-NEXT: [[SQUARE:%.*]] = fmul fast float [[X:%.*]], [[X]] ; VC83-NEXT: ret float [[SQUARE]] ; @@ -384,6 +411,8 @@ define float @pow_neg1_strict(float %x) { ; VC32-NEXT: ret float [[POW]] ; VC51-NEXT: [[POW:%.*]] = call float @powf(float [[X:%.*]], float -1.000000e+00) ; VC51-NEXT: ret float [[POW]] +; VC64-NEXT: [[RECIPROCAL:%.*]] = fdiv float 1.000000e+00, [[X:%.*]] +; VC64-NEXT: ret float [[RECIPROCAL]] ; VC83-NEXT: [[RECIPROCAL:%.*]] = fdiv float 1.000000e+00, [[X:%.*]] ; VC83-NEXT: ret float [[RECIPROCAL]] ;