[llvm] [AMDGPU] Add half vector support for table-driven libcall optimization (PR #178638)
Steffen Larsen via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 10 04:48:07 PST 2026
================
@@ -1400,148 +1402,97 @@ bool AMDGPULibCalls::evaluateScalarMathFunc(const FuncInfo &FInfo, double &Res0,
: (double)fpopr1->getValueAPF().convertToFloat();
}
- switch (FInfo.getId()) {
- default : return false;
-
- case AMDGPULibFunc::EI_ACOS:
- Res0 = acos(opr0);
- return true;
-
- case AMDGPULibFunc::EI_ACOSH:
- // acosh(x) == log(x + sqrt(x*x - 1))
- Res0 = log(opr0 + sqrt(opr0*opr0 - 1.0));
- return true;
-
- case AMDGPULibFunc::EI_ACOSPI:
- Res0 = acos(opr0) / MATH_PI;
- return true;
-
- case AMDGPULibFunc::EI_ASIN:
- Res0 = asin(opr0);
- return true;
-
- case AMDGPULibFunc::EI_ASINH:
- // asinh(x) == log(x + sqrt(x*x + 1))
- Res0 = log(opr0 + sqrt(opr0*opr0 + 1.0));
- return true;
-
- case AMDGPULibFunc::EI_ASINPI:
- Res0 = asin(opr0) / MATH_PI;
- return true;
-
- case AMDGPULibFunc::EI_ATAN:
- Res0 = atan(opr0);
- return true;
-
- case AMDGPULibFunc::EI_ATANH:
- // atanh(x) == (log(x+1) - log(x-1))/2;
- Res0 = (log(opr0 + 1.0) - log(opr0 - 1.0))/2.0;
- return true;
-
- case AMDGPULibFunc::EI_ATANPI:
- Res0 = atan(opr0) / MATH_PI;
- return true;
-
- case AMDGPULibFunc::EI_CBRT:
- Res0 = (opr0 < 0.0) ? -pow(-opr0, 1.0/3.0) : pow(opr0, 1.0/3.0);
- return true;
-
- case AMDGPULibFunc::EI_COS:
- Res0 = cos(opr0);
- return true;
-
- case AMDGPULibFunc::EI_COSH:
- Res0 = cosh(opr0);
- return true;
-
- case AMDGPULibFunc::EI_COSPI:
- Res0 = cos(MATH_PI * opr0);
- return true;
-
- case AMDGPULibFunc::EI_EXP:
- Res0 = exp(opr0);
- return true;
-
- case AMDGPULibFunc::EI_EXP2:
- Res0 = pow(2.0, opr0);
- return true;
-
- case AMDGPULibFunc::EI_EXP10:
- Res0 = pow(10.0, opr0);
- return true;
-
- case AMDGPULibFunc::EI_LOG:
- Res0 = log(opr0);
- return true;
-
- case AMDGPULibFunc::EI_LOG2:
- Res0 = log(opr0) / log(2.0);
- return true;
-
- case AMDGPULibFunc::EI_LOG10:
- Res0 = log(opr0) / log(10.0);
- return true;
-
- case AMDGPULibFunc::EI_RSQRT:
- Res0 = 1.0 / sqrt(opr0);
- return true;
-
- case AMDGPULibFunc::EI_SIN:
- Res0 = sin(opr0);
- return true;
-
- case AMDGPULibFunc::EI_SINH:
- Res0 = sinh(opr0);
- return true;
-
- case AMDGPULibFunc::EI_SINPI:
- Res0 = sin(MATH_PI * opr0);
- return true;
-
- case AMDGPULibFunc::EI_TAN:
- Res0 = tan(opr0);
- return true;
-
- case AMDGPULibFunc::EI_TANH:
- Res0 = tanh(opr0);
- return true;
-
- case AMDGPULibFunc::EI_TANPI:
- Res0 = tan(MATH_PI * opr0);
- return true;
-
- // two-arg functions
- case AMDGPULibFunc::EI_POW:
- case AMDGPULibFunc::EI_POWR:
- Res0 = pow(opr0, opr1);
- return true;
-
- case AMDGPULibFunc::EI_POWN: {
- if (ConstantInt *iopr1 = dyn_cast_or_null<ConstantInt>(copr1)) {
- double val = (double)iopr1->getSExtValue();
- Res0 = pow(opr0, val);
- return true;
+ auto Res = [&FInfo, opr0, opr1,
----------------
steffenlarsen wrote:
It was an attempt to avoid having to insert explicit `APFloat` all over. I'm fine with either, so it is now back to the old structure, but with `APFloat` constructions.
https://github.com/llvm/llvm-project/pull/178638
More information about the llvm-commits
mailing list