[llvm] [X86] Match SETCC_CARRY in addition of SUB when trying to reconstruct LEA (PR #126551)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 12 06:03:08 PST 2025
================
@@ -51985,21 +51985,30 @@ static SDValue combineOr(SDNode *N, SelectionDAG &DAG,
return R;
// (0 - SetCC) | C -> (zext (not SetCC)) * (C + 1) - 1 if we can get a LEA out of it.
- if ((VT == MVT::i32 || VT == MVT::i64) &&
- N0.getOpcode() == ISD::SUB && N0.hasOneUse() &&
- isNullConstant(N0.getOperand(0))) {
- SDValue Cond = N0.getOperand(1);
- if (Cond.getOpcode() == ISD::ZERO_EXTEND && Cond.hasOneUse())
- Cond = Cond.getOperand(0);
-
- if (Cond.getOpcode() == X86ISD::SETCC && Cond.hasOneUse()) {
- if (auto *CN = dyn_cast<ConstantSDNode>(N1)) {
- uint64_t Val = CN->getZExtValue();
- if (Val == 1 || Val == 2 || Val == 3 || Val == 4 || Val == 7 || Val == 8) {
- X86::CondCode CCode = (X86::CondCode)Cond.getConstantOperandVal(0);
- CCode = X86::GetOppositeBranchCondition(CCode);
- SDValue NotCond = getSETCC(CCode, Cond.getOperand(1), SDLoc(Cond), DAG);
+ if (VT == MVT::i32 || VT == MVT::i64) {
+ if (auto *CN = dyn_cast<ConstantSDNode>(N1)) {
+ unsigned Val = CN->getZExtValue();
+ if (Val == 1 || Val == 2 || Val == 3 || Val == 4 || Val == 7 ||
+ Val == 8) {
+ SDValue NotCond;
+ if (N0.getOpcode() == X86ISD::SETCC_CARRY && N0.hasOneUse() &&
+ N0.getOperand(1).hasOneUse()) {
----------------
phoebewang wrote:
`N0.hasOneUse() && N0.getOperand(1).hasOneUse()` can be hoisted out?
https://github.com/llvm/llvm-project/pull/126551
More information about the llvm-commits
mailing list