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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 29 00:25:53 PST 2024


================
@@ -1415,6 +1415,24 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info,
   }
 }
 
+void SITargetLowering::CollectTargetIntrinsicOperands(
+    const CallInst &I, SmallVectorImpl<SDValue> &Ops, SelectionDAG &DAG) const {
+  switch (cast<IntrinsicInst>(I).getIntrinsicID()) {
+  case Intrinsic::amdgcn_addrspacecast_nonnull: {
+    // The DAG's ValueType loses the addrspaces.
+    // Add them as 2 extra Constant operands "from" and "to".
+    unsigned SrcAS =
+        I.getOperand(0)->getType()->getScalarType()->getPointerAddressSpace();
+    unsigned DstAS = I.getType()->getScalarType()->getPointerAddressSpace();
----------------
arsenm wrote:

```suggestion
    unsigned SrcAS =
        I.getOperand(0)->getType()->getPointerAddressSpace();
    unsigned DstAS = I.getType()->getPointerAddressSpace();
```

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


More information about the llvm-commits mailing list