From f47b94151099b723e679f84151ef0df13a86cbe2 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Wed, 9 Nov 2011 21:30:12 +0000 Subject: [PATCH] The ARM LDRH/STRH instructions use a +/-imm8 encoding, not an imm12. rdar://10418009 llvm-svn: 144213 --- lib/Target/ARM/ARMFastISel.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/Target/ARM/ARMFastISel.cpp b/lib/Target/ARM/ARMFastISel.cpp index 23629e76675..44c88aa7fd7 100644 --- a/lib/Target/ARM/ARMFastISel.cpp +++ b/lib/Target/ARM/ARMFastISel.cpp @@ -846,9 +846,17 @@ void ARMFastISel::ARMSimplifyAddress(Address &Addr, EVT VT) { switch (VT.getSimpleVT().SimpleTy) { default: assert(false && "Unhandled load/store type!"); + case MVT::i16: + if (isThumb2) + // Integer loads/stores handle 12-bit offsets. + needsLowering = ((Addr.Offset & 0xfff) != Addr.Offset); + else + // ARM i16 integer loads/stores handle +/-imm8 offsets. + if (Addr.Offset > 255 || Addr.Offset < -255) + needsLowering = true; + break; case MVT::i1: case MVT::i8: - case MVT::i16: case MVT::i32: // Integer loads/stores handle 12-bit offsets. needsLowering = ((Addr.Offset & 0xfff) != Addr.Offset); @@ -932,14 +940,14 @@ bool ARMFastISel::ARMEmitLoad(EVT VT, unsigned &ResultReg, Address &Addr) { switch (VT.getSimpleVT().SimpleTy) { // This is mostly going to be Neon/vector support. default: return false; - case MVT::i16: - Opc = isThumb2 ? ARM::t2LDRHi12 : ARM::LDRH; - RC = ARM::GPRRegisterClass; - break; case MVT::i8: Opc = isThumb2 ? ARM::t2LDRBi12 : ARM::LDRBi12; RC = ARM::GPRRegisterClass; break; + case MVT::i16: + Opc = isThumb2 ? ARM::t2LDRHi12 : ARM::LDRH; + RC = ARM::GPRRegisterClass; + break; case MVT::i32: Opc = isThumb2 ? ARM::t2LDRi12 : ARM::LDRi12; RC = ARM::GPRRegisterClass;