diff options
| author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2023-08-12 14:42:38 -0400 |
|---|---|---|
| committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2023-08-14 18:36:01 -0400 |
| commit | 416f6af9765cba2f9c45901b07e8d793f482f26d (patch) | |
| tree | cf25bfa7f3aa5b16830db72eed3beba255721aa3 /llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp | |
| parent | 0eabe65bfbb8eed5d0ffb3718fed3c9bbe058379 (diff) | |
AMDGPU: Remove special case folding of fma/mad
These just get replaced with an intrinsic now. This was also
introducing host dependence on the result since it relied on the
compiler choice to contract or not.
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp | 40 |
1 files changed, 8 insertions, 32 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp index 9c99356cde37..74b5f2df1358 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp @@ -75,8 +75,8 @@ private: bool sincosUseNative(CallInst *aCI, const FuncInfo &FInfo); // evaluate calls if calls' arguments are constants. - bool evaluateScalarMathFunc(const FuncInfo &FInfo, double& Res0, - double& Res1, Constant *copr0, Constant *copr1, Constant *copr2); + bool evaluateScalarMathFunc(const FuncInfo &FInfo, double &Res0, double &Res1, + Constant *copr0, Constant *copr1); bool evaluateCall(CallInst *aCI, const FuncInfo &FInfo); // sqrt @@ -1306,17 +1306,15 @@ bool AMDGPULibCalls::fold_sincos(FPMathOperator *FPOp, IRBuilder<> &B, return true; } -bool AMDGPULibCalls::evaluateScalarMathFunc(const FuncInfo &FInfo, - double& Res0, double& Res1, - Constant *copr0, Constant *copr1, - Constant *copr2) { +bool AMDGPULibCalls::evaluateScalarMathFunc(const FuncInfo &FInfo, double &Res0, + double &Res1, Constant *copr0, + Constant *copr1) { // By default, opr0/opr1/opr3 holds values of float/double type. // If they are not float/double, each function has to its // operand separately. - double opr0=0.0, opr1=0.0, opr2=0.0; + double opr0 = 0.0, opr1 = 0.0; ConstantFP *fpopr0 = dyn_cast_or_null<ConstantFP>(copr0); ConstantFP *fpopr1 = dyn_cast_or_null<ConstantFP>(copr1); - ConstantFP *fpopr2 = dyn_cast_or_null<ConstantFP>(copr2); if (fpopr0) { opr0 = (getArgType(FInfo) == AMDGPULibFunc::F64) ? fpopr0->getValueAPF().convertToDouble() @@ -1329,12 +1327,6 @@ bool AMDGPULibCalls::evaluateScalarMathFunc(const FuncInfo &FInfo, : (double)fpopr1->getValueAPF().convertToFloat(); } - if (fpopr2) { - opr2 = (getArgType(FInfo) == AMDGPULibFunc::F64) - ? fpopr2->getValueAPF().convertToDouble() - : (double)fpopr2->getValueAPF().convertToFloat(); - } - switch (FInfo.getId()) { default : return false; @@ -1486,12 +1478,6 @@ bool AMDGPULibCalls::evaluateScalarMathFunc(const FuncInfo &FInfo, Res0 = sin(opr0); Res1 = cos(opr0); return true; - - // three-arg functions - case AMDGPULibFunc::EI_FMA: - case AMDGPULibFunc::EI_MAD: - Res0 = opr0 * opr1 + opr2; - return true; } return false; @@ -1504,7 +1490,6 @@ bool AMDGPULibCalls::evaluateCall(CallInst *aCI, const FuncInfo &FInfo) { Constant *copr0 = nullptr; Constant *copr1 = nullptr; - Constant *copr2 = nullptr; if (numArgs > 0) { if ((copr0 = dyn_cast<Constant>(aCI->getArgOperand(0))) == nullptr) return false; @@ -1517,11 +1502,6 @@ bool AMDGPULibCalls::evaluateCall(CallInst *aCI, const FuncInfo &FInfo) { } } - if (numArgs > 2) { - if ((copr2 = dyn_cast<Constant>(aCI->getArgOperand(2))) == nullptr) - return false; - } - // At this point, all arguments to aCI are constants. // max vector size is 16, and sincos will generate two results. @@ -1529,20 +1509,16 @@ bool AMDGPULibCalls::evaluateCall(CallInst *aCI, const FuncInfo &FInfo) { int FuncVecSize = getVecSize(FInfo); bool hasTwoResults = (FInfo.getId() == AMDGPULibFunc::EI_SINCOS); if (FuncVecSize == 1) { - if (!evaluateScalarMathFunc(FInfo, DVal0[0], - DVal1[0], copr0, copr1, copr2)) { + if (!evaluateScalarMathFunc(FInfo, DVal0[0], DVal1[0], copr0, copr1)) { return false; } } else { ConstantDataVector *CDV0 = dyn_cast_or_null<ConstantDataVector>(copr0); ConstantDataVector *CDV1 = dyn_cast_or_null<ConstantDataVector>(copr1); - ConstantDataVector *CDV2 = dyn_cast_or_null<ConstantDataVector>(copr2); for (int i = 0; i < FuncVecSize; ++i) { Constant *celt0 = CDV0 ? CDV0->getElementAsConstant(i) : nullptr; Constant *celt1 = CDV1 ? CDV1->getElementAsConstant(i) : nullptr; - Constant *celt2 = CDV2 ? CDV2->getElementAsConstant(i) : nullptr; - if (!evaluateScalarMathFunc(FInfo, DVal0[i], - DVal1[i], celt0, celt1, celt2)) { + if (!evaluateScalarMathFunc(FInfo, DVal0[i], DVal1[i], celt0, celt1)) { return false; } } |
