[clang] [HLSL][Matrix] Load and store ConstantMatrixBoolTypes as i32 FixedVectorTypes (PR #175245)

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 9 13:39:47 PST 2026


================
@@ -180,6 +180,19 @@ llvm::Type *CodeGenTypes::convertTypeForLoadStore(QualType T,
     return llvm::IntegerType::get(getLLVMContext(),
                                   (unsigned)Context.getTypeSize(T));
 
+  if (T->isConstantMatrixBoolType()) {
+    // Matrices are loaded and stored atomically as vectors. Therefore we
+    // construct a FixedVectorType here instead of returning
+    // ConvertTypeForMem(T) which would return an ArrayType instead.
+    const Type *Ty = Context.getCanonicalType(T).getTypePtr();
+    const ConstantMatrixType *MT = cast<ConstantMatrixType>(Ty);
+    llvm::Type *IRElemTy = ConvertType(MT->getElementType());
+    if (Context.getLangOpts().HLSL && T->isConstantMatrixBoolType())
+      IRElemTy = ConvertTypeForMem(Context.BoolTy);
+    return llvm::FixedVectorType::get(IRElemTy,
+                                      MT->getNumRows() * MT->getNumColumns());
----------------
farzonl wrote:

there is an flattened  getter you can use so you don't have to do this multiplication.

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


More information about the cfe-commits mailing list