[llvm] [InstSimplify] Simplify select if it combinated `and/or/xor` (PR #73362)

via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 26 16:32:46 PST 2023


================
@@ -4572,12 +4614,37 @@ static Value *simplifySelectWithICmpCond(Value *CondVal, Value *TrueVal,
                                          unsigned MaxRecurse) {
   ICmpInst::Predicate Pred;
   Value *CmpLHS, *CmpRHS;
+  const APInt *C;
   if (!match(CondVal, m_ICmp(Pred, m_Value(CmpLHS), m_Value(CmpRHS))))
     return nullptr;
 
   if (Value *V = simplifyCmpSelOfMaxMin(CmpLHS, CmpRHS, Pred, TrueVal, FalseVal))
     return V;
 
+  if (ICmpInst::isEquality(Pred) && match(CmpRHS, m_APInt(C)) &&
+      (C->isZero() | C->isOne())) {
+    bool which;
+    Value *X, *Y;
+
+    if (Pred == ICmpInst::ICMP_EQ)
+      which = C->isZero() ? false : true;
+    else
+      which = C->isZero() ? true : false;
----------------
ParkHanbum wrote:

which is removed now but I'll remember that your advises. thanks

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


More information about the llvm-commits mailing list