[llvm] [AMDGPU] Improve detection of non-null addrspacecast operands (PR #82311)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 1 02:39:22 PST 2024


================
@@ -6635,24 +6652,37 @@ static bool isKnownNonNull(SDValue Val, SelectionDAG &DAG,
 SDValue SITargetLowering::lowerADDRSPACECAST(SDValue Op,
                                              SelectionDAG &DAG) const {
   SDLoc SL(Op);
-  const AddrSpaceCastSDNode *ASC = cast<AddrSpaceCastSDNode>(Op);
-
-  SDValue Src = ASC->getOperand(0);
-  SDValue FlatNullPtr = DAG.getConstant(0, SL, MVT::i64);
-  unsigned SrcAS = ASC->getSrcAddressSpace();
 
   const AMDGPUTargetMachine &TM =
     static_cast<const AMDGPUTargetMachine &>(getTargetMachine());
 
+  unsigned DestAS, SrcAS;
+  SDValue Src;
+  bool KnownNonNull;
+  if (const auto *ASC = dyn_cast<AddrSpaceCastSDNode>(Op)) {
+    SrcAS = ASC->getSrcAddressSpace();
+    Src = ASC->getOperand(0);
+    DestAS = ASC->getDestAddressSpace();
+    KnownNonNull = isKnownNonNull(Op, DAG, TM, SrcAS);
----------------
arsenm wrote:

Ditto 

https://github.com/llvm/llvm-project/pull/82311


More information about the llvm-commits mailing list