[llvm] [AMDGPU] Improve detection of non-null addrspacecast operands (PR #82311)
Pierre van Houtryve via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 26 23:54:09 PST 2024
================
@@ -2013,6 +2021,78 @@ bool AMDGPUCodeGenPrepareImpl::visitPHINode(PHINode &I) {
return true;
}
+bool AMDGPUCodeGenPrepareImpl::visitAddrSpaceCastInst(AddrSpaceCastInst &I) {
+ if (!LowerAddrSpaceCast)
+ return false;
+
+ // Check if this can be lowered to a amdgcn.addrspacecast.nonnull.
+ // This is only worthwhile for casts from/to priv/local to flat.
+ const unsigned SrcAS = I.getSrcAddressSpace();
+ const unsigned DstAS = I.getDestAddressSpace();
+
+ bool CanLower = false;
+ if (SrcAS == AMDGPUAS::FLAT_ADDRESS)
+ CanLower = (DstAS == AMDGPUAS::LOCAL_ADDRESS ||
+ DstAS == AMDGPUAS::PRIVATE_ADDRESS);
+ else if (DstAS == AMDGPUAS::FLAT_ADDRESS)
+ CanLower = (SrcAS == AMDGPUAS::LOCAL_ADDRESS ||
+ SrcAS == AMDGPUAS::PRIVATE_ADDRESS);
+ if (!CanLower)
+ return false;
+
+ // Check the Src operand, and look through Phis.
----------------
Pierre-vh wrote:
isKnownNeverNull assumes zero null pointers, it's why it's not used. Once we have proper IR support for non-zero nulls then we could just use that
https://github.com/llvm/llvm-project/pull/82311
More information about the llvm-commits
mailing list