[llvm] [DAG] Fold pow2 masked bittest comparisons (PR #216302)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 18 10:00:05 PDT 2026


================
@@ -6778,6 +6778,26 @@ SDValue DAGCombiner::foldLogicOfSetCCs(bool IsAnd, SDValue N0, SDValue N1,
     }
   }
 
+  // (and (setne (and X, LL1), 0), (setne (and X, RL1), 0))
+  // --> (seteq (and X, (LL1|RL1)), (LL1|RL1))
+  // (or  (seteq (and X, LL1), 0), (seteq (and X, RL1), 0))
+  // --> (setne (and X, (LL1|RL1)), (LL1|RL1))
+  if (LL.getOpcode() == ISD::AND && RL.getOpcode() == ISD::AND &&
+      isNullConstant(LR) && isNullConstant(RR) && CC0 == CC1 &&
+      (CC0 == ISD::SETNE || CC0 == ISD::SETEQ)) {
----------------
RKSimon wrote:

do we have test coverage for all and/or + setne/seteq combos?

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


More information about the llvm-commits mailing list