[llvm] [Matrix] Use data layout index type for lowering matrix intrinsics (PR #162646)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 10 01:50:28 PDT 2025


================
@@ -1295,6 +1295,24 @@ class LowerMatrixIntrinsics {
     return commonAlignment(InitialAlign, ElementSizeInBits / 8);
   }
 
+  IntegerType *getIndexType(Value *Ptr) const {
+    return cast<IntegerType>(DL.getIndexType(Ptr->getType()));
+  }
+
+  Value *getIndex(Value *Ptr, uint64_t V) const {
+    return ConstantInt::get(getIndexType(Ptr), V);
+  }
+
+  Value *castToIndexType(Value *Ptr, Value *V, IRBuilder<> &Builder) const {
+    assert(isa<IntegerType>(V->getType()) &&
+           "Attempted to cast non-integral type to integer index");
+    // In case the data layout's index type differs in width from the type of
+    // the value we're given, truncate or zero extend to the appropraite width.
----------------
fhahn wrote:

```suggestion
    // the value we're given, truncate or zero extend to the appropriate width.
```

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


More information about the llvm-commits mailing list