[llvm] r279913 - [X86] Enable FR32/FR64 cmpeq/cmpne/cmpunord/cmpord to be commuted.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 26 22:22:13 PDT 2016


Author: ctopper
Date: Sat Aug 27 00:22:12 2016
New Revision: 279913

URL: http://llvm.org/viewvc/llvm-project?rev=279913&view=rev
Log:
[X86] Enable FR32/FR64 cmpeq/cmpne/cmpunord/cmpord to be commuted.

Modified:
    llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
    llvm/trunk/lib/Target/X86/X86InstrSSE.td
    llvm/trunk/test/CodeGen/X86/fast-isel-cmp.ll

Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=279913&r1=279912&r2=279913&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Sat Aug 27 00:22:12 2016
@@ -3389,8 +3389,12 @@ MachineInstr *X86InstrInfo::commuteInstr
     return TargetInstrInfo::commuteInstructionImpl(WorkingMI, /*NewMI=*/false,
                                                    OpIdx1, OpIdx2);
   }
+  case X86::CMPSDrr:
+  case X86::CMPSSrr:
   case X86::CMPPDrri:
   case X86::CMPPSrri:
+  case X86::VCMPSDrr:
+  case X86::VCMPSSrr:
   case X86::VCMPPDrri:
   case X86::VCMPPSrri:
   case X86::VCMPPDYrri:
@@ -3637,8 +3641,12 @@ bool X86InstrInfo::findCommutedOpIndices
     return false;
 
   switch (MI.getOpcode()) {
+  case X86::CMPSDrr:
+  case X86::CMPSSrr:
   case X86::CMPPDrri:
   case X86::CMPPSrri:
+  case X86::VCMPSDrr:
+  case X86::VCMPSSrr:
   case X86::VCMPPDrri:
   case X86::VCMPPSrri:
   case X86::VCMPPDYrri:

Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=279913&r1=279912&r2=279913&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Sat Aug 27 00:22:12 2016
@@ -2325,6 +2325,7 @@ multiclass sse12_cmp_scalar<RegisterClas
                             Operand CC, SDNode OpNode, ValueType VT,
                             PatFrag ld_frag, string asm, string asm_alt,
                             OpndItins itins, ImmLeaf immLeaf> {
+  let isCommutable = 1 in
   def rr : SIi8<0xC2, MRMSrcReg,
                 (outs RC:$dst), (ins RC:$src1, RC:$src2, CC:$cc), asm,
                 [(set RC:$dst, (OpNode (VT RC:$src1), RC:$src2, immLeaf:$cc))],

Modified: llvm/trunk/test/CodeGen/X86/fast-isel-cmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-cmp.ll?rev=279913&r1=279912&r2=279913&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fast-isel-cmp.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fast-isel-cmp.ll Sat Aug 27 00:22:12 2016
@@ -285,8 +285,8 @@ define zeroext i1 @fcmp_oeq2(float %x) {
 define zeroext i1 @fcmp_oeq3(float %x) {
 ; SDAG-LABEL: fcmp_oeq3
 ; SDAG:       xorps    %xmm1, %xmm1
-; SDAG-NEXT:  cmpeqss  %xmm1, %xmm0
-; SDAG-NEXT:  movd     %xmm0, %eax
+; SDAG-NEXT:  cmpeqss  %xmm0, %xmm1
+; SDAG-NEXT:  movd     %xmm1, %eax
 ; SDAG-NEXT:  andl     $1, %eax
 ; FAST-LABEL: fcmp_oeq3
 ; FAST:       xorps    %xmm1, %xmm1
@@ -584,8 +584,8 @@ define zeroext i1 @fcmp_une2(float %x) {
 define zeroext i1 @fcmp_une3(float %x) {
 ; SDAG-LABEL: fcmp_une3
 ; SDAG:       xorps    %xmm1, %xmm1
-; SDAG-NEXT:  cmpneqss %xmm1, %xmm0
-; SDAG-NEXT:  movd     %xmm0, %eax
+; SDAG-NEXT:  cmpneqss %xmm0, %xmm1
+; SDAG-NEXT:  movd     %xmm1, %eax
 ; SDAG-NEXT:  andl     $1, %eax
 ; FAST-LABEL: fcmp_une3
 ; FAST:       xorps    %xmm1, %xmm1




More information about the llvm-commits mailing list