1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

[AArch64] Avoid pairing loads with same result reg

When pairing ldr instructions to an ldp instruction, we cannot pair two ldr
destination registers where one is a sub or super register of the other.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D86906
This commit is contained in:
Congzhe Cao 2020-09-22 16:21:27 -04:00 committed by Danilo C. Grael
parent 3c9a842f53
commit a77f090539
2 changed files with 45 additions and 4 deletions

View File

@ -1550,10 +1550,12 @@ AArch64LoadStoreOpt::findMatchingInsn(MachineBasicBlock::iterator I,
continue;
}
}
// If the destination register of the loads is the same register, bail
// and keep looking. A load-pair instruction with both destination
// registers the same is UNPREDICTABLE and will result in an exception.
if (MayLoad && Reg == getLdStRegOp(MI).getReg()) {
// If the destination register of one load is the same register or a
// sub/super register of the other load, bail and keep looking. A
// load-pair instruction with both destination registers the same is
// UNPREDICTABLE and will result in an exception.
if (MayLoad &&
TRI->isSuperOrSubRegisterEq(Reg, getLdStRegOp(MI).getReg())) {
LiveRegUnits::accumulateUsedDefed(MI, ModifiedRegUnits, UsedRegUnits,
TRI);
MemInsns.push_back(&MI);

View File

@ -0,0 +1,39 @@
# RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -run-pass=aarch64-ldst-opt %s -o - | FileCheck %s
#
# The test below tests that when the AArch64 Load Store Optimization pass tries to
# convert load instructions into a ldp instruction, and when the destination
# registers are sub/super register of each other, then the convertion should not occur.
#
# For example, for the following pattern:
# ldr x10 [x9]
# ldr w10 [x9, 8],
# We cannot convert it to an ldp instruction.
#
# CHECK-NOT: LDP
# CHECK: $x10 = LDRSWui $x9, 0
# CHECK: $w10 = LDRWui $x9, 1
# CHECK: RET
---
name: test1
tracksRegLiveness: true
body: |
bb.0:
liveins: $x9
$x10 = LDRSWui $x9, 0 :: (load 4)
$w10 = LDRWui $x9, 1 :: (load 4)
RET undef $lr, implicit undef $w0
...
# CHECK-NOT: LDP
# CHECK: $w10 = LDRWui $x9, 0
# CHECK: $x10 = LDRSWui $x9, 1
# CHECK: RET
---
name: test2
tracksRegLiveness: true
body: |
bb.0:
liveins: $x9
$w10 = LDRWui $x9, 0 :: (load 4)
$x10 = LDRSWui $x9, 1 :: (load 4)
RET undef $lr, implicit undef $w0
...