-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[SystemZ] SIMM32 is a signed constant #118634
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
@llvm/pr-subscribers-backend-systemz Author: Kai Nacke (redstar) ChangesA follow-up to PR #117181: SIMM32 must use getSignedTargetConstant(), too. Full diff: https://github.com/llvm/llvm-project/pull/118634.diff 1 Files Affected:
diff --git a/llvm/lib/Target/SystemZ/SystemZOperands.td b/llvm/lib/Target/SystemZ/SystemZOperands.td
index 64345ca3a1394e..5349e0d9a8512c 100644
--- a/llvm/lib/Target/SystemZ/SystemZOperands.td
+++ b/llvm/lib/Target/SystemZ/SystemZOperands.td
@@ -262,8 +262,8 @@ def UIMM16 : SDNodeXForm<imm, [{
// Truncate an immediate to a 32-bit signed quantity.
def SIMM32 : SDNodeXForm<imm, [{
- return CurDAG->getTargetConstant(int32_t(N->getZExtValue()), SDLoc(N),
- MVT::i64);
+ return CurDAG->getSignedTargetConstant(int32_t(N->getZExtValue()), SDLoc(N),
+ MVT::i64);
}]>;
// Negate and then truncate an immediate to a 32-bit unsigned quantity.
|
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.
This looks good to me, but it would be nice to add a test case.
@@ -262,8 +262,8 @@ def UIMM16 : SDNodeXForm<imm, [{ | |||
|
|||
// Truncate an immediate to a 32-bit signed quantity. | |||
def SIMM32 : SDNodeXForm<imm, [{ | |||
return CurDAG->getTargetConstant(int32_t(N->getZExtValue()), SDLoc(N), | |||
MVT::i64); | |||
return CurDAG->getSignedTargetConstant(int32_t(N->getZExtValue()), SDLoc(N), |
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.
return CurDAG->getSignedTargetConstant(int32_t(N->getZExtValue()), SDLoc(N), | |
return CurDAG->getSignedTargetConstant(int32_t(N->getSExtValue()), SDLoc(N), |
Shouldn't make a difference here, but I think this would be more obvious...
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.
Good point. This should be done for all the SIMM variants then, I think. @redstar would you mind doing this in a follow-on PR?
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.
Sure, I'll do that.
Turns out to be more difficult than expected. The reason seems to be that the target type is
crashes when targeting 32 bit mode, and compiles fine for 64 bit mode. The generated instruction is the same ( |
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. I think this should go in even if we don't have any simple test cases on upstream.
@@ -262,8 +262,8 @@ def UIMM16 : SDNodeXForm<imm, [{ | |||
|
|||
// Truncate an immediate to a 32-bit signed quantity. | |||
def SIMM32 : SDNodeXForm<imm, [{ | |||
return CurDAG->getTargetConstant(int32_t(N->getZExtValue()), SDLoc(N), | |||
MVT::i64); | |||
return CurDAG->getSignedTargetConstant(int32_t(N->getZExtValue()), SDLoc(N), |
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.
Good point. This should be done for all the SIMM variants then, I think. @redstar would you mind doing this in a follow-on PR?
A follow-up to PR llvm#117181: SIMM32 must use getSignedTargetConstant(), too.
5b9884d
to
02b5c38
Compare
A follow-up to PR #117181: SIMM32 must use getSignedTargetConstant(), too.