================
@@ -2177,7 +2177,27 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, 
IntrinsicInst &II) const {
     Value *Src = II.getArgOperand(0);
     if (isa<PoisonValue>(Src))
       return IC.replaceInstUsesWith(II, PoisonValue::get(II.getType()));
-    return std::nullopt;
+
+    // Normalize num_records to the correct width.
+    std::optional<unsigned> Width = ST->getBufferResourceNumRecordsWidth();
+    if (!Width)
+      return std::nullopt;
+    Type *NumRecordsTy = IC.Builder.getIntNTy(*Width);
+    if (II.getArgOperand(2)->getType() == NumRecordsTy)
+      return std::nullopt;
+    SmallVector<Value *, 4> Args(II.args());
+    Args[2] = IC.Builder.CreateZExtOrTrunc(Args[2], NumRecordsTy);
+    CallInst *NewCall = IC.Builder.CreateIntrinsicWithoutFolding(
+        Intrinsic::amdgcn_make_buffer_rsrc,
+        {II.getType(), Src->getType(), NumRecordsTy}, Args);
----------------
krzysz00 wrote:

I don't think this thing currently has any opernad bundles?

(Though there's been a discussion of adding them in a different PR)

https://github.com/llvm/llvm-project/pull/217068
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to