Skip to content

Commit 438c985

Browse files
committed
[ARM] Use 0, not ZR during ISel for CSINC/INV/NEG
Instead of converting the 0 into a ZR reg during lowering, do that with tablegen by matching the zero immediate. This when combined with other optimizations is more likely to use ZR and helps keep the DAG more easily optimizable. It should not otherwise effect code generation.
1 parent 52bbbf4 commit 438c985

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5226,8 +5226,6 @@ SDValue ARMTargetLowering::LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const {
52265226
std::swap(TVal, FVal);
52275227
CC = ISD::getSetCCInverse(CC, LHS.getValueType());
52285228
}
5229-
if (TVal == 0)
5230-
TrueVal = DAG.getRegister(ARM::ZR, MVT::i32);
52315229

52325230
// Drops F's value because we can get it by inverting/negating TVal.
52335231
FalseVal = TrueVal;

llvm/lib/Target/ARM/ARMInstrThumb2.td

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5518,13 +5518,22 @@ def t2CSINC : CS<"csinc", 0b1001>;
55185518
def t2CSINV : CS<"csinv", 0b1010>;
55195519
def t2CSNEG : CS<"csneg", 0b1011>;
55205520

5521+
55215522
let Predicates = [HasV8_1MMainline] in {
5522-
def : T2Pat<(ARMcsinc GPRwithZR:$tval, GPRwithZR:$fval, imm0_31:$imm),
5523-
(t2CSINC GPRwithZR:$tval, GPRwithZR:$fval, imm0_31:$imm)>;
5524-
def : T2Pat<(ARMcsinv GPRwithZR:$tval, GPRwithZR:$fval, imm0_31:$imm),
5525-
(t2CSINV GPRwithZR:$tval, GPRwithZR:$fval, imm0_31:$imm)>;
5526-
def : T2Pat<(ARMcsneg GPRwithZR:$tval, GPRwithZR:$fval, imm0_31:$imm),
5527-
(t2CSNEG GPRwithZR:$tval, GPRwithZR:$fval, imm0_31:$imm)>;
5523+
multiclass CSPats<SDNode Node, Instruction Insn> {
5524+
def : T2Pat<(Node GPRwithZR:$tval, GPRwithZR:$fval, imm0_31:$imm),
5525+
(Insn GPRwithZR:$tval, GPRwithZR:$fval, imm0_31:$imm)>;
5526+
def : T2Pat<(Node (i32 0), GPRwithZR:$fval, imm0_31:$imm),
5527+
(Insn ZR, GPRwithZR:$fval, imm0_31:$imm)>;
5528+
def : T2Pat<(Node GPRwithZR:$tval, (i32 0), imm0_31:$imm),
5529+
(Insn GPRwithZR:$tval, ZR, imm0_31:$imm)>;
5530+
def : T2Pat<(Node (i32 0), (i32 0), imm0_31:$imm),
5531+
(Insn ZR, ZR, imm0_31:$imm)>;
5532+
}
5533+
5534+
defm : CSPats<ARMcsinc, t2CSINC>;
5535+
defm : CSPats<ARMcsinv, t2CSINV>;
5536+
defm : CSPats<ARMcsneg, t2CSNEG>;
55285537

55295538
multiclass ModifiedV8_1CSEL<Instruction Insn, dag modvalue> {
55305539
def : T2Pat<(ARMcmov modvalue, GPRwithZR:$tval, cmovpred:$imm),

0 commit comments

Comments
 (0)