From 8bec0f9db187b29ea54784efa8b33d90f5694d33 Mon Sep 17 00:00:00 2001 From: Toma Tabacu Date: Tue, 28 Apr 2015 14:06:35 +0000 Subject: [PATCH] [mips] [IAS] Do not generate redundant ORi in createLShiftOri. Summary: If the immediate is 0, the ORi is pointless. Reviewers: dsanders Reviewed By: dsanders Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8969 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235990 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Mips/AsmParser/MipsAsmParser.cpp | 4 ++++ test/MC/Mips/mips-expansions.s | 13 ++++++++----- test/MC/Mips/mips64-expansions.s | 16 ++++++++-------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index 4d57c79c678..4779c227465 100644 --- a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -1645,6 +1645,10 @@ void createLShiftOri(MCOperand Operand, unsigned RegNo, SMLoc IDLoc, Instructions.push_back(tmpInst); tmpInst.clear(); } + // There's no need for an ORi if the immediate is 0. + if (Operand.isImm() && Operand.getImm() == 0) + return; + tmpInst.setOpcode(Mips::ORi); tmpInst.addOperand(MCOperand::CreateReg(RegNo)); tmpInst.addOperand(MCOperand::CreateReg(RegNo)); diff --git a/test/MC/Mips/mips-expansions.s b/test/MC/Mips/mips-expansions.s index 490b8147413..f832dd865fd 100644 --- a/test/MC/Mips/mips-expansions.s +++ b/test/MC/Mips/mips-expansions.s @@ -4,11 +4,13 @@ #------------------------------------------------------------------------------ # Load immediate instructions #------------------------------------------------------------------------------ -# CHECK: ori $5, $zero, 123 # encoding: [0x7b,0x00,0x05,0x34] -# CHECK: addiu $6, $zero, -2345 # encoding: [0xd7,0xf6,0x06,0x24] -# CHECK: lui $7, 1 # encoding: [0x01,0x00,0x07,0x3c] -# CHECK: ori $7, $7, 2 # encoding: [0x02,0x00,0xe7,0x34] -# CHECK: addiu $8, $zero, -8 # encoding: [0xf8,0xff,0x08,0x24] +# CHECK: ori $5, $zero, 123 # encoding: [0x7b,0x00,0x05,0x34] +# CHECK: addiu $6, $zero, -2345 # encoding: [0xd7,0xf6,0x06,0x24] +# CHECK: lui $7, 1 # encoding: [0x01,0x00,0x07,0x3c] +# CHECK: ori $7, $7, 2 # encoding: [0x02,0x00,0xe7,0x34] +# CHECK: addiu $8, $zero, -8 # encoding: [0xf8,0xff,0x08,0x24] +# CHECK: lui $9, 1 # encoding: [0x01,0x00,0x09,0x3c] +# CHECK-NOT: ori $9, $9, 0 # encoding: [0x00,0x00,0x29,0x35] # CHECK: addiu $4, $zero, 20 # encoding: [0x14,0x00,0x04,0x24] # CHECK: lui $7, 1 # encoding: [0x01,0x00,0x07,0x3c] @@ -70,6 +72,7 @@ li $6,-2345 li $7,65538 li $8, ~7 + li $9, 0x10000 la $a0, 20 la $7,65538 diff --git a/test/MC/Mips/mips64-expansions.s b/test/MC/Mips/mips64-expansions.s index 0efdd2fa5c8..8a8128e6b4c 100644 --- a/test/MC/Mips/mips64-expansions.s +++ b/test/MC/Mips/mips64-expansions.s @@ -52,25 +52,25 @@ # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] # CHECK: ori $12, $12, 28609 # encoding: [0xc1,0x6f,0x8c,0x35] # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] -# CHECK: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] +# CHECK-NOT: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] # CHECK: lui $12, 355 # encoding: [0x63,0x01,0x0c,0x3c] # CHECK: ori $12, $12, 17784 # encoding: [0x78,0x45,0x8c,0x35] # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] # CHECK: ori $12, $12, 23946 # encoding: [0x8a,0x5d,0x8c,0x35] # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] -# CHECK: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] +# CHECK-NOT: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] # CHECK: lui $12, 3552 # encoding: [0xe0,0x0d,0x0c,0x3c] # CHECK: ori $12, $12, 46771 # encoding: [0xb3,0xb6,0x8c,0x35] # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] # CHECK: ori $12, $12, 42852 # encoding: [0x64,0xa7,0x8c,0x35] # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] -# CHECK: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] +# CHECK-NOT: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] # CHECK: lui $12, 35527 # encoding: [0xc7,0x8a,0x0c,0x3c] # CHECK: ori $12, $12, 8964 # encoding: [0x04,0x23,0x8c,0x35] # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] # CHECK: ori $12, $12, 35304 # encoding: [0xe8,0x89,0x8c,0x35] # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] -# CHECK: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] +# CHECK-NOT: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] # CHECK: addiu $12, $zero, -1 # encoding: [0xff,0xff,0x0c,0x24] # CHECK: addiu $12, $zero, -10 # encoding: [0xf6,0xff,0x0c,0x24] # CHECK: addiu $12, $zero, -100 # encoding: [0x9c,0xff,0x0c,0x24] @@ -147,25 +147,25 @@ # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] # CHECK: ori $12, $12, 36927 # encoding: [0x3f,0x90,0x8c,0x35] # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] -# CHECK: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] +# CHECK-NOT: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] # CHECK: lui $12, 65180 # encoding: [0x9c,0xfe,0x0c,0x3c] # CHECK: ori $12, $12, 47751 # encoding: [0x87,0xba,0x8c,0x35] # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] # CHECK: ori $12, $12, 41590 # encoding: [0x76,0xa2,0x8c,0x35] # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] -# CHECK: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] +# CHECK-NOT: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] # CHECK: lui $12, 61983 # encoding: [0x1f,0xf2,0x0c,0x3c] # CHECK: ori $12, $12, 18764 # encoding: [0x4c,0x49,0x8c,0x35] # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] # CHECK: ori $12, $12, 22684 # encoding: [0x9c,0x58,0x8c,0x35] # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] -# CHECK: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] +# CHECK-NOT: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] # CHECK: lui $12, 30008 # encoding: [0x38,0x75,0x0c,0x3c] # CHECK: ori $12, $12, 56571 # encoding: [0xfb,0xdc,0x8c,0x35] # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] # CHECK: ori $12, $12, 30232 # encoding: [0x18,0x76,0x8c,0x35] # CHECK: dsll $12, $12, 16 # encoding: [0x38,0x64,0x0c,0x00] -# CHECK: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] +# CHECK-NOT: ori $12, $12, 0 # encoding: [0x00,0x00,0x8c,0x35] dli $t0, 1 dli $t0, 10 -- 2.34.1