Skip to content

Commit 3cf1f0c

Browse files
authored
[ARM] Pattern match Low Overhead Loops pseudos (NFC) (#168209)
Pull Request: llvm/llvm-project#168209
1 parent 94e9bfb commit 3cf1f0c

File tree

2 files changed

+24
-43
lines changed

2 files changed

+24
-43
lines changed

llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3965,31 +3965,6 @@ void ARMDAGToDAGISel::Select(SDNode *N) {
39653965
return;
39663966
// Other cases are autogenerated.
39673967
break;
3968-
case ARMISD::WLSSETUP: {
3969-
SDNode *New = CurDAG->getMachineNode(ARM::t2WhileLoopSetup, dl, MVT::i32,
3970-
N->getOperand(0));
3971-
ReplaceUses(N, New);
3972-
CurDAG->RemoveDeadNode(N);
3973-
return;
3974-
}
3975-
case ARMISD::WLS: {
3976-
SDNode *New = CurDAG->getMachineNode(ARM::t2WhileLoopStart, dl, MVT::Other,
3977-
N->getOperand(1), N->getOperand(2),
3978-
N->getOperand(0));
3979-
ReplaceUses(N, New);
3980-
CurDAG->RemoveDeadNode(N);
3981-
return;
3982-
}
3983-
case ARMISD::LE: {
3984-
SDValue Ops[] = { N->getOperand(1),
3985-
N->getOperand(2),
3986-
N->getOperand(0) };
3987-
unsigned Opc = ARM::t2LoopEnd;
3988-
SDNode *New = CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops);
3989-
ReplaceUses(N, New);
3990-
CurDAG->RemoveDeadNode(N);
3991-
return;
3992-
}
39933968
case ARMISD::LDRD: {
39943969
if (Subtarget->isThumb2())
39953970
break; // TableGen handles isel in this case.
@@ -4043,17 +4018,6 @@ void ARMDAGToDAGISel::Select(SDNode *N) {
40434018
CurDAG->RemoveDeadNode(N);
40444019
return;
40454020
}
4046-
case ARMISD::LOOP_DEC: {
4047-
SDValue Ops[] = { N->getOperand(1),
4048-
N->getOperand(2),
4049-
N->getOperand(0) };
4050-
SDNode *Dec =
4051-
CurDAG->getMachineNode(ARM::t2LoopDec, dl,
4052-
CurDAG->getVTList(MVT::i32, MVT::Other), Ops);
4053-
ReplaceUses(N, Dec);
4054-
CurDAG->RemoveDeadNode(N);
4055-
return;
4056-
}
40574021
case ARMISD::BRCOND: {
40584022
// Pattern: (ARMbrcond:void (bb:Other):$dst, (imm:i32):$cc)
40594023
// Emits: (Bcc:void (bb:Other):$dst, (imm:i32):$cc)

llvm/lib/Target/ARM/ARMInstrThumb2.td

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5581,6 +5581,20 @@ class t2LOL<dag oops, dag iops, string asm, string ops>
55815581
let Predicates = [IsThumb2, HasV8_1MMainline, HasLOB];
55825582
}
55835583

5584+
def arm_wlssetup
5585+
: SDNode<"ARMISD::WLSSETUP",
5586+
SDTypeProfile<1, 1, [SDTCisInt<0>, SDTCisSameAs<1, 0>]>>;
5587+
5588+
def arm_wls : SDNode<"ARMISD::WLS",
5589+
SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisVT<1, OtherVT>]>,
5590+
[SDNPHasChain]>;
5591+
5592+
def arm_loop_dec : SDNode<"ARMISD::LOOP_DEC", SDTIntBinOp, [SDNPHasChain]>;
5593+
5594+
def arm_le : SDNode<"ARMISD::LE",
5595+
SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisVT<1, OtherVT>]>,
5596+
[SDNPHasChain]>;
5597+
55845598
let isNotDuplicable = 1 in {
55855599
def t2WLS : t2LOL<(outs GPRlr:$LR),
55865600
(ins rGPR:$Rn, wlslabel_u11:$label),
@@ -5651,24 +5665,26 @@ def t2DoLoopStartTP :
56515665
// valid after reg alloc, as it should be lowered during MVETPAndVPTOptimisations
56525666
// into a t2WhileLoopStartLR (or expanded).
56535667
def t2WhileLoopSetup :
5654-
t2PseudoInst<(outs GPRlr:$lr), (ins rGPR:$tc), 4, IIC_Br, []>;
5668+
t2PseudoInst<(outs GPRlr:$lr), (ins rGPR:$tc), 4, IIC_Br,
5669+
[(set i32:$lr, (arm_wlssetup i32:$tc))]>;
56555670

56565671
// A pseudo to represent the decrement in a low overhead loop. A t2LoopDec and
56575672
// t2LoopEnd together represent a LE instruction. Ideally these are converted
56585673
// to a t2LoopEndDec which is lowered as a single instruction.
56595674
let hasSideEffects = 0 in
56605675
def t2LoopDec :
5661-
t2PseudoInst<(outs GPRlr:$Rm), (ins GPRlr:$Rn, imm0_7:$size),
5662-
4, IIC_Br, []>, Sched<[WriteBr]>;
5676+
t2PseudoInst<(outs GPRlr:$Rm), (ins GPRlr:$Rn, imm0_7:$size), 4, IIC_Br,
5677+
[(set i32:$Rm, (arm_loop_dec i32:$Rn, timm:$size))]>,
5678+
Sched<[WriteBr]>;
56635679

56645680
let isBranch = 1, isTerminator = 1, hasSideEffects = 1, Defs = [CPSR] in {
56655681
// The branch in a t2WhileLoopSetup/t2WhileLoopStart pair, eventually turned
56665682
// into a t2WhileLoopStartLR that does both the LR setup and branch.
56675683
def t2WhileLoopStart :
56685684
t2PseudoInst<(outs),
56695685
(ins GPRlr:$tc, brtarget:$target),
5670-
4, IIC_Br, []>,
5671-
Sched<[WriteBr]>;
5686+
4, IIC_Br, [(arm_wls i32:$tc, bb:$target)]>,
5687+
Sched<[WriteBr]>;
56725688

56735689
// WhileLoopStartLR that sets up LR and branches on zero, equivalent to WLS. It
56745690
// is lowered in the ARMLowOverheadLoops pass providing the branches are within
@@ -5690,8 +5706,9 @@ def t2WhileLoopStartTP :
56905706

56915707
// t2LoopEnd - the branch half of a t2LoopDec/t2LoopEnd pair.
56925708
def t2LoopEnd :
5693-
t2PseudoInst<(outs), (ins GPRlr:$tc, brtarget:$target),
5694-
8, IIC_Br, []>, Sched<[WriteBr]>;
5709+
t2PseudoInst<(outs), (ins GPRlr:$tc, brtarget:$target),
5710+
8, IIC_Br, [(arm_le i32:$tc, bb:$target)]>,
5711+
Sched<[WriteBr]>;
56955712

56965713
// The combination of a t2LoopDec and t2LoopEnd, performing both the LR
56975714
// decrement and branch as a single instruction. Is lowered to a LE or

0 commit comments

Comments
 (0)