-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Mips] Use getSignedConstant() for signed values #116405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This also adds a getSignedTargetConstant() helper, as these seem to be fairly common in general.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@llvm/pr-subscribers-llvm-selectiondag Author: Nikita Popov (nikic) ChangesThis also adds a getSignedTargetConstant() helper, as these seem to be fairly common in general. Full diff: https://github.com/llvm/llvm-project/pull/116405.diff 4 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h
index 9035aa3ea31278..2e3507386df309 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -700,6 +700,10 @@ class SelectionDAG {
bool isOpaque = false) {
return getConstant(Val, DL, VT, true, isOpaque);
}
+ SDValue getSignedTargetConstant(int64_t Val, const SDLoc &DL, EVT VT,
+ bool isOpaque = false) {
+ return getSignedConstant(Val, DL, VT, true, isOpaque);
+ }
/// Create a true or false constant of type \p VT using the target's
/// BooleanContent for type \p OpVT.
diff --git a/llvm/lib/Target/Mips/MipsISelDAGToDAG.h b/llvm/lib/Target/Mips/MipsISelDAGToDAG.h
index 6135f968078542..0411a17b4f0669 100644
--- a/llvm/lib/Target/Mips/MipsISelDAGToDAG.h
+++ b/llvm/lib/Target/Mips/MipsISelDAGToDAG.h
@@ -134,6 +134,11 @@ class MipsDAGToDAGISel : public SelectionDAGISel {
return CurDAG->getTargetConstant(Imm, SDLoc(Node), Node->getValueType(0));
}
+ inline SDValue getSignedImm(const SDNode *Node, int64_t Imm) {
+ return CurDAG->getSignedTargetConstant(Imm, SDLoc(Node),
+ Node->getValueType(0));
+ }
+
virtual void processFunctionAfterISel(MachineFunction &MF) = 0;
bool SelectInlineAsmMemoryOperand(const SDValue &Op,
diff --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp b/llvm/lib/Target/Mips/MipsISelLowering.cpp
index f1cc9fd958447a..ef2c89f49e875a 100644
--- a/llvm/lib/Target/Mips/MipsISelLowering.cpp
+++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp
@@ -2362,9 +2362,9 @@ SDValue MipsTargetLowering::lowerVAARG(SDValue Op, SelectionDAG &DAG) const {
ISD::ADD, DL, VAList.getValueType(), VAList,
DAG.getConstant(Align.value() - 1, DL, VAList.getValueType()));
- VAList = DAG.getNode(
- ISD::AND, DL, VAList.getValueType(), VAList,
- DAG.getConstant(-(int64_t)Align.value(), DL, VAList.getValueType()));
+ VAList = DAG.getNode(ISD::AND, DL, VAList.getValueType(), VAList,
+ DAG.getSignedConstant(-(int64_t)Align.value(), DL,
+ VAList.getValueType()));
}
// Increment the pointer, VAList, to the next vaarg.
@@ -4291,7 +4291,7 @@ void MipsTargetLowering::LowerAsmOperandForConstraint(SDValue Op,
EVT Type = Op.getValueType();
int64_t Val = C->getSExtValue();
if (isInt<16>(Val)) {
- Result = DAG.getTargetConstant(Val, DL, Type);
+ Result = DAG.getSignedTargetConstant(Val, DL, Type);
break;
}
}
@@ -4321,7 +4321,7 @@ void MipsTargetLowering::LowerAsmOperandForConstraint(SDValue Op,
EVT Type = Op.getValueType();
int64_t Val = C->getSExtValue();
if ((isInt<32>(Val)) && ((Val & 0xffff) == 0)){
- Result = DAG.getTargetConstant(Val, DL, Type);
+ Result = DAG.getSignedTargetConstant(Val, DL, Type);
break;
}
}
@@ -4331,7 +4331,7 @@ void MipsTargetLowering::LowerAsmOperandForConstraint(SDValue Op,
EVT Type = Op.getValueType();
int64_t Val = C->getSExtValue();
if ((Val >= -65535) && (Val <= -1)) {
- Result = DAG.getTargetConstant(Val, DL, Type);
+ Result = DAG.getSignedTargetConstant(Val, DL, Type);
break;
}
}
@@ -4341,7 +4341,7 @@ void MipsTargetLowering::LowerAsmOperandForConstraint(SDValue Op,
EVT Type = Op.getValueType();
int64_t Val = C->getSExtValue();
if ((isInt<15>(Val))) {
- Result = DAG.getTargetConstant(Val, DL, Type);
+ Result = DAG.getSignedTargetConstant(Val, DL, Type);
break;
}
}
diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.td b/llvm/lib/Target/Mips/MipsInstrInfo.td
index 85e3e78d2a4d8f..557e6a2c72e273 100644
--- a/llvm/lib/Target/Mips/MipsInstrInfo.td
+++ b/llvm/lib/Target/Mips/MipsInstrInfo.td
@@ -1199,7 +1199,9 @@ def HI16 : SDNodeXForm<imm, [{
}]>;
// Plus 1.
-def Plus1 : SDNodeXForm<imm, [{ return getImm(N, N->getSExtValue() + 1); }]>;
+def Plus1 : SDNodeXForm<imm, [{
+ return getSignedImm(N, N->getSExtValue() + 1);
+}]>;
// Node immediate is zero (e.g. insve.d)
def immz : PatLeaf<(imm), [{ return N->getSExtValue() == 0; }]>;
|
cc @yingopq |
LGTM |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/8735 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/51/builds/6503 Here is the relevant piece of the build log for the reference
|
This also adds a getSignedTargetConstant() helper, as these seem to be fairly common in general.