[llvm] [DAG] Generalize setcc(setcc) fold to use known bits. (PR #66503)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 19 03:14:21 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) &&
----------------
davemgreen wrote:
It will do the transform if it is a setcc, or if the type _isn't_ an i1. i1 types are trivially true for the known bits combine, and handled further below when the foldBools flag is set.
https://github.com/llvm/llvm-project/pull/66503
More information about the llvm-commits
mailing list