mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[ConstantFolding] Fold constant calls to log2()
Somehow, folding calls to `log2()` with a constant was missing. Differential revision: https://reviews.llvm.org/D67300 llvm-svn: 373262
This commit is contained in:
parent
15a5c7b05f
commit
4b361fd46d
@ -1508,6 +1508,7 @@ bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) {
|
||||
Name == "fmod" || Name == "fmodf";
|
||||
case 'l':
|
||||
return Name == "log" || Name == "logf" ||
|
||||
Name == "log2" || Name == "log2f" ||
|
||||
Name == "log10" || Name == "log10f";
|
||||
case 'n':
|
||||
return Name == "nearbyint" || Name == "nearbyintf";
|
||||
@ -1890,6 +1891,14 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
|
||||
if (V > 0.0 && TLI->has(Func))
|
||||
return ConstantFoldFP(log, V, Ty);
|
||||
break;
|
||||
case LibFunc_log2:
|
||||
case LibFunc_log2f:
|
||||
case LibFunc_log2_finite:
|
||||
case LibFunc_log2f_finite:
|
||||
if (V > 0.0 && TLI->has(Func))
|
||||
// TODO: What about hosts that lack a C99 library?
|
||||
return ConstantFoldFP(Log2, V, Ty);
|
||||
break;
|
||||
case LibFunc_log10:
|
||||
case LibFunc_log10f:
|
||||
case LibFunc_log10_finite:
|
||||
|
@ -92,14 +92,14 @@ define double @i_exp2() {
|
||||
ret double %res
|
||||
}
|
||||
|
||||
; FIXME
|
||||
; FIXME: exp10() is not widely supported.
|
||||
declare float @exp10f(float)
|
||||
define float @f_exp10f() {
|
||||
; CHECK-LABEL: @f_exp10f(
|
||||
; CHECK-NEXT: [[RES:%.*]] = tail call fast float @exp10f(float 1.000000e+00)
|
||||
; CHECK-NEXT: [[RES:%.*]] = tail call float @exp10f(float 1.000000e+00)
|
||||
; CHECK-NEXT: ret float [[RES]]
|
||||
;
|
||||
%res = tail call fast float @exp10f(float 1.0)
|
||||
%res = tail call float @exp10f(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
@ -121,12 +121,10 @@ define double @i_log() {
|
||||
ret double %res
|
||||
}
|
||||
|
||||
; FIXME
|
||||
declare float @log2f(float)
|
||||
define float @f_log2f() {
|
||||
; CHECK-LABEL: @f_log2f(
|
||||
; CHECK-NEXT: [[RES:%.*]] = tail call fast float @log2f(float 1.000000e+00)
|
||||
; CHECK-NEXT: ret float [[RES]]
|
||||
; CHECK-NEXT: ret float 0.000000e+00
|
||||
;
|
||||
%res = tail call fast float @log2f(float 1.0)
|
||||
ret float %res
|
||||
|
Loading…
x
Reference in New Issue
Block a user