[llvm] [DAG] Generalize setcc(setcc) fold to use known bits. (PR #66503)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 15 07:44:38 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) &&
isTypeLegal(VT) && VT.bitsLE(N0.getValueType()) &&
(N0.getValueType() == MVT::i1 ||
- getBooleanContents(N0.getOperand(0).getValueType()) ==
- ZeroOrOneBooleanContent)) {
+ getBooleanContents(N0.getValueType()) == ZeroOrOneBooleanContent) &&
+ DAG.MaskedValueIsZero(
+ N0, APInt::getHighBitsSet(N0.getValueSizeInBits(),
----------------
topperc wrote:
APInt::getBitsSetFrom(N0.getValueSizeInBits(), 1)
https://github.com/llvm/llvm-project/pull/66503
More information about the llvm-commits
mailing list