[llvm] 58c5b4c - [RISCV] Use TargetConstant for condition code of RISCVISD::SELECT_CC.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 21 23:11:15 PDT 2021
Author: Craig Topper
Date: 2021-04-21T23:08:52-07:00
New Revision: 58c5b4c2c356a377581440110f1e634fbb49cef6
URL: https://github.com/llvm/llvm-project/commit/58c5b4c2c356a377581440110f1e634fbb49cef6
DIFF: https://github.com/llvm/llvm-project/commit/58c5b4c2c356a377581440110f1e634fbb49cef6.diff
LOG: [RISCV] Use TargetConstant for condition code of RISCVISD::SELECT_CC.
The value is always an immediate and can never be in a register.
This the kind of thing TargetConstant is for.
Saves a step GenDAGISel to convert a Constant to a TargetConstant.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfo.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 231d898af6e7..0e060ce6d73b 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -2426,7 +2426,7 @@ SDValue RISCVTargetLowering::lowerSELECT(SDValue Op, SelectionDAG &DAG) const {
translateSetCCForBranch(DL, LHS, RHS, CCVal, DAG);
- SDValue TargetCC = DAG.getConstant(CCVal, DL, XLenVT);
+ SDValue TargetCC = DAG.getTargetConstant(CCVal, DL, XLenVT);
SDValue Ops[] = {LHS, RHS, TargetCC, TrueV, FalseV};
return DAG.getNode(RISCVISD::SELECT_CC, DL, Op.getValueType(), Ops);
}
@@ -2435,7 +2435,7 @@ SDValue RISCVTargetLowering::lowerSELECT(SDValue Op, SelectionDAG &DAG) const {
// (select condv, truev, falsev)
// -> (riscvisd::select_cc condv, zero, setne, truev, falsev)
SDValue Zero = DAG.getConstant(0, DL, XLenVT);
- SDValue SetNE = DAG.getConstant(ISD::SETNE, DL, XLenVT);
+ SDValue SetNE = DAG.getTargetConstant(ISD::SETNE, DL, XLenVT);
SDValue Ops[] = {CondV, Zero, SetNE, TrueV, FalseV};
@@ -5146,7 +5146,8 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
LHS = LHS.getOperand(0);
translateSetCCForBranch(DL, LHS, RHS, CCVal, DAG);
- SDValue TargetCC = DAG.getConstant(CCVal, DL, Subtarget.getXLenVT());
+ SDValue TargetCC =
+ DAG.getTargetConstant(CCVal, DL, Subtarget.getXLenVT());
return DAG.getNode(
RISCVISD::SELECT_CC, DL, N->getValueType(0),
{LHS, RHS, TargetCC, N->getOperand(3), N->getOperand(4)});
@@ -5166,7 +5167,8 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
if (isOneConstant(RHS) && DAG.MaskedValueIsZero(LHS, Mask)) {
SDLoc DL(N);
CCVal = ISD::getSetCCInverse(CCVal, LHS.getValueType());
- SDValue TargetCC = DAG.getConstant(CCVal, DL, Subtarget.getXLenVT());
+ SDValue TargetCC =
+ DAG.getTargetConstant(CCVal, DL, Subtarget.getXLenVT());
RHS = DAG.getConstant(0, DL, LHS.getValueType());
return DAG.getNode(
RISCVISD::SELECT_CC, DL, N->getValueType(0),
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
index eb49b75735f6..ed31e1dee0d3 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -964,7 +964,7 @@ class SelectCC_rrirr<RegisterClass valty, RegisterClass cmpty>
(ins cmpty:$lhs, cmpty:$rhs, ixlenimm:$imm,
valty:$truev, valty:$falsev),
[(set valty:$dst, (riscv_selectcc cmpty:$lhs, cmpty:$rhs,
- (XLenVT imm:$imm), valty:$truev, valty:$falsev))]>;
+ (XLenVT timm:$imm), valty:$truev, valty:$falsev))]>;
def Select_GPR_Using_CC_GPR : SelectCC_rrirr<GPR, GPR>;
More information about the llvm-commits
mailing list