Skip to content

Commit 508e70f

Browse files
committed
[ARM] Stop gluing ALU nodes to branches / selects
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.
1 parent 8c56dd3 commit 508e70f

File tree

82 files changed

+9967
-11244
lines changed

Some content is hidden

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

82 files changed

+9967
-11244
lines changed

llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4123,17 +4123,15 @@ void ARMDAGToDAGISel::Select(SDNode *N) {
41234123
SDValue Chain = N->getOperand(0);
41244124
SDValue N1 = N->getOperand(1);
41254125
SDValue N2 = N->getOperand(2);
4126-
SDValue N3 = N->getOperand(3);
4127-
SDValue InGlue = N->getOperand(4);
4126+
SDValue Flags = N->getOperand(3);
41284127
assert(N1.getOpcode() == ISD::BasicBlock);
41294128
assert(N2.getOpcode() == ISD::Constant);
4130-
assert(N3.getOpcode() == ISD::Register);
41314129

41324130
unsigned CC = (unsigned)N2->getAsZExtVal();
41334131

4134-
if (InGlue.getOpcode() == ARMISD::CMPZ) {
4135-
if (InGlue.getOperand(0).getOpcode() == ISD::INTRINSIC_W_CHAIN) {
4136-
SDValue Int = InGlue.getOperand(0);
4132+
if (Flags.getOpcode() == ARMISD::CMPZ) {
4133+
if (Flags.getOperand(0).getOpcode() == ISD::INTRINSIC_W_CHAIN) {
4134+
SDValue Int = Flags.getOperand(0);
41374135
uint64_t ID = Int->getConstantOperandVal(1);
41384136

41394137
// Handle low-overhead loops.
@@ -4155,15 +4153,15 @@ void ARMDAGToDAGISel::Select(SDNode *N) {
41554153

41564154
ReplaceUses(N, LoopEnd);
41574155
CurDAG->RemoveDeadNode(N);
4158-
CurDAG->RemoveDeadNode(InGlue.getNode());
4156+
CurDAG->RemoveDeadNode(Flags.getNode());
41594157
CurDAG->RemoveDeadNode(Int.getNode());
41604158
return;
41614159
}
41624160
}
41634161

41644162
bool SwitchEQNEToPLMI;
4165-
SelectCMPZ(InGlue.getNode(), SwitchEQNEToPLMI);
4166-
InGlue = N->getOperand(4);
4163+
SelectCMPZ(Flags.getNode(), SwitchEQNEToPLMI);
4164+
Flags = N->getOperand(3);
41674165

41684166
if (SwitchEQNEToPLMI) {
41694167
switch ((ARMCC::CondCodes)CC) {
@@ -4178,26 +4176,22 @@ void ARMDAGToDAGISel::Select(SDNode *N) {
41784176
}
41794177
}
41804178

4179+
SDValue InChain =
4180+
CurDAG->getCopyToReg(Chain, dl, ARM::CPSR, Flags, SDValue());
4181+
SDValue InGlue = InChain.getValue(1);
4182+
41814183
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);
4184+
SDValue Ops[] = {N1, Tmp2, CurDAG->getRegister(ARM::CPSR, MVT::i32),
4185+
InChain, InGlue};
4186+
CurDAG->SelectNodeTo(N, Opc, MVT::Other, Ops);
41934187
return;
41944188
}
41954189

41964190
case ARMISD::CMPZ: {
41974191
// select (CMPZ X, #-C) -> (CMPZ (ADDS X, #C), #0)
41984192
// 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.
4193+
// The CMPZ #0 is useless and will be peepholed away but we need to keep
4194+
// it for its flags output.
42014195
SDValue X = N->getOperand(0);
42024196
auto *C = dyn_cast<ConstantSDNode>(N->getOperand(1).getNode());
42034197
if (C && C->getSExtValue() < 0 && Subtarget->isThumb()) {
@@ -4224,19 +4218,19 @@ void ARMDAGToDAGISel::Select(SDNode *N) {
42244218
}
42254219
if (Add) {
42264220
SDValue Ops2[] = {SDValue(Add, 0), CurDAG->getConstant(0, dl, MVT::i32)};
4227-
CurDAG->MorphNodeTo(N, ARMISD::CMPZ, CurDAG->getVTList(MVT::Glue), Ops2);
4221+
CurDAG->MorphNodeTo(N, ARMISD::CMPZ, N->getVTList(), Ops2);
42284222
}
42294223
}
42304224
// Other cases are autogenerated.
42314225
break;
42324226
}
42334227

42344228
case ARMISD::CMOV: {
4235-
SDValue InGlue = N->getOperand(4);
4229+
SDValue Flags = N->getOperand(3);
42364230

4237-
if (InGlue.getOpcode() == ARMISD::CMPZ) {
4231+
if (Flags.getOpcode() == ARMISD::CMPZ) {
42384232
bool SwitchEQNEToPLMI;
4239-
SelectCMPZ(InGlue.getNode(), SwitchEQNEToPLMI);
4233+
SelectCMPZ(Flags.getNode(), SwitchEQNEToPLMI);
42404234

42414235
if (SwitchEQNEToPLMI) {
42424236
SDValue ARMcc = N->getOperand(2);
@@ -4253,10 +4247,9 @@ void ARMDAGToDAGISel::Select(SDNode *N) {
42534247
}
42544248
SDValue NewARMcc = CurDAG->getConstant((unsigned)CC, dl, MVT::i32);
42554249
SDValue Ops[] = {N->getOperand(0), N->getOperand(1), NewARMcc,
4256-
N->getOperand(3), N->getOperand(4)};
4250+
N->getOperand(3)};
42574251
CurDAG->MorphNodeTo(N, ARMISD::CMOV, N->getVTList(), Ops);
42584252
}
4259-
42604253
}
42614254
// Other cases are autogenerated.
42624255
break;

0 commit comments

Comments
 (0)