diff options
| author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2024-05-20 22:23:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-20 22:23:02 +0200 |
| commit | 3cb1fe60fb00ba3761e34866ffc93c7d7a0b509d (patch) | |
| tree | dadd8f6053bf08f75e5bfa653aa62d4ce4ab29b9 /llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp | |
| parent | 0da1a6ceb595fa91e3af20bf7f304ba275526f3c (diff) | |
AMDGPU: Don't fold rootn(x, 1) to input for strictfp functions (#92595)
We need to insert a constrained canonicalize.
Depends #92594
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp')
| -rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp index 0a5fbf5034c0..47de1791dae3 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp @@ -1163,14 +1163,19 @@ bool AMDGPULibCalls::fold_rootn(FPMathOperator *FPOp, IRBuilder<> &B, if (!match(opr1, m_APIntAllowPoison(CINT))) return false; + Function *Parent = B.GetInsertBlock()->getParent(); + int ci_opr1 = (int)CINT->getSExtValue(); - if (ci_opr1 == 1) { // rootn(x, 1) = x - LLVM_DEBUG(errs() << "AMDIC: " << *FPOp << " ---> " << *opr0 << "\n"); + if (ci_opr1 == 1 && !Parent->hasFnAttribute(Attribute::StrictFP)) { + // rootn(x, 1) = x + // + // TODO: Insert constrained canonicalize for strictfp case. + LLVM_DEBUG(errs() << "AMDIC: " << *FPOp << " ---> " << *opr0 << '\n'); replaceCall(FPOp, opr0); return true; } - Module *M = B.GetInsertBlock()->getModule(); + Module *M = Parent->getParent(); if (ci_opr1 == 2) { // rootn(x, 2) = sqrt(x) if (FunctionCallee FPExpr = getFunction(M, AMDGPULibFunc(AMDGPULibFunc::EI_SQRT, FInfo))) { |
