[PATCH] D91401: [AMDGPU] Mark sin/cos load folding as modifying the function.
Matthew Dawson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 12 22:22:36 PST 2020
MJDSys created this revision.
Herald added subscribers: llvm-commits, kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl, arsenm.
Herald added a project: LLVM.
MJDSys requested review of this revision.
Herald added a subscriber: wdng.
When the load value is folded into the sin/cos operation, the
AMDGPU library calls simplifier could still mark the function
as unmodified. Instead ensure if there is an early return,
return whether the load was folded into the sin/cos call.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D91401
Files:
llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
Index: llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
@@ -1288,6 +1288,7 @@
BasicBlock * const CBB = CI->getParent();
int const MaxScan = 30;
+ bool Changed = false;
{ // fold in load value.
LoadInst *LI = dyn_cast<LoadInst>(CArgVal);
@@ -1295,6 +1296,7 @@
BasicBlock::iterator BBI = LI->getIterator();
Value *AvailableVal = FindAvailableLoadedValue(LI, CBB, BBI, MaxScan, AA);
if (AvailableVal) {
+ Changed = true;
CArgVal->replaceAllUsesWith(AvailableVal);
if (CArgVal->getNumUses() == 0)
LI->eraseFromParent();
@@ -1330,7 +1332,8 @@
if (UI) break;
}
- if (!UI) return false;
+ if (!UI)
+ return Changed;
// Merge the sin and cos.
@@ -1339,7 +1342,8 @@
AMDGPULibFunc nf(AMDGPULibFunc::EI_SINCOS, fInfo);
nf.getLeads()[0].PtrKind = AMDGPULibFunc::getEPtrKindFromAddrSpace(AMDGPUAS::FLAT_ADDRESS);
FunctionCallee Fsincos = getFunction(M, nf);
- if (!Fsincos) return false;
+ if (!Fsincos)
+ return Changed;
BasicBlock::iterator ItOld = B.GetInsertPoint();
AllocaInst *Alloc = insertAlloca(UI, B, "__sincos_");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91401.305031.patch
Type: text/x-patch
Size: 1285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201113/a4cb5495/attachment.bin>
More information about the llvm-commits
mailing list