[llvm] [InstCombine] Fold `select Cond, not X, X` into `Cond ^ X` (PR #90089)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon May 13 00:11:46 PDT 2024
================
@@ -3985,5 +3985,10 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
}
}
+ if (CondVal->getType() == SI.getType() && impliesPoison(FalseVal, TrueVal) &&
+ isImpliedCondition(FalseVal, TrueVal, DL, /*LHSIsTrue=*/true) == false &&
+ isImpliedCondition(FalseVal, TrueVal, DL, /*LHSIsTrue=*/false) == true)
----------------
dtcxzyw wrote:
When FVal implies TVal and !FVal -> !TVal, TVal must be the same as FVal. If not, we need a canonicalization for this pattern.
BTW, I tried `isImpliedCondition(FalseVal, TrueVal, DL, /*LHSIsTrue=*/true) == true && isImpliedCondition(FalseVal, TrueVal, DL, /*LHSIsTrue=*/false) == false` before submitting this patch. But it didn't improve the result.
https://github.com/llvm/llvm-project/pull/90089
More information about the llvm-commits
mailing list