================
@@ -4439,6 +4448,68 @@ bool ExtVectorElementExpr::containsDuplicateElements() 
const {
   return false;
 }
 
+/// containsDuplicateElements - Return true if any Matrix element access is
+/// repeated.
+bool MatrixElementExpr::containsDuplicateElements() const {
+  StringRef Comp = Accessor->getName();
+  assert(!Comp.empty() && Comp[0] == '_' && "invalid matrix accessor");
+
+  // Get the matrix type so we know bounds.
+  const ConstantMatrixType *MT =
+      getBase()->getType()->getAs<ConstantMatrixType>();
+  assert(MT && "MatrixElementExpr base must be a matrix type");
+
+  unsigned Rows = MT->getNumRows();
+  unsigned Cols = MT->getNumColumns();
+  unsigned Max = Rows * Cols;
+
+  // Zero-indexed: _mRC  (4 chars per component)
+  // One-indexed: _RC    (3 chars per component)
+  bool IsZeroIndexed = false;
+  unsigned ChunkLen = 0;
+
+  if (Comp.size() >= 2 && Comp[0] == '_' && Comp[1] == 'm') {
+    IsZeroIndexed = true;
+    ChunkLen = 4;
+  } else {
+    IsZeroIndexed = false;
+    ChunkLen = 3;
+  }
+
+  assert(ChunkLen && "unrecognized matrix swizzle format");
----------------
hekota wrote:

This assert will never fire. `ChunkLen` is always assigned `3` or `4`.

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

Reply via email to