-
Notifications
You must be signed in to change notification settings - Fork 14.3k
PeepholeOpt: Remove subreg def check for bitcast #130086
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
arsenm
merged 1 commit into
main
from
users/arsenm/peephole-opt/remove-dead-subreg-def-check-for-bitcast
Mar 7, 2025
Merged
PeepholeOpt: Remove subreg def check for bitcast #130086
arsenm
merged 1 commit into
main
from
users/arsenm/peephole-opt/remove-dead-subreg-def-check-for-bitcast
Mar 7, 2025
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
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-backend-x86 Author: Matt Arsenault (arsenm) ChangesSubregister defs are illegal in SSA. Surprisingly this enables folding Full diff: https://github.com/llvm/llvm-project/pull/130086.diff 2 Files Affected:
diff --git a/llvm/lib/CodeGen/PeepholeOptimizer.cpp b/llvm/lib/CodeGen/PeepholeOptimizer.cpp
index 4d0fd86eb216f..ec8e97f73546a 100644
--- a/llvm/lib/CodeGen/PeepholeOptimizer.cpp
+++ b/llvm/lib/CodeGen/PeepholeOptimizer.cpp
@@ -1923,11 +1923,8 @@ ValueTrackerResult ValueTracker::getNextSourceFromBitcast() {
// Bitcasts with more than one def are not supported.
if (Def->getDesc().getNumDefs() != 1)
return ValueTrackerResult();
- const MachineOperand DefOp = Def->getOperand(DefIdx);
- if (DefOp.getSubReg() != DefSubReg)
- // If we look for a different subreg, it means we want a subreg of the src.
- // Bails as we do not support composing subregs yet.
- return ValueTrackerResult();
+
+ assert(!Def->getOperand(DefIdx).getSubReg() && "no subregister defs in SSA");
unsigned SrcIdx = Def->getNumOperands();
for (unsigned OpIdx = DefIdx + 1, EndOpIdx = SrcIdx; OpIdx != EndOpIdx;
@@ -1950,6 +1947,8 @@ ValueTrackerResult ValueTracker::getNextSourceFromBitcast() {
if (SrcIdx >= Def->getNumOperands())
return ValueTrackerResult();
+ const MachineOperand &DefOp = Def->getOperand(DefIdx);
+
// Stop when any user of the bitcast is a SUBREG_TO_REG, replacing with a COPY
// will break the assumed guarantees for the upper bits.
for (const MachineInstr &UseMI : MRI.use_nodbg_instructions(DefOp.getReg())) {
diff --git a/llvm/test/CodeGen/X86/pr41619.ll b/llvm/test/CodeGen/X86/pr41619.ll
index 88dcd7798f0c3..6bca77d05e9a9 100644
--- a/llvm/test/CodeGen/X86/pr41619.ll
+++ b/llvm/test/CodeGen/X86/pr41619.ll
@@ -6,8 +6,6 @@ define void @foo(double %arg) {
; CHECK-LABEL: foo:
; CHECK: ## %bb.0: ## %bb
; CHECK-NEXT: vmovq %xmm0, %rax
-; CHECK-NEXT: vmovd %eax, %xmm0
-; CHECK-NEXT: vmovq %xmm0, %rax
; CHECK-NEXT: movl %eax, (%rax)
; CHECK-NEXT: movq $0, (%rax)
; CHECK-NEXT: retq
|
qcolombet
approved these changes
Mar 6, 2025
590e663
to
afdb224
Compare
Base automatically changed from
users/arsenm/peephole-opt/remove-subreg-def-check-for-insert-subreg
to
main
March 7, 2025 00:40
Subregister defs are illegal in SSA. Surprisingly this enables folding into subregister insert patterns in one test.
c7d0811
to
a3c43f8
Compare
jph-13
pushed a commit
to jph-13/llvm-project
that referenced
this pull request
Mar 21, 2025
Subregister defs are illegal in SSA. Surprisingly this enables folding into subregister insert patterns in one test.
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.
Subregister defs are illegal in SSA. Surprisingly this enables folding
into subregister insert patterns in one test.