Skip to content
Merged
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
19 changes: 19 additions & 0 deletions llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,25 @@ AArch64LoadStoreOpt::mergePairedInsns(MachineBasicBlock::iterator I,
if (MOP.isReg() && MOP.isKill())
DefinedInBB.addReg(MOP.getReg());

// Copy over any implicit-def operands. This is like MI.copyImplicitOps, but
// only copies implicit defs and makes sure that each operand is only added
// once in case of duplicates.
auto CopyImplicitOps = [&](MachineBasicBlock::iterator MI1,
MachineBasicBlock::iterator MI2) {
SmallSetVector<Register, 4> Ops;
for (const MachineOperand &MO :
llvm::drop_begin(MI1->operands(), MI1->getDesc().getNumOperands()))
if (MO.isReg() && MO.isImplicit() && MO.isDef())
Ops.insert(MO.getReg());
for (const MachineOperand &MO :
llvm::drop_begin(MI2->operands(), MI2->getDesc().getNumOperands()))
if (MO.isReg() && MO.isImplicit() && MO.isDef())
Ops.insert(MO.getReg());
for (auto Op : Ops)
MIB.addDef(Op, RegState::Implicit);
};
CopyImplicitOps(I, Paired);

// Erase the old instructions.
I->eraseFromParent();
Paired->eraseFromParent();
Expand Down
80 changes: 80 additions & 0 deletions llvm/test/CodeGen/AArch64/ldst-implicitop.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 6
# RUN: llc -mtriple=aarch64-- -run-pass=aarch64-ldst-opt -verify-machineinstrs -o - %s | FileCheck %s
# Check that we copy implicit operands.
---
name: impdef_op1
tracksRegLiveness: true
body: |
bb.0:
liveins: $lr
; CHECK-LABEL: name: impdef_op1
; CHECK: liveins: $lr
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: renamable $q5, renamable $q20 = LDPQi renamable $lr, 3, implicit-def $q4_q5 :: (load (s128))
; CHECK-NEXT: $q0 = ORRv16i8 $q4, killed $q4
; CHECK-NEXT: $q1 = ORRv16i8 $q5, killed $q5
; CHECK-NEXT: RET_ReallyLR
renamable $q5 = LDRQui renamable $lr, 3, implicit-def $q4_q5 :: (load (s128))
renamable $q20 = LDRQui renamable $lr, 4 :: (load (s128))
$q0 = ORRv16i8 $q4, killed $q4
$q1 = ORRv16i8 $q5, killed $q5
RET_ReallyLR
...
---
name: impdef_op2
body: |
bb.0:
liveins: $lr
; CHECK-LABEL: name: impdef_op2
; CHECK: liveins: $lr
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: renamable $q20, renamable $q5 = LDPQi renamable $lr, 3, implicit-def $q4_q5 :: (load (s128))
; CHECK-NEXT: $q0 = ORRv16i8 $q4, killed $q4
; CHECK-NEXT: $q1 = ORRv16i8 $q5, killed $q5
; CHECK-NEXT: RET_ReallyLR
renamable $q20 = LDRQui renamable $lr, 3 :: (load (s128))
renamable $q5 = LDRQui renamable $lr, 4, implicit-def $q4_q5 :: (load (s128))
$q0 = ORRv16i8 $q4, killed $q4
$q1 = ORRv16i8 $q5, killed $q5
RET_ReallyLR
...
---
name: impdef_both
body: |
bb.0:
liveins: $lr
; CHECK-LABEL: name: impdef_both
; CHECK: liveins: $lr
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: renamable $q5, renamable $q20 = LDPQi renamable $lr, 3, implicit-def $q4_q5, implicit-def $q20_q21 :: (load (s128))
; CHECK-NEXT: $q0 = ORRv16i8 $q4, killed $q4
; CHECK-NEXT: $q1 = ORRv16i8 $q5, killed $q5
; CHECK-NEXT: $q2 = ORRv16i8 $q20, killed $q20
; CHECK-NEXT: $q3 = ORRv16i8 $q21, killed $q21
; CHECK-NEXT: RET_ReallyLR
renamable $q5 = LDRQui renamable $lr, 3, implicit-def $q4_q5 :: (load (s128))
renamable $q20 = LDRQui renamable $lr, 4, implicit-def $q20_q21 :: (load (s128))
$q0 = ORRv16i8 $q4, killed $q4
$q1 = ORRv16i8 $q5, killed $q5
$q2 = ORRv16i8 $q20, killed $q20
$q3 = ORRv16i8 $q21, killed $q21
RET_ReallyLR
...
---
name: impdef_both_same
body: |
bb.0:
liveins: $lr
; CHECK-LABEL: name: impdef_both_same
; CHECK: liveins: $lr
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: renamable $q5, renamable $q20 = LDPQi renamable $lr, 3, implicit-def $q4_q5 :: (load (s128))
; CHECK-NEXT: $q0 = ORRv16i8 $q4, killed $q4
; CHECK-NEXT: $q1 = ORRv16i8 $q5, killed $q5
; CHECK-NEXT: RET_ReallyLR
renamable $q5 = LDRQui renamable $lr, 3, implicit-def $q4_q5 :: (load (s128))
renamable $q20 = LDRQui renamable $lr, 4, implicit-def $q4_q5 :: (load (s128))
$q0 = ORRv16i8 $q4, killed $q4
$q1 = ORRv16i8 $q5, killed $q5
RET_ReallyLR
...