[llvm] [DAG] Generalize setcc(setcc) fold to use known bits. (PR #66503)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 15 10:47:24 PDT 2023


================
@@ -4652,21 +4652,25 @@ SDValue TargetLowering::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
                           DAG.getConstant(C1 & Imm, dl, ExtDstTy), Cond);
     } else if ((N1C->isZero() || N1C->isOne()) &&
                (Cond == ISD::SETEQ || Cond == ISD::SETNE)) {
-      // SETCC (SETCC), [0|1], [EQ|NE]  -> SETCC
-      if (N0.getOpcode() == ISD::SETCC &&
+      // SETCC (X), [0|1], [EQ|NE]  -> X if X is known 0/1
+      if ((N0.getOpcode() == ISD::SETCC || VT != MVT::i1) &&
----------------
goldsteinn wrote:

I don't quite understand the `VT != MVT::i1` here. Doesn't that break things like `setcc (setcc ...))`

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


More information about the llvm-commits mailing list