[llvm] [VPlan] Introduce m_Cmp; match more compares (PR #154771)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 21 08:21:55 PDT 2025
================
@@ -1106,18 +1106,16 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
return Def->replaceAllUsesWith(A);
// Try to fold Not into compares by adjusting the predicate in-place.
- if (isa<VPWidenRecipe>(A) && A->getNumUsers() == 1) {
- auto *WideCmp = cast<VPWidenRecipe>(A);
- if (WideCmp->getOpcode() == Instruction::ICmp ||
- WideCmp->getOpcode() == Instruction::FCmp) {
- WideCmp->setPredicate(
- CmpInst::getInversePredicate(WideCmp->getPredicate()));
- Def->replaceAllUsesWith(WideCmp);
- // If WideCmp doesn't have a debug location, use the one from the
- // negation, to preserve the location.
- if (!WideCmp->getDebugLoc() && R.getDebugLoc())
- WideCmp->setDebugLoc(R.getDebugLoc());
- }
+ CmpPredicate Pred;
+ if (match(A, m_Cmp(Pred, m_VPValue(), m_VPValue())) &&
+ A->getNumUsers() == 1) {
+ auto *Cmp = cast<VPRecipeWithIRFlags>(A);
+ Cmp->setPredicate(CmpInst::getInversePredicate(Pred));
+ Def->replaceAllUsesWith(Cmp);
+ // If WideCmp doesn't have a debug location, use the one from the
----------------
lukel97 wrote:
```suggestion
// If Cmp doesn't have a debug location, use the one from the
```
https://github.com/llvm/llvm-project/pull/154771
More information about the llvm-commits
mailing list