<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/120489>120489</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] `--canonicalize=disable-patterns=` doesn't work
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
jpienaar,
ftynse,
joker-eph
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
makslevental
</td>
</tr>
</table>
<pre>
If you try to specify `--canonicalize=disable-patterns=RemoveLoopInvariantArgsFromBefor...` you will not get the expected result (that none of these patterns are applied). Why?
Because patterns [labels](https://github.com/llvm/llvm-project/blob/6ae7f66ff5169ddc5a7b9ab545707042c77e036c/mlir/lib/Rewrite/FrozenRewritePatternSet.cpp#L101) are their entire `typename`:
```
FoldTensorCastPackOp
FoldTensorCastProducerOp
CanonicalizeConvertFromConvert
CanonicalizeConvertFromReshape
CanonicalizeConvertFromHistogram
CanonicalizeConvertFromAlloc
CanonicalizeConvertFromLocalStore
CanonicalizeConvertFromSplit
(anonymous namespace)::InsertSliceOpConstantArgumentFolder<mlir::tensor::ParallelInsertSliceOp>
(anonymous namespace)::InsertSliceOpCastFolder<mlir::tensor::ParallelInsertSliceOp>
(anonymous namespace)::InsertSliceOpSourceCastInserter<mlir::tensor::ParallelInsertSliceOp>
(anonymous namespace)::FoldStaticZeroPadding
(anonymous namespace)::FoldSourceTensorCast
(anonymous namespace)::FoldTargetTensorCast
(anonymous namespace)::FoldOrthogonalPaddings
(anonymous namespace)::FoldStaticPadding
(anonymous namespace)::FoldConsecutiveConstantPadding
(anonymous namespace)::InsertSliceOpConstantArgumentFolder<mlir::tensor::InsertSliceOp>
(anonymous namespace)::InsertSliceOpCastFolder<mlir::tensor::InsertSliceOp>
(anonymous namespace)::InsertSliceOpSourceCastInserter<mlir::tensor::InsertSliceOp>
(anonymous namespace)::ExtractFromTensorGenerate
(anonymous namespace)::StaticTensorGenerate
(anonymous namespace)::ExtractElementFromIndexCast
mlir::OpWithOffsetSizesAndStridesConstantArgumentFolder<mlir::tensor::ExtractSliceOp, SliceReturnTypeCanonicalizer, SliceCanonicalizer>
(anonymous namespace)::ExtractSliceOpCastFolder
(anonymous namespace)::ExtractFromTensorCast
mlir::ComposeReassociativeReshapeOps<mlir::tensor::ExpandShapeOp, mlir::ReshapeOpKind::kExpand>
mlir::ComposeExpandOfCollapseOp<mlir::tensor::ExpandShapeOp, mlir::tensor::CollapseShapeOp>
(anonymous namespace)::ConvertToStaticExpandShape
(anonymous namespace)::FoldReshapeWithConstant<mlir::tensor::ExpandShapeOp>
(anonymous namespace)::FoldReshapeWithSplat<mlir::tensor::ExpandShapeOp>
(anonymous namespace)::FoldReshapeWithFromElements<mlir::tensor::ExpandShapeOp>
(anonymous namespace)::FoldDimOfExpandShape
(anonymous namespace)::FoldDimOfCollapseShape
(anonymous namespace)::FoldEmptyTensorWithCastOp
(anonymous namespace)::FoldEmptyTensorWithDimOp
(anonymous namespace)::ReplaceEmptyTensorStaticShapeDims
(anonymous namespace)::DimOfCastOp
(anonymous namespace)::DimOfDestStyleOp
(anonymous namespace)::DimOfReshapeOp
(anonymous namespace)::SingleInputConcatOp
mlir::ComposeReassociativeReshapeOps<mlir::tensor::CollapseShapeOp, mlir::ReshapeOpKind::kCollapse>
mlir::ComposeCollapseOfExpandOp<mlir::tensor::CollapseShapeOp, mlir::tensor::ExpandShapeOp, mlir::tensor::CastOp, mlir::tensor::DimOp, mlir::RankedTensorType>
(anonymous namespace)::FoldReshapeWithConstant<mlir::tensor::CollapseShapeOp>
(anonymous namespace)::FoldReshapeWithSplat<mlir::tensor::CollapseShapeOp>
(anonymous namespace)::FoldReshapeWithFromElements<mlir::tensor::CollapseShapeOp>
(anonymous namespace)::FoldCollapseOfCastOp
(anonymous namespace)::ChainedTensorCast
(anonymous namespace)::TensorCastExtractSlice
(anonymous namespace)::ChainedTensorBitcast
(anonymous namespace)::FoldComponentNeg<mlir::complex::ReOp, 0>
(anonymous namespace)::FoldComponentNeg<mlir::complex::ImOp, 1>
MergeComplexBitcast
MergeArithBitcast
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffineVectorStoreOp>
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffineVectorLoadOp>
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffineStoreOp>
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffinePrefetchOp>
CanonicalizeSingleResultAffineMinMaxOp<mlir::affine::AffineMinOp>
DeduplicateAffineMinMaxExpressions<mlir::affine::AffineMinOp>
MergeAffineMinMaxOp<mlir::affine::AffineMinOp>
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffineMinOp>
CanonicalizeAffineMinMaxOpExprAndTermOrder<mlir::affine::AffineMinOp>
CanonicalizeSingleResultAffineMinMaxOp<mlir::affine::AffineMaxOp>
DeduplicateAffineMinMaxExpressions<mlir::affine::AffineMaxOp>
MergeAffineMinMaxOp<mlir::affine::AffineMaxOp>
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffineMaxOp>
CanonicalizeAffineMinMaxOpExprAndTermOrder<mlir::affine::AffineMaxOp>
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffineLoadOp>
(anonymous namespace)::CancelLinearizeOfDelinearizeExact
(anonymous namespace)::DropLinearizeLeadingZero
(anonymous namespace)::DropLinearizeUnitComponentsIfDisjointOrZero
(anonymous namespace)::SimplifyDeadElse
(anonymous namespace)::AlwaysTrueOrFalseIf
(anonymous namespace)::AffineForEmptyLoopFolder
(anonymous namespace)::CancelDelinearizeOfLinearizeDisjointExactTail
(anonymous namespace)::DropUnitExtentBasis
(anonymous namespace)::SplitDelinearizeSpanningLastLinearizeArg
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffineApplyOp>
(anonymous namespace)::EraseRedundantGpuWaitOpPairs
(anonymous namespace)::SimplifyGpuWaitOp
(anonymous namespace)::EraseTrivialCopyOp
FoldLaunchArguments
(anonymous namespace)::SimplifyDimOfAllocOp
mlir::triton::CanonicalizeMaskedStorePattern
mlir::triton::CanonicalizeMaskedLoadPattern
(anonymous namespace)::SimplifyConstCondBranchPred
(anonymous namespace)::SimplifyPassThroughCondBranch
(anonymous namespace)::SimplifyCondBranchIdenticalSuccessors
(anonymous namespace)::SimplifyCondBranchFromCondBranchOnSameCondition
(anonymous namespace)::CondBranchTruthPropagation
(anonymous namespace)::RemoveLoopInvariantArgsFromBeforeBlock
(anonymous namespace)::RemoveLoopInvariantValueYielded
(anonymous namespace)::WhileConditionTruth
(anonymous namespace)::WhileCmpCond
(anonymous namespace)::WhileUnusedResult
(anonymous namespace)::WhileRemoveDuplicatedResults
(anonymous namespace)::WhileRemoveUnusedArgs
(anonymous namespace)::WhileOpAlignBeforeArgs
(anonymous namespace)::RedundantSelectFalse
(anonymous namespace)::RedundantSelectTrue
(anonymous namespace)::SelectNotCond
(anonymous namespace)::SelectI1ToNot
SelectToExtUI
(anonymous namespace)::XOrINotCmpI
(anonymous namespace)::XOrIOfExtUI
(anonymous namespace)::XOrIOfExtSI
(anonymous namespace)::TruncIExtSIToExtSI
(anonymous namespace)::TruncIExtUIToExtUI
(anonymous namespace)::TruncIShrSIToTrunciShrUI
(anonymous namespace)::TruncIShrUIMulIToMulSIExtended
(anonymous namespace)::TruncIShrUIMulIToMulUIExtended
(anonymous namespace)::SubIRHSAddConstant
(anonymous namespace)::SubILHSAddConstant
(anonymous namespace)::SubIRHSSubConstantRHS
(anonymous namespace)::SubIRHSSubConstantLHS
(anonymous namespace)::SubILHSSubConstantRHS
(anonymous namespace)::SubILHSSubConstantLHS
(anonymous namespace)::SubISubILHSRHSLHS
(anonymous namespace)::OrOfExtUI
(anonymous namespace)::OrOfExtSI
(anonymous namespace)::MulUIExtendedToMulI
(anonymous namespace)::MulSIExtendedToMulI
(anonymous namespace)::MulSIExtendedRHSOne
(anonymous namespace)::MulIMulIConstant
(anonymous namespace)::MulFOfNegF
(anonymous namespace)::IndexCastUIOfIndexCastUI
(anonymous namespace)::IndexCastUIOfExtUI
(anonymous namespace)::IndexCastOfIndexCast
(anonymous namespace)::IndexCastOfExtSI
(anonymous namespace)::ExtSIOfExtUI
(anonymous namespace)::DivFOfNegF
(anonymous namespace)::CmpIExtSI
(anonymous namespace)::CmpIExtUI
CmpFIntToFPConst
(anonymous namespace)::BitcastOfBitcast
(anonymous namespace)::AndOfExtUI
(anonymous namespace)::AndOfExtSI
(anonymous namespace)::AddUIExtendedToAddI
(anonymous namespace)::AddIAddConstant
(anonymous namespace)::AddISubConstantRHS
(anonymous namespace)::AddISubConstantLHS
(anonymous namespace)::AddIMulNegativeOneRhs
(anonymous namespace)::AddIMulNegativeOneLhs
FoldTensorCastPackOp
FoldTensorCastProducerOp
CanonicalizeConvertFromConvert
CanonicalizeConvertFromReshape
CanonicalizeConvertFromHistogram
CanonicalizeConvertFromAlloc
CanonicalizeConvertFromLocalStore
CanonicalizeConvertFromSplit
(anonymous namespace)::InsertSliceOpConstantArgumentFolder<mlir::tensor::ParallelInsertSliceOp>
(anonymous namespace)::InsertSliceOpCastFolder<mlir::tensor::ParallelInsertSliceOp>
(anonymous namespace)::InsertSliceOpSourceCastInserter<mlir::tensor::ParallelInsertSliceOp>
(anonymous namespace)::FoldStaticZeroPadding
(anonymous namespace)::FoldSourceTensorCast
(anonymous namespace)::FoldTargetTensorCast
(anonymous namespace)::FoldOrthogonalPaddings
(anonymous namespace)::FoldStaticPadding
(anonymous namespace)::FoldConsecutiveConstantPadding
(anonymous namespace)::InsertSliceOpConstantArgumentFolder<mlir::tensor::InsertSliceOp>
(anonymous namespace)::InsertSliceOpCastFolder<mlir::tensor::InsertSliceOp>
(anonymous namespace)::InsertSliceOpSourceCastInserter<mlir::tensor::InsertSliceOp>
(anonymous namespace)::ExtractFromTensorGenerate
(anonymous namespace)::StaticTensorGenerate
(anonymous namespace)::ExtractElementFromIndexCast
mlir::OpWithOffsetSizesAndStridesConstantArgumentFolder<mlir::tensor::ExtractSliceOp, SliceReturnTypeCanonicalizer, SliceCanonicalizer>
(anonymous namespace)::ExtractSliceOpCastFolder
(anonymous namespace)::ExtractFromTensorCast
mlir::ComposeReassociativeReshapeOps<mlir::tensor::ExpandShapeOp, mlir::ReshapeOpKind::kExpand>
mlir::ComposeExpandOfCollapseOp<mlir::tensor::ExpandShapeOp, mlir::tensor::CollapseShapeOp>
(anonymous namespace)::ConvertToStaticExpandShape
(anonymous namespace)::FoldReshapeWithConstant<mlir::tensor::ExpandShapeOp>
(anonymous namespace)::FoldReshapeWithSplat<mlir::tensor::ExpandShapeOp>
(anonymous namespace)::FoldReshapeWithFromElements<mlir::tensor::ExpandShapeOp>
(anonymous namespace)::FoldDimOfExpandShape
(anonymous namespace)::FoldDimOfCollapseShape
(anonymous namespace)::FoldEmptyTensorWithCastOp
(anonymous namespace)::FoldEmptyTensorWithDimOp
(anonymous namespace)::ReplaceEmptyTensorStaticShapeDims
(anonymous namespace)::DimOfCastOp
(anonymous namespace)::DimOfDestStyleOp
(anonymous namespace)::DimOfReshapeOp
(anonymous namespace)::SingleInputConcatOp
mlir::ComposeReassociativeReshapeOps<mlir::tensor::CollapseShapeOp, mlir::ReshapeOpKind::kCollapse>
mlir::ComposeCollapseOfExpandOp<mlir::tensor::CollapseShapeOp, mlir::tensor::ExpandShapeOp, mlir::tensor::CastOp, mlir::tensor::DimOp, mlir::RankedTensorType>
(anonymous namespace)::FoldReshapeWithConstant<mlir::tensor::CollapseShapeOp>
(anonymous namespace)::FoldReshapeWithSplat<mlir::tensor::CollapseShapeOp>
(anonymous namespace)::FoldReshapeWithFromElements<mlir::tensor::CollapseShapeOp>
(anonymous namespace)::FoldCollapseOfCastOp
(anonymous namespace)::ChainedTensorCast
(anonymous namespace)::TensorCastExtractSlice
(anonymous namespace)::ChainedTensorBitcast
(anonymous namespace)::FoldComponentNeg<mlir::complex::ReOp, 0>
(anonymous namespace)::FoldComponentNeg<mlir::complex::ImOp, 1>
MergeComplexBitcast
MergeArithBitcast
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffineVectorStoreOp>
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffineVectorLoadOp>
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffineStoreOp>
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffinePrefetchOp>
CanonicalizeSingleResultAffineMinMaxOp<mlir::affine::AffineMinOp>
DeduplicateAffineMinMaxExpressions<mlir::affine::AffineMinOp>
MergeAffineMinMaxOp<mlir::affine::AffineMinOp>
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffineMinOp>
CanonicalizeAffineMinMaxOpExprAndTermOrder<mlir::affine::AffineMinOp>
CanonicalizeSingleResultAffineMinMaxOp<mlir::affine::AffineMaxOp>
DeduplicateAffineMinMaxExpressions<mlir::affine::AffineMaxOp>
MergeAffineMinMaxOp<mlir::affine::AffineMaxOp>
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffineMaxOp>
CanonicalizeAffineMinMaxOpExprAndTermOrder<mlir::affine::AffineMaxOp>
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffineLoadOp>
(anonymous namespace)::CancelLinearizeOfDelinearizeExact
(anonymous namespace)::DropLinearizeLeadingZero
(anonymous namespace)::DropLinearizeUnitComponentsIfDisjointOrZero
(anonymous namespace)::SimplifyDeadElse
(anonymous namespace)::AlwaysTrueOrFalseIf
(anonymous namespace)::AffineForEmptyLoopFolder
(anonymous namespace)::CancelDelinearizeOfLinearizeDisjointExactTail
(anonymous namespace)::DropUnitExtentBasis
(anonymous namespace)::SplitDelinearizeSpanningLastLinearizeArg
(anonymous namespace)::SimplifyAffineOp<mlir::affine::AffineApplyOp>
(anonymous namespace)::EraseRedundantGpuWaitOpPairs
(anonymous namespace)::SimplifyGpuWaitOp
(anonymous namespace)::EraseTrivialCopyOp
FoldLaunchArguments
(anonymous namespace)::SimplifyDimOfAllocOp
mlir::triton::CanonicalizeMaskedStorePattern
mlir::triton::CanonicalizeMaskedLoadPattern
```
</pre>
<img width="1" height="1" alt=""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