Skip to content

Commit a348f22

Browse files
authored
[ARM] Stop gluing ALU nodes to branches / selects (#116970)
Following #116547 and #116676, this PR changes the type of results and operands of some nodes to accept / return a normal type instead of Glue. Unfortunately, changing the result type of one node requires changing the operand types of all potential consumer nodes, which in turn requires changing the result types of all other possible producer nodes. So this is a bulk change. Pull Request: #116970
1 parent 691e556 commit a348f22

File tree

83 files changed

+10027
-11288
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+10027
-11288
lines changed

llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,6 @@ class ARMDAGToDAGISel : public SelectionDAGISel {
111111
bool SelectAddrModeImm12(SDValue N, SDValue &Base, SDValue &OffImm);
112112
bool SelectLdStSOReg(SDValue N, SDValue &Base, SDValue &Offset, SDValue &Opc);
113113

114-
bool SelectCMOVPred(SDValue N, SDValue &Pred, SDValue &Reg) {
115-
const ConstantSDNode *CN = cast<ConstantSDNode>(N);
116-
Pred = CurDAG->getTargetConstant(CN->getZExtValue(), SDLoc(N), MVT::i32);
117-
Reg = CurDAG->getRegister(ARM::CPSR, MVT::i32);
118-
return true;
119-
}
120-
121114
bool SelectAddrMode2OffsetReg(SDNode *Op, SDValue N,
122115
SDValue &Offset, SDValue &Opc);
123116
bool SelectAddrMode2OffsetImm(SDNode *Op, SDValue N,
@@ -4123,17 +4116,15 @@ void ARMDAGToDAGISel::Select(SDNode *N) {
41234116
SDValue Chain = N->getOperand(0);
41244117
SDValue N1 = N->getOperand(1);
41254118
SDValue N2 = N->getOperand(2);
4126-
SDValue N3 = N->getOperand(3);
4127-
SDValue InGlue = N->getOperand(4);
4119+
SDValue Flags = N->getOperand(3);
41284120
assert(N1.getOpcode() == ISD::BasicBlock);
41294121
assert(N2.getOpcode() == ISD::Constant);
4130-
assert(N3.getOpcode() == ISD::Register);
41314122

41324123
unsigned CC = (unsigned)N2->getAsZExtVal();
41334124

4134-
if (InGlue.getOpcode() == ARMISD::CMPZ) {
4135-
if (InGlue.getOperand(0).getOpcode() == ISD::INTRINSIC_W_CHAIN) {
4136-
SDValue Int = InGlue.getOperand(0);
4125+
if (Flags.getOpcode() == ARMISD::CMPZ) {
4126+
if (Flags.getOperand(0).getOpcode() == ISD::INTRINSIC_W_CHAIN) {
4127+
SDValue Int = Flags.getOperand(0);
41374128
uint64_t ID = Int->getConstantOperandVal(1);
41384129

41394130
// Handle low-overhead loops.
@@ -4155,15 +4146,15 @@ void ARMDAGToDAGISel::Select(SDNode *N) {
41554146

41564147
ReplaceUses(N, LoopEnd);
41574148
CurDAG->RemoveDeadNode(N);
4158-
CurDAG->RemoveDeadNode(InGlue.getNode());
4149+
CurDAG->RemoveDeadNode(Flags.getNode());
41594150
CurDAG->RemoveDeadNode(Int.getNode());
41604151
return;
41614152
}
41624153
}
41634154

41644155
bool SwitchEQNEToPLMI;
4165-
SelectCMPZ(InGlue.getNode(), SwitchEQNEToPLMI);
4166-
InGlue = N->getOperand(4);
4156+
SelectCMPZ(Flags.getNode(), SwitchEQNEToPLMI);
4157+
Flags = N->getOperand(3);
41674158

41684159
if (SwitchEQNEToPLMI) {
41694160
switch ((ARMCC::CondCodes)CC) {
@@ -4179,25 +4170,18 @@ void ARMDAGToDAGISel::Select(SDNode *N) {
41794170
}
41804171

41814172
SDValue Tmp2 = CurDAG->getTargetConstant(CC, dl, MVT::i32);
4182-
SDValue Ops[] = { N1, Tmp2, N3, Chain, InGlue };
4183-
SDNode *ResNode = CurDAG->getMachineNode(Opc, dl, MVT::Other,
4184-
MVT::Glue, Ops);
4185-
Chain = SDValue(ResNode, 0);
4186-
if (N->getNumValues() == 2) {
4187-
InGlue = SDValue(ResNode, 1);
4188-
ReplaceUses(SDValue(N, 1), InGlue);
4189-
}
4190-
ReplaceUses(SDValue(N, 0),
4191-
SDValue(Chain.getNode(), Chain.getResNo()));
4192-
CurDAG->RemoveDeadNode(N);
4173+
Chain = CurDAG->getCopyToReg(Chain, dl, ARM::CPSR, Flags, SDValue());
4174+
SDValue Ops[] = {N1, Tmp2, CurDAG->getRegister(ARM::CPSR, MVT::i32), Chain,
4175+
Chain.getValue(1)};
4176+
CurDAG->SelectNodeTo(N, Opc, MVT::Other, Ops);
41934177
return;
41944178
}
41954179

41964180
case ARMISD::CMPZ: {
41974181
// select (CMPZ X, #-C) -> (CMPZ (ADDS X, #C), #0)
41984182
// This allows us to avoid materializing the expensive negative constant.
4199-
// The CMPZ #0 is useless and will be peepholed away but we need to keep it
4200-
// for its glue output.
4183+
// The CMPZ #0 is useless and will be peepholed away but we need to keep
4184+
// it for its flags output.
42014185
SDValue X = N->getOperand(0);
42024186
auto *C = dyn_cast<ConstantSDNode>(N->getOperand(1).getNode());
42034187
if (C && C->getSExtValue() < 0 && Subtarget->isThumb()) {
@@ -4224,19 +4208,19 @@ void ARMDAGToDAGISel::Select(SDNode *N) {
42244208
}
42254209
if (Add) {
42264210
SDValue Ops2[] = {SDValue(Add, 0), CurDAG->getConstant(0, dl, MVT::i32)};
4227-
CurDAG->MorphNodeTo(N, ARMISD::CMPZ, CurDAG->getVTList(MVT::Glue), Ops2);
4211+
CurDAG->MorphNodeTo(N, ARMISD::CMPZ, N->getVTList(), Ops2);
42284212
}
42294213
}
42304214
// Other cases are autogenerated.
42314215
break;
42324216
}
42334217

42344218
case ARMISD::CMOV: {
4235-
SDValue InGlue = N->getOperand(4);
4219+
SDValue Flags = N->getOperand(3);
42364220

4237-
if (InGlue.getOpcode() == ARMISD::CMPZ) {
4221+
if (Flags.getOpcode() == ARMISD::CMPZ) {
42384222
bool SwitchEQNEToPLMI;
4239-
SelectCMPZ(InGlue.getNode(), SwitchEQNEToPLMI);
4223+
SelectCMPZ(Flags.getNode(), SwitchEQNEToPLMI);
42404224

42414225
if (SwitchEQNEToPLMI) {
42424226
SDValue ARMcc = N->getOperand(2);
@@ -4253,10 +4237,9 @@ void ARMDAGToDAGISel::Select(SDNode *N) {
42534237
}
42544238
SDValue NewARMcc = CurDAG->getConstant((unsigned)CC, dl, MVT::i32);
42554239
SDValue Ops[] = {N->getOperand(0), N->getOperand(1), NewARMcc,
4256-
N->getOperand(3), N->getOperand(4)};
4240+
N->getOperand(3)};
42574241
CurDAG->MorphNodeTo(N, ARMISD::CMOV, N->getVTList(), Ops);
42584242
}
4259-
42604243
}
42614244
// Other cases are autogenerated.
42624245
break;

0 commit comments

Comments
 (0)