From ccba76bb254e653646b01cf5b8304b14092d372b Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Tue, 30 May 2006 20:26:50 +0000 Subject: Allow shufps x, x, mask to be converted to pshufd x, mask to save a move. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28565 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86InstrInfo.cpp | 13 ++++++++++++- lib/Target/X86/X86InstrSSE.td | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/Target') diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp index e397163a89..3c84ef5f9e 100644 --- a/lib/Target/X86/X86InstrInfo.cpp +++ b/lib/Target/X86/X86InstrInfo.cpp @@ -102,7 +102,6 @@ unsigned X86InstrInfo::isStoreToStackSlot(MachineInstr *MI, } - /// convertToThreeAddress - This method must be implemented by targets that /// set the M_CONVERTIBLE_TO_3_ADDR flag. When this flag is set, the target /// may be able to convert a two-address instruction into a true @@ -118,6 +117,18 @@ MachineInstr *X86InstrInfo::convertToThreeAddress(MachineInstr *MI) const { unsigned Dest = MI->getOperand(0).getReg(); unsigned Src = MI->getOperand(1).getReg(); + switch (MI->getOpcode()) { + default: break; + case X86::SHUFPSrri: { + assert(MI->getNumOperands() == 4 && "Unknown shufps instruction!"); + unsigned A = MI->getOperand(0).getReg(); + unsigned B = MI->getOperand(1).getReg(); + unsigned C = MI->getOperand(2).getReg(); + unsigned M = MI->getOperand(3).getImmedValue(); + return BuildMI(X86::PSHUFDri, 2, A).addReg(B).addImm(M); + } + } + // FIXME: None of these instructions are promotable to LEAs without // additional information. In particular, LEA doesn't set the flags that // add and inc do. :( diff --git a/lib/Target/X86/X86InstrSSE.td b/lib/Target/X86/X86InstrSSE.td index e777f30b64..ca6ed88bdc 100644 --- a/lib/Target/X86/X86InstrSSE.td +++ b/lib/Target/X86/X86InstrSSE.td @@ -1218,6 +1218,7 @@ def CMPPDrmi : PDIi8<0xC2, MRMSrcMem, // Shuffle and unpack instructions let isTwoAddress = 1 in { +let isConvertibleToThreeAddress = 1 in // Convert to pshufd def SHUFPSrri : PSIi8<0xC6, MRMSrcReg, (ops VR128:$dst, VR128:$src1, VR128:$src2, i32i8imm:$src3), "shufps {$src3, $src2, $dst|$dst, $src2, $src3}", -- cgit v1.2.3