[llvm] r294847 - [X86][3DNow!] Enable PFSUB<->PFSUBR commutation

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 11 05:51:15 PST 2017


Author: rksimon
Date: Sat Feb 11 07:51:14 2017
New Revision: 294847

URL: http://llvm.org/viewvc/llvm-project?rev=294847&view=rev
Log:
[X86][3DNow!] Enable PFSUB<->PFSUBR commutation

Modified:
    llvm/trunk/lib/Target/X86/X86Instr3DNow.td
    llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
    llvm/trunk/test/CodeGen/X86/commute-3dnow.ll

Modified: llvm/trunk/lib/Target/X86/X86Instr3DNow.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr3DNow.td?rev=294847&r1=294846&r2=294847&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86Instr3DNow.td (original)
+++ llvm/trunk/lib/Target/X86/X86Instr3DNow.td Sat Feb 11 07:51:14 2017
@@ -80,8 +80,8 @@ defm PFRCPIT1 : I3DNow_binop_rm_int<0xA6
 defm PFRCPIT2 : I3DNow_binop_rm_int<0xB6, "pfrcpit2">;
 defm PFRSQIT1 : I3DNow_binop_rm_int<0xA7, "pfrsqit1">;
 defm PFRSQRT  : I3DNow_conv_rm_int<0x97, "pfrsqrt">;
-defm PFSUB    : I3DNow_binop_rm_int<0x9A, "pfsub">;
-defm PFSUBR   : I3DNow_binop_rm_int<0xAA, "pfsubr">;
+defm PFSUB    : I3DNow_binop_rm_int<0x9A, "pfsub", 1>;
+defm PFSUBR   : I3DNow_binop_rm_int<0xAA, "pfsubr", 1>;
 defm PI2FD    : I3DNow_conv_rm_int<0x0D, "pi2fd">;
 defm PMULHRW  : I3DNow_binop_rm_int<0xB7, "pmulhrw", 1>;
 

Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=294847&r1=294846&r2=294847&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Sat Feb 11 07:51:14 2017
@@ -4813,6 +4813,18 @@ MachineInstr *X86InstrInfo::commuteInstr
     return TargetInstrInfo::commuteInstructionImpl(WorkingMI, /*NewMI=*/false,
                                                    OpIdx1, OpIdx2);
   }
+  case X86::PFSUBrr:
+  case X86::PFSUBRrr: {
+    // PFSUB  x, y: x = x - y
+    // PFSUBR x, y: x = y - x
+    unsigned Opc =
+        (X86::PFSUBRrr == MI.getOpcode() ? X86::PFSUBrr : X86::PFSUBRrr);
+    auto &WorkingMI = cloneIfNew(MI);
+    WorkingMI.setDesc(get(Opc));
+    return TargetInstrInfo::commuteInstructionImpl(WorkingMI, /*NewMI=*/false,
+                                                   OpIdx1, OpIdx2);
+    break;
+  }
   case X86::BLENDPDrri:
   case X86::BLENDPSrri:
   case X86::PBLENDWrri:

Modified: llvm/trunk/test/CodeGen/X86/commute-3dnow.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/commute-3dnow.ll?rev=294847&r1=294846&r2=294847&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/commute-3dnow.ll (original)
+++ llvm/trunk/test/CodeGen/X86/commute-3dnow.ll Sat Feb 11 07:51:14 2017
@@ -31,7 +31,6 @@ define void @commute_m_pfadd(x86_mmx *%a
 }
 declare x86_mmx @llvm.x86.3dnow.pfadd(x86_mmx, x86_mmx)
 
-; FIXME - missed PFSUB commutation.
 define void @commute_m_pfsub(x86_mmx *%a0, x86_mmx *%a1, x86_mmx *%a2) nounwind {
 ; X32-LABEL: commute_m_pfsub:
 ; X32:       # BB#0:
@@ -39,19 +38,17 @@ define void @commute_m_pfsub(x86_mmx *%a
 ; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx
 ; X32-NEXT:    movl {{[0-9]+}}(%esp), %edx
 ; X32-NEXT:    movq (%edx), %mm0
-; X32-NEXT:    movq (%ecx), %mm1
 ; X32-NEXT:    pfsub (%eax), %mm0
-; X32-NEXT:    pfsub %mm0, %mm1
-; X32-NEXT:    movq %mm1, (%ecx)
+; X32-NEXT:    pfsubr (%ecx), %mm0
+; X32-NEXT:    movq %mm0, (%ecx)
 ; X32-NEXT:    retl
 ;
 ; X64-LABEL: commute_m_pfsub:
 ; X64:       # BB#0:
 ; X64-NEXT:    movq (%rdi), %mm0
-; X64-NEXT:    movq (%rdx), %mm1
 ; X64-NEXT:    pfsub (%rsi), %mm0
-; X64-NEXT:    pfsub %mm0, %mm1
-; X64-NEXT:    movq %mm1, (%rdx)
+; X64-NEXT:    pfsubr (%rdx), %mm0
+; X64-NEXT:    movq %mm0, (%rdx)
 ; X64-NEXT:    retq
   %1 = load x86_mmx, x86_mmx* %a0
   %2 = load x86_mmx, x86_mmx* %a1
@@ -63,7 +60,6 @@ define void @commute_m_pfsub(x86_mmx *%a
 }
 declare x86_mmx @llvm.x86.3dnow.pfsub(x86_mmx, x86_mmx)
 
-; FIXME - missed PFSUBR commutation.
 define void @commute_m_pfsubr(x86_mmx *%a0, x86_mmx *%a1, x86_mmx *%a2) nounwind {
 ; X32-LABEL: commute_m_pfsubr:
 ; X32:       # BB#0:
@@ -71,19 +67,17 @@ define void @commute_m_pfsubr(x86_mmx *%
 ; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx
 ; X32-NEXT:    movl {{[0-9]+}}(%esp), %edx
 ; X32-NEXT:    movq (%edx), %mm0
-; X32-NEXT:    movq (%ecx), %mm1
 ; X32-NEXT:    pfsubr (%eax), %mm0
-; X32-NEXT:    pfsubr %mm0, %mm1
-; X32-NEXT:    movq %mm1, (%ecx)
+; X32-NEXT:    pfsub (%ecx), %mm0
+; X32-NEXT:    movq %mm0, (%ecx)
 ; X32-NEXT:    retl
 ;
 ; X64-LABEL: commute_m_pfsubr:
 ; X64:       # BB#0:
 ; X64-NEXT:    movq (%rdi), %mm0
-; X64-NEXT:    movq (%rdx), %mm1
 ; X64-NEXT:    pfsubr (%rsi), %mm0
-; X64-NEXT:    pfsubr %mm0, %mm1
-; X64-NEXT:    movq %mm1, (%rdx)
+; X64-NEXT:    pfsub (%rdx), %mm0
+; X64-NEXT:    movq %mm0, (%rdx)
 ; X64-NEXT:    retq
   %1 = load x86_mmx, x86_mmx* %a0
   %2 = load x86_mmx, x86_mmx* %a1




More information about the llvm-commits mailing list