[llvm] [DirectX] Add support for typedBufferLoad and Store for RWBuffer<double2> and RWBuffer<double> (PR #139996)

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Wed May 14 22:04:45 PDT 2025


================
@@ -532,6 +541,80 @@ static Value *expandRadiansIntrinsic(CallInst *Orig) {
   return Builder.CreateFMul(X, PiOver180);
 }
 
+static void expandTypedBufferLoadIntrinsic(CallInst *Orig) {
+  IRBuilder<> Builder(Orig);
+
+  unsigned ExtractNum =
+      Orig->getType()->getStructElementType(0)->isVectorTy() ? 4 : 2;
+  Type *Ty = VectorType::get(Builder.getInt32Ty(), ExtractNum, false);
----------------
bogner wrote:

This would miscompile if we were to encounter something like `<4 x double>` or `<23 x double>`. While those aren't really in scope, it's not ideal that this would silently accept but generate incorrect code if we did see them. We have a couple of options here:
1. Implement this in a way that it would handle arbitrary sizes
2. When we have a vector, assert that the vector size is exactly 2

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


More information about the llvm-commits mailing list