Skip to content

Commit ce48f43

Browse files
authored
[SelectionDAG] Require UADDO_CARRY carryin and carryout to have the same type. (#89255)
This requires type legalization to keep them the same. This means we no longer need to legalize the operand since it will be legalized when we legalize the second result.
1 parent adc11b3 commit ce48f43

File tree

4 files changed

+4
-23
lines changed

4 files changed

+4
-23
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3359,7 +3359,7 @@ SDValue DAGCombiner::visitUADDO_CARRY(SDNode *N) {
33593359
}
33603360

33613361
/**
3362-
* If we are facing some sort of diamond carry propapagtion pattern try to
3362+
* If we are facing some sort of diamond carry propagation pattern try to
33633363
* break it up to generate something like:
33643364
* (uaddo_carry X, 0, (uaddo_carry A, B, Z):Carry)
33653365
*
@@ -3400,7 +3400,7 @@ static SDValue combineUADDO_CARRYDiamond(DAGCombiner &Combiner,
34003400
Z = Carry0.getOperand(2);
34013401
} else if (Carry0.getOpcode() == ISD::UADDO &&
34023402
isOneConstant(Carry0.getOperand(1))) {
3403-
EVT VT = Combiner.getSetCCResultType(Carry0.getValueType());
3403+
EVT VT = Carry0->getValueType(1);
34043404
Z = DAG.getConstant(1, SDLoc(Carry0.getOperand(1)), VT);
34053405
} else {
34063406
// We couldn't find a suitable Z.

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_Overflow(SDNode *N) {
949949
unsigned NumOps = N->getNumOperands();
950950
assert(NumOps <= 3 && "Too many operands");
951951
if (NumOps == 3)
952-
Ops[2] = N->getOperand(2);
952+
Ops[2] = PromoteTargetBoolean(N->getOperand(2), VT);
953953

954954
SDLoc dl(N);
955955
SDValue Res = DAG.getNode(N->getOpcode(), dl, DAG.getVTList(VT, SVT),
@@ -1867,11 +1867,6 @@ bool DAGTypeLegalizer::PromoteIntegerOperand(SDNode *N, unsigned OpNo) {
18671867
case ISD::FSHL:
18681868
case ISD::FSHR: Res = PromoteIntOp_FunnelShift(N); break;
18691869

1870-
case ISD::SADDO_CARRY:
1871-
case ISD::SSUBO_CARRY:
1872-
case ISD::UADDO_CARRY:
1873-
case ISD::USUBO_CARRY: Res = PromoteIntOp_ADDSUBO_CARRY(N, OpNo); break;
1874-
18751870
case ISD::FRAMEADDR:
18761871
case ISD::RETURNADDR: Res = PromoteIntOp_FRAMERETURNADDR(N); break;
18771872

@@ -2373,19 +2368,6 @@ SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(SDNode *N) {
23732368
N->getOperand(1), N->getOperand(2));
23742369
}
23752370

2376-
SDValue DAGTypeLegalizer::PromoteIntOp_ADDSUBO_CARRY(SDNode *N, unsigned OpNo) {
2377-
assert(OpNo == 2 && "Don't know how to promote this operand!");
2378-
2379-
SDValue LHS = N->getOperand(0);
2380-
SDValue RHS = N->getOperand(1);
2381-
SDValue Carry = N->getOperand(2);
2382-
SDLoc DL(N);
2383-
2384-
Carry = PromoteTargetBoolean(Carry, LHS.getValueType());
2385-
2386-
return SDValue(DAG.UpdateNodeOperands(N, LHS, RHS, Carry), 0);
2387-
}
2388-
23892371
SDValue DAGTypeLegalizer::PromoteIntOp_FIX(SDNode *N) {
23902372
SDValue Op2 = ZExtPromotedInteger(N->getOperand(2));
23912373
return SDValue(

llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
389389
SDValue PromoteIntOp_MLOAD(MaskedLoadSDNode *N, unsigned OpNo);
390390
SDValue PromoteIntOp_MSCATTER(MaskedScatterSDNode *N, unsigned OpNo);
391391
SDValue PromoteIntOp_MGATHER(MaskedGatherSDNode *N, unsigned OpNo);
392-
SDValue PromoteIntOp_ADDSUBO_CARRY(SDNode *N, unsigned OpNo);
393392
SDValue PromoteIntOp_FRAMERETURNADDR(SDNode *N);
394393
SDValue PromoteIntOp_FIX(SDNode *N);
395394
SDValue PromoteIntOp_ExpOp(SDNode *N);

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9924,7 +9924,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
99249924
assert(VTList.VTs[0].isInteger() && VTList.VTs[1].isInteger() &&
99259925
Ops[0].getValueType() == Ops[1].getValueType() &&
99269926
Ops[0].getValueType() == VTList.VTs[0] &&
9927-
Ops[2].getValueType().isInteger() &&
9927+
Ops[2].getValueType() == VTList.VTs[1] &&
99289928
"Binary operator types must match!");
99299929
break;
99309930
case ISD::SMUL_LOHI:

0 commit comments

Comments
 (0)