[PATCH] D11132: [ARM] Handle commutativity when converting to tADDhirr in Thumb2
scott douglass
sdouglass at arm.com
Mon Jul 13 01:35:14 PDT 2015
scott-0 created this revision.
scott-0 added a subscriber: llvm-commits.
Herald added subscribers: rengolin, aemerson.
http://reviews.llvm.org/D11132
Files:
lib/Target/ARM/AsmParser/ARMAsmParser.cpp
test/MC/ARM/thumb2-narrow-dp.ll
Index: test/MC/ARM/thumb2-narrow-dp.ll
===================================================================
--- test/MC/ARM/thumb2-narrow-dp.ll
+++ test/MC/ARM/thumb2-narrow-dp.ll
@@ -44,6 +44,8 @@
// CHECK: adds r0, r2, r1 @ encoding: [0x50,0x18]
ADDS r2, r2, r1 // ADDS has T1 narrow 3 operand
// CHECK: adds r2, r2, r1 @ encoding: [0x52,0x18]
+ ADD r3, r1, r3 // T2
+// CHECK: add r3, r1 @ encoding: [0x0b,0x44]
IT EQ
// CHECK: it eq @ encoding: [0x08,0xbf]
Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===================================================================
--- lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -8215,17 +8215,25 @@
// If the destination and first source operand are the same, and
// there's no setting of the flags, use encoding T2 instead of T3.
// Note that this is only for ADD, not SUB. This mirrors the system
- // 'as' behaviour. Make sure the wide encoding wasn't explicit.
- if (Inst.getOperand(0).getReg() != Inst.getOperand(1).getReg() ||
+ // 'as' behaviour. Also take advantage of ADD being commutative.
+ // Make sure the wide encoding wasn't explicit.
+ bool Swap = false;
+ auto DestReg = Inst.getOperand(0).getReg();
+ bool Transform = DestReg == Inst.getOperand(1).getReg();
+ if (!Transform && DestReg == Inst.getOperand(2).getReg()) {
+ Transform = true;
+ Swap = true;
+ }
+ if (!Transform ||
Inst.getOperand(5).getReg() != 0 ||
(static_cast<ARMOperand &>(*Operands[3]).isToken() &&
static_cast<ARMOperand &>(*Operands[3]).getToken() == ".w"))
break;
MCInst TmpInst;
TmpInst.setOpcode(ARM::tADDhirr);
TmpInst.addOperand(Inst.getOperand(0));
TmpInst.addOperand(Inst.getOperand(0));
- TmpInst.addOperand(Inst.getOperand(2));
+ TmpInst.addOperand(Inst.getOperand(Swap ? 1 : 2));
TmpInst.addOperand(Inst.getOperand(3));
TmpInst.addOperand(Inst.getOperand(4));
Inst = TmpInst;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11132.29531.patch
Type: text/x-patch
Size: 2102 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150713/44740c2b/attachment.bin>
More information about the llvm-commits
mailing list