Skip to content

Commit 17b4347

Browse files
committed
[ARM] Remove duplicate custom SDag node (NFCI)
ARMISD::SUBS is a duplicate of ARMISD::SUBC. The node was introduced in 5745b6a. This patch replaces SUBS with SUBC and reverts changes in *.td files.
1 parent a4a4366 commit 17b4347

File tree

5 files changed

+8
-31
lines changed

5 files changed

+8
-31
lines changed

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,6 @@ const char *ARMTargetLowering::getTargetNodeName(unsigned Opcode) const {
17131713
MAKE_CASE(ARMISD::BCC_i64)
17141714
MAKE_CASE(ARMISD::FMSTAT)
17151715
MAKE_CASE(ARMISD::CMOV)
1716-
MAKE_CASE(ARMISD::SUBS)
17171716
MAKE_CASE(ARMISD::SSAT)
17181717
MAKE_CASE(ARMISD::USAT)
17191718
MAKE_CASE(ARMISD::ASRL)
@@ -18461,9 +18460,9 @@ ARMTargetLowering::PerformCMOVCombine(SDNode *N, SelectionDAG &DAG) const {
1846118460
} else if (CC == ARMCC::NE && !isNullConstant(RHS) &&
1846218461
(!Subtarget->isThumb1Only() || isPowerOf2Constant(TrueVal))) {
1846318462
// This seems pointless but will allow us to combine it further below.
18464-
// CMOV 0, z, !=, (CMPZ x, y) -> CMOV (SUBS x, y), z, !=, (SUBS x, y):1
18463+
// CMOV 0, z, !=, (CMPZ x, y) -> CMOV (SUBC x, y), z, !=, (SUBC x, y):1
1846518464
SDValue Sub =
18466-
DAG.getNode(ARMISD::SUBS, dl, DAG.getVTList(VT, MVT::i32), LHS, RHS);
18465+
DAG.getNode(ARMISD::SUBC, dl, DAG.getVTList(VT, MVT::i32), LHS, RHS);
1846718466
SDValue CPSRGlue = DAG.getCopyToReg(DAG.getEntryNode(), dl, ARM::CPSR,
1846818467
Sub.getValue(1), SDValue());
1846918468
Res = DAG.getNode(ARMISD::CMOV, dl, VT, Sub, TrueVal, ARMcc,
@@ -18475,9 +18474,9 @@ ARMTargetLowering::PerformCMOVCombine(SDNode *N, SelectionDAG &DAG) const {
1847518474
(!Subtarget->isThumb1Only() || isPowerOf2Constant(FalseVal))) {
1847618475
// This seems pointless but will allow us to combine it further below
1847718476
// Note that we change == for != as this is the dual for the case above.
18478-
// CMOV z, 0, ==, (CMPZ x, y) -> CMOV (SUBS x, y), z, !=, (SUBS x, y):1
18477+
// CMOV z, 0, ==, (CMPZ x, y) -> CMOV (SUBC x, y), z, !=, (SUBC x, y):1
1847918478
SDValue Sub =
18480-
DAG.getNode(ARMISD::SUBS, dl, DAG.getVTList(VT, MVT::i32), LHS, RHS);
18479+
DAG.getNode(ARMISD::SUBC, dl, DAG.getVTList(VT, MVT::i32), LHS, RHS);
1848118480
SDValue CPSRGlue = DAG.getCopyToReg(DAG.getEntryNode(), dl, ARM::CPSR,
1848218481
Sub.getValue(1), SDValue());
1848318482
Res = DAG.getNode(ARMISD::CMOV, dl, VT, Sub, FalseVal,
@@ -18489,21 +18488,21 @@ ARMTargetLowering::PerformCMOVCombine(SDNode *N, SelectionDAG &DAG) const {
1848918488

1849018489
// On Thumb1, the DAG above may be further combined if z is a power of 2
1849118490
// (z == 2 ^ K).
18492-
// CMOV (SUBS x, y), z, !=, (SUBS x, y):1 ->
18491+
// CMOV (SUBC x, y), z, !=, (SUBC x, y):1 ->
1849318492
// t1 = (USUBO (SUB x, y), 1)
1849418493
// t2 = (USUBO_CARRY (SUB x, y), t1:0, t1:1)
1849518494
// Result = if K != 0 then (SHL t2:0, K) else t2:0
1849618495
//
1849718496
// This also handles the special case of comparing against zero; it's
18498-
// essentially, the same pattern, except there's no SUBS:
18497+
// essentially, the same pattern, except there's no SUBC:
1849918498
// CMOV x, z, !=, (CMPZ x, 0) ->
1850018499
// t1 = (USUBO x, 1)
1850118500
// t2 = (USUBO_CARRY x, t1:0, t1:1)
1850218501
// Result = if K != 0 then (SHL t2:0, K) else t2:0
1850318502
const APInt *TrueConst;
1850418503
if (Subtarget->isThumb1Only() && CC == ARMCC::NE &&
18505-
((FalseVal.getOpcode() == ARMISD::SUBS &&
18506-
FalseVal.getOperand(0) == LHS && FalseVal.getOperand(1) == RHS) ||
18504+
((FalseVal.getOpcode() == ARMISD::SUBC && FalseVal.getOperand(0) == LHS &&
18505+
FalseVal.getOperand(1) == RHS) ||
1850718506
(FalseVal == LHS && isNullConstant(RHS))) &&
1850818507
(TrueConst = isPowerOf2Constant(TrueVal))) {
1850918508
SDVTList VTs = DAG.getVTList(VT, MVT::i32);

llvm/lib/Target/ARM/ARMISelLowering.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ class VectorType;
9595
FMSTAT, // ARM fmstat instruction.
9696

9797
CMOV, // ARM conditional move instructions.
98-
SUBS, // Flag-setting subtraction.
9998

10099
SSAT, // Signed saturation
101100
USAT, // Unsigned saturation

llvm/lib/Target/ARM/ARMInstrInfo.td

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ def ARMintretglue : SDNode<"ARMISD::INTRET_GLUE", SDT_ARMcall,
160160
[SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
161161
def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
162162
[SDNPInGlue]>;
163-
def ARMsubs : SDNode<"ARMISD::SUBS", SDTIntBinOp, [SDNPOutGlue]>;
164163

165164
def ARMssat : SDNode<"ARMISD::SSAT", SDTIntSatNoShOp, []>;
166165

@@ -3879,14 +3878,6 @@ let isAdd = 1 in
38793878
defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMaddc, 1>;
38803879
defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMsubc>;
38813880

3882-
def : ARMPat<(ARMsubs GPR:$Rn, mod_imm:$imm), (SUBSri $Rn, mod_imm:$imm)>;
3883-
def : ARMPat<(ARMsubs GPR:$Rn, GPR:$Rm), (SUBSrr $Rn, $Rm)>;
3884-
def : ARMPat<(ARMsubs GPR:$Rn, so_reg_imm:$shift),
3885-
(SUBSrsi $Rn, so_reg_imm:$shift)>;
3886-
def : ARMPat<(ARMsubs GPR:$Rn, so_reg_reg:$shift),
3887-
(SUBSrsr $Rn, so_reg_reg:$shift)>;
3888-
3889-
38903881
let isAdd = 1 in
38913882
defm ADC : AI1_adde_sube_irs<0b0101, "adc", ARMadde, 1>;
38923883
defm SBC : AI1_adde_sube_irs<0b0110, "sbc", ARMsube>;

llvm/lib/Target/ARM/ARMInstrThumb.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,12 +1400,6 @@ let hasPostISelHook = 1, Defs = [CPSR] in {
14001400
Sched<[WriteALU]>;
14011401
}
14021402

1403-
1404-
def : T1Pat<(ARMsubs tGPR:$Rn, tGPR:$Rm), (tSUBSrr $Rn, $Rm)>;
1405-
def : T1Pat<(ARMsubs tGPR:$Rn, imm0_7:$imm3), (tSUBSi3 $Rn, imm0_7:$imm3)>;
1406-
def : T1Pat<(ARMsubs tGPR:$Rn, imm0_255:$imm8), (tSUBSi8 $Rn, imm0_255:$imm8)>;
1407-
1408-
14091403
// Sign-extend byte
14101404
def tSXTB : // A8.6.222
14111405
T1pIMiscEncode<{0,0,1,0,0,1,?}, (outs tGPR:$Rd), (ins tGPR:$Rm),

llvm/lib/Target/ARM/ARMInstrThumb2.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,12 +2438,6 @@ defm t2SUB : T2I_bin_ii12rs<0b101, "sub", sub>;
24382438
defm t2ADDS : T2I_bin_s_irs <IIC_iALUi, IIC_iALUr, IIC_iALUsi, ARMaddc, 1>;
24392439
defm t2SUBS : T2I_bin_s_irs <IIC_iALUi, IIC_iALUr, IIC_iALUsi, ARMsubc>;
24402440

2441-
def : T2Pat<(ARMsubs GPRnopc:$Rn, t2_so_imm:$imm),
2442-
(t2SUBSri $Rn, t2_so_imm:$imm)>;
2443-
def : T2Pat<(ARMsubs GPRnopc:$Rn, rGPR:$Rm), (t2SUBSrr $Rn, $Rm)>;
2444-
def : T2Pat<(ARMsubs GPRnopc:$Rn, t2_so_reg:$ShiftedRm),
2445-
(t2SUBSrs $Rn, t2_so_reg:$ShiftedRm)>;
2446-
24472441
defm t2ADC : T2I_adde_sube_irs<0b1010, "adc", ARMadde, 1, 1>;
24482442
defm t2SBC : T2I_adde_sube_irs<0b1011, "sbc", ARMsube, 0, 1>;
24492443

0 commit comments

Comments
 (0)