Skip to content

[NFC][SystemZ] Use SExt for signed constants #118803

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

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

redstar
Copy link
Member

@redstar redstar commented Dec 5, 2024

Use SExt instead of ZExt in XForms which produce a signed value. This is only to make it clear that the XForm handles a signed value.

@redstar redstar requested a review from uweigand December 5, 2024 13:42
@redstar redstar self-assigned this Dec 5, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 5, 2024

@llvm/pr-subscribers-backend-systemz

Author: Kai Nacke (redstar)

Changes

Use SExt instead of ZExt in XForms which produce a signed value. This is only to make it clear that the XForm handles a signed value.


Full diff: https://github.com/llvm/llvm-project/pull/118803.diff

1 Files Affected:

  • (modified) llvm/lib/Target/SystemZ/SystemZOperands.td (+6-6)
diff --git a/llvm/lib/Target/SystemZ/SystemZOperands.td b/llvm/lib/Target/SystemZ/SystemZOperands.td
index 5349e0d9a8512c..5cff74389bf1af 100644
--- a/llvm/lib/Target/SystemZ/SystemZOperands.td
+++ b/llvm/lib/Target/SystemZ/SystemZOperands.td
@@ -214,13 +214,13 @@ def NEGLH16 : SDNodeXForm<imm, [{
 }]>;
 
 def NEGLF32 : SDNodeXForm<imm, [{
-  uint64_t Value = -N->getZExtValue() & 0x00000000FFFFFFFFULL;
+  uint64_t Value = -N->getSExtValue() & 0x00000000FFFFFFFFULL;
   return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64);
 }]>;
 
 // Truncate an immediate to a 8-bit signed quantity.
 def SIMM8 : SDNodeXForm<imm, [{
-  return CurDAG->getSignedTargetConstant(int8_t(N->getZExtValue()), SDLoc(N),
+  return CurDAG->getSignedTargetConstant(int8_t(N->getSExtValue()), SDLoc(N),
                                          MVT::i64);
 }]>;
 
@@ -244,13 +244,13 @@ def UIMM12 : SDNodeXForm<imm, [{
 
 // Truncate an immediate to a 16-bit signed quantity.
 def SIMM16 : SDNodeXForm<imm, [{
-  return CurDAG->getSignedTargetConstant(int16_t(N->getZExtValue()), SDLoc(N),
+  return CurDAG->getSignedTargetConstant(int16_t(N->getSExtValue()), SDLoc(N),
                                          MVT::i64);
 }]>;
 
 // Negate and then truncate an immediate to a 16-bit signed quantity.
 def NEGSIMM16 : SDNodeXForm<imm, [{
-  return CurDAG->getSignedTargetConstant(int16_t(-N->getZExtValue()), SDLoc(N),
+  return CurDAG->getSignedTargetConstant(int16_t(-N->getSExtValue()), SDLoc(N),
                                          MVT::i64);
 }]>;
 
@@ -262,13 +262,13 @@ def UIMM16 : SDNodeXForm<imm, [{
 
 // Truncate an immediate to a 32-bit signed quantity.
 def SIMM32 : SDNodeXForm<imm, [{
-  return CurDAG->getSignedTargetConstant(int32_t(N->getZExtValue()), SDLoc(N),
+  return CurDAG->getSignedTargetConstant(int32_t(N->getSExtValue()), SDLoc(N),
                                          MVT::i64);
 }]>;
 
 // Negate and then truncate an immediate to a 32-bit unsigned quantity.
 def NEGSIMM32 : SDNodeXForm<imm, [{
-  return CurDAG->getSignedTargetConstant(int32_t(-N->getZExtValue()), SDLoc(N),
+  return CurDAG->getSignedTargetConstant(int32_t(-N->getSExtValue()), SDLoc(N),
                                          MVT::i64);
 }]>;
 

@redstar redstar requested review from JonPsson1 and nikic December 5, 2024 13:42
Copy link
Member

@uweigand uweigand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@redstar redstar force-pushed the knacke/usesextforsigned branch from f56672c to e3a4769 Compare December 5, 2024 14:48
Use SExt instead of ZExt in XForms which produce a signed value. This is only to make it clear that the XForm handles a signed value.
@redstar redstar force-pushed the knacke/usesextforsigned branch from e3a4769 to f0cb15b Compare December 5, 2024 14:49
@redstar redstar merged commit 3bd3fa6 into llvm:main Dec 5, 2024
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants