[llvm] [InstCombine] Fold `select Cond, not X, X` into `Cond ^ X` (PR #90089)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 25 19:34:04 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)
----------------
nikic wrote:

Would it cover the motivating cases to check for icmp with same operands and inverted predicate?

This is a pretty weird check and I'm not sure if doing the poison check in one direction is sufficient here.

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


More information about the llvm-commits mailing list