-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RISCV] Return false for Zalasr load/store in isWorthFoldingAdd. #136799
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
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
The Zalasr load/store don't support reg-imm addressing modes so they can't fold an ADDI.
@llvm/pr-subscribers-backend-risc-v Author: Craig Topper (topperc) ChangesThe Zalasr load/store don't support reg-imm addressing modes so they Full diff: https://github.com/llvm/llvm-project/pull/136799.diff 2 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
index 4de93d5d5abde..ad77106d386c9 100644
--- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -2599,6 +2599,8 @@ static bool isWorthFoldingAdd(SDValue Add) {
if (User->getOpcode() == ISD::ATOMIC_STORE &&
cast<AtomicSDNode>(User)->getVal() == Add)
return false;
+ if (isStrongerThanMonotonic(cast<MemSDNode>(User)->getSuccessOrdering()))
+ return false;
}
return true;
diff --git a/llvm/test/CodeGen/RISCV/zalasr-offset-folding.ll b/llvm/test/CodeGen/RISCV/zalasr-offset-folding.ll
new file mode 100644
index 0000000000000..78653ba3b78ef
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/zalasr-offset-folding.ll
@@ -0,0 +1,22 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc < %s -mtriple=riscv32 -mattr=+a,+experimental-zalasr | FileCheck %s
+
+; Make sure we don't fold -1920 into the lw instruction because we still
+; need it for the sw.rl.
+
+define i32 @test(ptr %p) {
+; CHECK-LABEL: test:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: lui a1, 20
+; CHECK-NEXT: addi a1, a1, -1920
+; CHECK-NEXT: add a0, a0, a1
+; CHECK-NEXT: li a1, 2
+; CHECK-NEXT: sw.rl a1, (a0)
+; CHECK-NEXT: lw a0, 0(a0)
+; CHECK-NEXT: ret
+entry:
+ %gep0 = getelementptr [65536 x i32], ptr %p, i64 0, i32 20000
+ store atomic i32 2, ptr %gep0 seq_cst, align 4
+ %a = load i32, ptr %gep0
+ ret i32 %a
+}
|
preames
approved these changes
Apr 23, 2025
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
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
…m#136799) The Zalasr load/store don't support reg-imm addressing modes so they can't fold an ADDI.
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
…m#136799) The Zalasr load/store don't support reg-imm addressing modes so they can't fold an ADDI.
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
…m#136799) The Zalasr load/store don't support reg-imm addressing modes so they can't fold an ADDI.
Ankur-0429
pushed a commit
to Ankur-0429/llvm-project
that referenced
this pull request
May 9, 2025
…m#136799) The Zalasr load/store don't support reg-imm addressing modes so they can't fold an ADDI.
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.
The Zalasr load/store don't support reg-imm addressing modes so they
can't fold an ADDI.