[clang] [HLSL][Matrix] EmitFromMemory when emitting load of vector and matrix element LValues (PR #178315)

Deric C. via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 18 11:52:31 PST 2026


================
@@ -2506,14 +2507,18 @@ RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, SourceLocation Loc) {
 
   if (LV.isMatrixElt()) {
     llvm::Value *Idx = LV.getMatrixIdx();
-    if (CGM.getCodeGenOpts().OptimizationLevel > 0) {
-      const auto *const MatTy = LV.getType()->castAs<ConstantMatrixType>();
-      llvm::MatrixBuilder MB(Builder);
-      MB.CreateIndexAssumption(Idx, MatTy->getNumElementsFlattened());
+    QualType EltTy = LV.getType();
+    if (const auto *MatTy = EltTy->getAs<ConstantMatrixType>()) {
+      EltTy = MatTy->getElementType();
+      if (CGM.getCodeGenOpts().OptimizationLevel > 0) {
+        llvm::MatrixBuilder MB(Builder);
+        MB.CreateIndexAssumption(Idx, MatTy->getNumElementsFlattened());
+      }
----------------
Icohedron wrote:

I think the index assumption used by the OpenCL backend. Other than that I'm not sure.

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


More information about the cfe-commits mailing list