-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[CodeGen] Parse nusw flag #138856
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
[CodeGen] Parse nusw flag #138856
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-backend-amdgpu @llvm/pr-subscribers-llvm-globalisel Author: Pierre van Houtryve (Pierre-vh) ChangesFixes #127781 Full diff: https://github.com/llvm/llvm-project/pull/138856.diff 2 Files Affected:
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index 5c8e32d11cfb0..858cdb6599c62 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -1476,6 +1476,7 @@ bool MIParser::parseInstruction(unsigned &OpCode, unsigned &Flags) {
Token.is(MIToken::kw_unpredictable) ||
Token.is(MIToken::kw_nneg) ||
Token.is(MIToken::kw_disjoint) ||
+ Token.is(MIToken::kw_nusw) ||
Token.is(MIToken::kw_samesign)) {
// clang-format on
// Mine frame and fast math flags
@@ -1513,6 +1514,8 @@ bool MIParser::parseInstruction(unsigned &OpCode, unsigned &Flags) {
Flags |= MachineInstr::NonNeg;
if (Token.is(MIToken::kw_disjoint))
Flags |= MachineInstr::Disjoint;
+ if (Token.is(MIToken::kw_nusw))
+ Flags |= MachineInstr::NoUSWrap;
if (Token.is(MIToken::kw_samesign))
Flags |= MachineInstr::SameSign;
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/ptradd-flags.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/ptradd-flags.mir
new file mode 100644
index 0000000000000..2da0eb7be0677
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/ptradd-flags.mir
@@ -0,0 +1,23 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
+# RUN: llc -mtriple=amdgcn -mcpu=gfx900 -run-pass=none -verify-machineinstrs %s -o - | FileCheck %s
+
+---
+name: nusw_ptr_add
+legalized: true
+tracksRegLiveness: true
+body: |
+ bb.0:
+ liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
+
+ ; CHECK-LABEL: name: nusw_ptr_add
+ ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: %ptr:_(p0) = COPY $vgpr0_vgpr1
+ ; CHECK-NEXT: %off:_(s64) = COPY $vgpr2_vgpr3
+ ; CHECK-NEXT: %ret:_(p0) = nuw nusw G_PTR_ADD %ptr, %off(s64)
+ ; CHECK-NEXT: $vgpr0_vgpr1 = COPY %ret(p0)
+ %ptr:_(p0) = COPY $vgpr0_vgpr1
+ %off:_(s64) = COPY $vgpr2_vgpr3
+ %ret:_(p0) = nuw nusw G_PTR_ADD %ptr, %off
+ $vgpr0_vgpr1 = COPY %ret
+...
|
arsenm
reviewed
May 7, 2025
arsenm
approved these changes
May 7, 2025
Merge activity
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #127781