1
0
mirror of https://github.com/c64scene-ar/llvm-6502.git synced 2024-12-14 11:32:34 +00:00

Thumb2SizeReduction: Check the correct set of registers for LDMIA.

The register set for LDMIA begins at offset 3, not 4. We were previously
missing the short encoding of this instruction in the case where the base
register was the first register in the register set.

Also clean up some dead code:

- The isARMLowRegister check is redundant with what VerifyLowRegs does;
  replace with an assert.
- Remove handling of LDMDB instruction, which has no short encoding (and
  does not appear in ReduceTable).

Differential Revision: http://reviews.llvm.org/D9485

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236535 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Collingbourne 2015-05-05 20:07:10 +00:00
parent 97dbeaa8d5
commit 08c531db5f
2 changed files with 5 additions and 10 deletions
lib/Target/ARM
test/CodeGen/Thumb2

View File

@ -333,9 +333,7 @@ Thumb2SizeReduce::VerifyPredAndCC(MachineInstr *MI, const ReduceEntry &Entry,
static bool VerifyLowRegs(MachineInstr *MI) { static bool VerifyLowRegs(MachineInstr *MI) {
unsigned Opc = MI->getOpcode(); unsigned Opc = MI->getOpcode();
bool isPCOk = (Opc == ARM::t2LDMIA_RET || Opc == ARM::t2LDMIA || bool isPCOk = (Opc == ARM::t2LDMIA_RET || Opc == ARM::t2LDMIA_UPD);
Opc == ARM::t2LDMDB || Opc == ARM::t2LDMIA_UPD ||
Opc == ARM::t2LDMDB_UPD);
bool isLROk = (Opc == ARM::t2STMDB_UPD); bool isLROk = (Opc == ARM::t2STMDB_UPD);
bool isSPOk = isPCOk || isLROk; bool isSPOk = isPCOk || isLROk;
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
@ -413,16 +411,14 @@ Thumb2SizeReduce::ReduceLoadStore(MachineBasicBlock &MBB, MachineInstr *MI,
HasShift = true; HasShift = true;
OpNum = 4; OpNum = 4;
break; break;
case ARM::t2LDMIA: case ARM::t2LDMIA: {
case ARM::t2LDMDB: {
unsigned BaseReg = MI->getOperand(0).getReg(); unsigned BaseReg = MI->getOperand(0).getReg();
if (!isARMLowRegister(BaseReg) || Entry.WideOpc != ARM::t2LDMIA) assert(isARMLowRegister(BaseReg));
return false;
// For the non-writeback version (this one), the base register must be // For the non-writeback version (this one), the base register must be
// one of the registers being loaded. // one of the registers being loaded.
bool isOK = false; bool isOK = false;
for (unsigned i = 4; i < MI->getNumOperands(); ++i) { for (unsigned i = 3; i < MI->getNumOperands(); ++i) {
if (MI->getOperand(i).getReg() == BaseReg) { if (MI->getOperand(i).getReg() == BaseReg) {
isOK = true; isOK = true;
break; break;
@ -446,7 +442,6 @@ Thumb2SizeReduce::ReduceLoadStore(MachineBasicBlock &MBB, MachineInstr *MI,
break; break;
} }
case ARM::t2LDMIA_UPD: case ARM::t2LDMIA_UPD:
case ARM::t2LDMDB_UPD:
case ARM::t2STMIA_UPD: case ARM::t2STMIA_UPD:
case ARM::t2STMDB_UPD: { case ARM::t2STMDB_UPD: {
OpNum = 0; OpNum = 0;

View File

@ -109,7 +109,7 @@ entry:
define double @load_d(double* %a) { define double @load_d(double* %a) {
entry: entry:
; CHECK-LABEL: load_d: ; CHECK-LABEL: load_d:
; NONE: ldm.w r0, {r0, r1} ; NONE: ldm r0, {r0, r1}
; HARD: vldr d0, [r0] ; HARD: vldr d0, [r0]
%0 = load double, double* %a, align 8 %0 = load double, double* %a, align 8
ret double %0 ret double %0