[llvm] [SPIRV][Matrix] fix boolean transpose by supporting nonstandard vector sizes (PR #187539)

Dmitry Sidorov via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 22 16:57:22 PDT 2026


================
@@ -261,9 +261,9 @@ SPIRVLegalizerInfo::SPIRVLegalizerInfo(const SPIRVSubtarget &ST) {
       .lowerIf(vectorElementCountIsGreaterThan(1, MaxVectorSize))
       .custom();
 
-  // If the result is still illegal, the combiner should be able to remove it.
+  // Because of 4x4 matrices the largest supported concat vector size is 16.
   getActionDefinitionsBuilder(G_CONCAT_VECTORS)
-      .legalForCartesianProduct(allowedVectorTypes, allowedVectorTypes);
+      .legalIf(vectorElementCountIsLessThanOrEqualTo(0, 16));
----------------
MrSidims wrote:

I have an incorrect and incomplete patch for wide vector legalization. It has a change here to avoid hard setting size=16:
```
   getActionDefinitionsBuilder(G_BUILD_VECTOR)
-      .legalIf(vectorElementCountIsLessThanOrEqualTo(0, MaxVectorSize));
+      .legalIf(vectorElementCountIsLessThanOrEqualTo(0, MaxVectorSize))
+      .fewerElementsIf(vectorElementCountIsGreaterThan(0, MaxVectorSize),
+                       LegalizeMutations::changeElementCountTo(
+                           0, ElementCount::getFixed(MaxVectorSize)));
```

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


More information about the llvm-commits mailing list