[llvm] [NVPTX] instcombine known pointer AS checks. (PR #112964)

Alex MacLean via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 26 12:25:31 PDT 2024


================
@@ -6365,6 +6367,32 @@ static Value *simplifyUnaryIntrinsic(Function *F, Value *Op0,
 
     break;
   }
+  case Intrinsic::nvvm_isspacep_global:
+  case Intrinsic::nvvm_isspacep_local:
+  case Intrinsic::nvvm_isspacep_shared:
+  case Intrinsic::nvvm_isspacep_const: {
+    auto *Ty = F->getReturnType();
+    unsigned AS = Op0->getType()->getPointerAddressSpace();
+    if (AS == NVPTXAS::ADDRESS_SPACE_GENERIC) {
+      if (auto *ASC = dyn_cast<AddrSpaceCastInst>(Op0))
+        AS = ASC->getSrcAddressSpace();
+      else if (auto *ASCO = dyn_cast<AddrSpaceCastOperator>(Op0))
+        AS = ASCO->getOperand(0)->getType()->getPointerAddressSpace();
+    }
----------------
AlexMaclean wrote:

https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/IR/Operator.h#L30-L31

ASC operators include ASC instructions I believe. 

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


More information about the llvm-commits mailing list