[llvm] [Matrix][InstCombine] Collapse inverse Transposes (PR #224172)
Farzon Lotfi via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 17 11:02:21 PDT 2026
farzonl wrote:
> Currently we fold away transpose of transpose in LowerMatrixIntrinsics
HLSL does not run `LowerMatrixIntrinsics` for either the DirectX or SPIR-V backends. So `optimizeTransposes()` cannot eliminate these pairs for HLSL. DXIL expands each transpose directly, while SPIR-V lowers it during GlobalISel.
HLSL also does not rely on LMI shape propagation for memory layout. Row/column-major layout is encoded in the array-of-vectors memory representation before these flattened SSA values are produced.
That is why for us we are getting redundant transpose pairs generated during normalization that survive into target lowering. Avoiding that is why an earlier common fold is needed.
This is particularly problematic for us because HLSL has row\column major keywords than can impact memory layout of any matrix. While I beleive for your use case all your matrix types are row major or column major.
https://github.com/llvm/llvm-project/pull/224172
More information about the llvm-commits
mailing list