Skip to content

[AArch64] Drop flags from BSP pseudos #151856

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1242,8 +1242,10 @@ bool AArch64ExpandPseudo::expandMI(MachineBasicBlock &MBB,
.addReg(DstReg,
RegState::Define |
getRenamableRegState(MI.getOperand(0).isRenamable()))
.add(MI.getOperand(1))
.add(MI.getOperand(1));
.addReg(MI.getOperand(1).getReg(),
getRenamableRegState(MI.getOperand(1).isRenamable()))
.addReg(MI.getOperand(1).getReg(),
getRenamableRegState(MI.getOperand(1).isRenamable()));
auto I2 =
BuildMI(MBB, MBBI, MI.getDebugLoc(),
TII->get(Opcode == AArch64::BSPv8i8 ? AArch64::BSLv8i8
Expand Down
22 changes: 21 additions & 1 deletion llvm/test/CodeGen/AArch64/bsp_implicit_ops.mir
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ body: |
; CHECK-LABEL: name: BSL_COPY
; CHECK: liveins: $q20, $q21, $q22, $q23, $q6, $q1, $q7
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: renamable $q2 = ORRv16i8 killed renamable $q20, killed renamable $q20
; CHECK-NEXT: renamable $q2 = ORRv16i8 renamable $q20, renamable $q20
; CHECK-NEXT: renamable $q2 = BSLv16i8 killed renamable $q2, renamable $q21, renamable $q6, implicit killed $q21_q22_q23, implicit killed $q0_q1_q2_q3, implicit-def $q0_q1_q2_q3
; CHECK-NEXT: $q22 = ORRv16i8 $q0, killed $q0
; CHECK-NEXT: $q23 = ORRv16i8 $q1, killed $q1
Expand Down Expand Up @@ -96,3 +96,23 @@ body: |
$q25 = ORRv16i8 $q3, killed $q3
RET_ReallyLR implicit $q22
...
---
name: DoubleOp
tracksRegLiveness: true
body: |
bb.0.entry:
liveins: $q2

; CHECK-LABEL: name: DoubleOp
; CHECK: liveins: $q2
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: renamable $q0 = MOVIv8i16 1, 0
; CHECK-NEXT: renamable $q1 = ORRv16i8 renamable $q2, renamable $q2
; CHECK-NEXT: renamable $q1 = BSLv16i8 killed renamable $q1, renamable $q2, renamable $q0
Copy link
Contributor

@rj-jesus rj-jesus Aug 5, 2025

Choose a reason for hiding this comment

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

Would it be worth preserving the kill flag when the MOV's operand isn't needed elsewhere, like in BSL_COPY above, and propagating it down to the BSL in other cases (for example, killing q2 here)?

; CHECK-NEXT: renamable $q0 = SQADDv8i16 killed renamable $q1, killed renamable $q0
; CHECK-NEXT: RET undef $lr, implicit $q0
renamable $q0 = MOVIv8i16 1, 0
renamable $q1 = BSPv16i8 killed renamable $q2, renamable $q2, renamable $q0
renamable $q0 = SQADDv8i16 killed renamable $q1, killed renamable $q0
RET_ReallyLR implicit $q0
...