From: Scott Douglass Date: Thu, 9 Jul 2015 14:13:48 +0000 (+0000) Subject: [ARM] Don't be overzealous converting Thumb1 3 to 2 operands X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7b8defda793c0f22fdccb98232d0ae5230453d6f;p=oota-llvm.git [ARM] Don't be overzealous converting Thumb1 3 to 2 operands Differential Revision: http://reviews.llvm.org/D11056 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241801 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index cea7070abd0..0ae6925c28b 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -5512,6 +5512,11 @@ void ARMAsmParser::tryConvertingToTwoOperandForm(StringRef Mnemonic, if (((Mnemonic == "add" && CarrySetting) || Mnemonic == "sub") && Op5.isReg()) Transform = false; + + // Don't transform 'add/sub{s} Rd, Rd, #imm' if the immediate fits into + // 3-bits because the ARMARM says not to. + if ((Mnemonic == "add" || Mnemonic == "sub") && Op5.isImm0_7()) + Transform = false; } if (Transform) diff --git a/test/MC/ARM/thumb_rewrites.s b/test/MC/ARM/thumb_rewrites.s index ed712156213..b2ef83d4936 100644 --- a/test/MC/ARM/thumb_rewrites.s +++ b/test/MC/ARM/thumb_rewrites.s @@ -1,5 +1,11 @@ @ RUN: llvm-mc -triple thumbv6m -show-encoding < %s | FileCheck %s + adds r1, r1, #3 +@ CHECK: adds r1, r1, #3 @ encoding: [0xc9,0x1c] + + adds r1, #3 +@ CHECK: adds r1, #3 @ encoding: [0x03,0x31] + adds r0, r0, #8 @ CHECK: adds r0, #8 @ encoding: [0x08,0x30] @@ -34,6 +40,12 @@ subs r0, r0, r0 @ CHECK: subs r0, r0, r0 @ encoding: [0x00,0x1a] + subs r3, r3, #5 +@ CHECK: subs r3, r3, #5 @ encoding: [0x5b,0x1f] + + subs r3, #5 +@ CHECK: subs r3, #5 @ encoding: [0x05,0x3b] + subs r2, r2, #8 @ CHECK: subs r2, #8 @ encoding: [0x08,0x3a]