Skip to content

Commit 169626f

Browse files
authored
[RISCV] Rename RISCVISD::ABSW->NEGW_MAX. NFC (#164909)
This matches what it expands to. The P extension adds a proper ABSW instruction so being precise is important to avoid confusion.
1 parent cea8ffa commit 169626f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14797,7 +14797,7 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode *N,
1479714797
// to NEGW+MAX here requires a Freeze which breaks ComputeNumSignBits.
1479814798
SDValue Src = DAG.getNode(ISD::SIGN_EXTEND, DL, MVT::i64,
1479914799
N->getOperand(0));
14800-
SDValue Abs = DAG.getNode(RISCVISD::ABSW, DL, MVT::i64, Src);
14800+
SDValue Abs = DAG.getNode(RISCVISD::NEGW_MAX, DL, MVT::i64, Src);
1480114801
Results.push_back(DAG.getNode(ISD::TRUNCATE, DL, MVT::i32, Abs));
1480214802
return;
1480314803
}
@@ -21813,7 +21813,7 @@ unsigned RISCVTargetLowering::ComputeNumSignBitsForTargetNode(
2181321813
// Output is either all zero or operand 0. We can propagate sign bit count
2181421814
// from operand 0.
2181521815
return DAG.ComputeNumSignBits(Op.getOperand(0), DemandedElts, Depth + 1);
21816-
case RISCVISD::ABSW: {
21816+
case RISCVISD::NEGW_MAX: {
2181721817
// We expand this at isel to negw+max. The result will have 33 sign bits
2181821818
// if the input has at least 33 sign bits.
2181921819
unsigned Tmp =

llvm/lib/Target/RISCV/RISCVInstrInfoZb.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def riscv_zip : RVSDNode<"ZIP", SDTIntUnaryOp>;
5151
def riscv_unzip : RVSDNode<"UNZIP", SDTIntUnaryOp>;
5252

5353
// RV64IZbb absolute value for i32. Expanded to (max (negw X), X) during isel.
54-
def riscv_absw : RVSDNode<"ABSW", SDTIntUnaryOp>;
54+
def riscv_negw_max : RVSDNode<"NEGW_MAX", SDTIntUnaryOp>;
5555

5656
// Scalar cryptography
5757
def riscv_clmul : RVSDNode<"CLMUL", SDTIntBinOp>;
@@ -610,7 +610,7 @@ def : PatGpr<riscv_clzw, CLZW>;
610610
def : PatGpr<riscv_ctzw, CTZW>;
611611
def : Pat<(i64 (ctpop (i64 (zexti32 (i64 GPR:$rs1))))), (CPOPW GPR:$rs1)>;
612612

613-
def : Pat<(i64 (riscv_absw GPR:$rs1)),
613+
def : Pat<(i64 (riscv_negw_max GPR:$rs1)),
614614
(MAX GPR:$rs1, (XLenVT (SUBW (XLenVT X0), GPR:$rs1)))>;
615615
} // Predicates = [HasStdExtZbb, IsRV64]
616616

0 commit comments

Comments
 (0)