llvm.org GIT mirror llvm / f47f020
[ConstantFolding] Fold constant calls to log2() Somehow, folding calls to `log2()` with a constant was missing. Differential revision: https://reviews.llvm.org/D67300 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373262 91177308-0d34-0410-b5e6-96231b3b80d8 Evandro Menezes 1 year, 21 days ago
2 changed file(s) with 13 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
15071507 Name == "fmod" || Name == "fmodf";
15081508 case 'l':
15091509 return Name == "log" || Name == "logf" ||
1510 Name == "log2" || Name == "log2f" ||
15101511 Name == "log10" || Name == "log10f";
15111512 case 'n':
15121513 return Name == "nearbyint" || Name == "nearbyintf";
18891890 if (V > 0.0 && TLI->has(Func))
18901891 return ConstantFoldFP(log, V, Ty);
18911892 break;
1893 case LibFunc_log2:
1894 case LibFunc_log2f:
1895 case LibFunc_log2_finite:
1896 case LibFunc_log2f_finite:
1897 if (V > 0.0 && TLI->has(Func))
1898 // TODO: What about hosts that lack a C99 library?
1899 return ConstantFoldFP(Log2, V, Ty);
1900 break;
18921901 case LibFunc_log10:
18931902 case LibFunc_log10f:
18941903 case LibFunc_log10_finite:
9191 ret double %res
9292 }
9393
94 ; FIXME
94 ; FIXME: exp10() is not widely supported.
9595 declare float @exp10f(float)
9696 define float @f_exp10f() {
9797 ; CHECK-LABEL: @f_exp10f(
98 ; CHECK-NEXT: [[RES:%.*]] = tail call fast float @exp10f(float 1.000000e+00)
98 ; CHECK-NEXT: [[RES:%.*]] = tail call float @exp10f(float 1.000000e+00)
9999 ; CHECK-NEXT: ret float [[RES]]
100100 ;
101 %res = tail call fast float @exp10f(float 1.0)
101 %res = tail call float @exp10f(float 1.0)
102102 ret float %res
103103 }
104104
120120 ret double %res
121121 }
122122
123 ; FIXME
124123 declare float @log2f(float)
125124 define float @f_log2f() {
126125 ; CHECK-LABEL: @f_log2f(
127 ; CHECK-NEXT: [[RES:%.*]] = tail call fast float @log2f(float 1.000000e+00)
128 ; CHECK-NEXT: ret float [[RES]]
126 ; CHECK-NEXT: ret float 0.000000e+00
129127 ;
130128 %res = tail call fast float @log2f(float 1.0)
131129 ret float %res