Allow shufps x, x, mask to be converted to pshufd x, mask to save a move.
authorEvan Cheng <evan.cheng@apple.com>
Tue, 30 May 2006 20:26:50 +0000 (20:26 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Tue, 30 May 2006 20:26:50 +0000 (20:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28565 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86InstrInfo.cpp
lib/Target/X86/X86InstrSSE.td

index e397163a8938086ed257f55054f54e2b31e29826..3c84ef5f9e88eebe340509a21eb96dfdb2fbf5c8 100644 (file)
@@ -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.  :(
index e777f30b64043e9ae66483ec838513f9ac2c02a0..ca6ed88bdc2d42770940eeec8105144215f6e756 100644 (file)
@@ -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}",