OSDN Git Service

[X86] Enable FR32/FR64 cmpeq/cmpne/cmpunord/cmpord to be commuted.
authorCraig Topper <craig.topper@gmail.com>
Sat, 27 Aug 2016 05:22:12 +0000 (05:22 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sat, 27 Aug 2016 05:22:12 +0000 (05:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279913 91177308-0d34-0410-b5e6-96231b3b80d8

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

index a16ff3f..2419f1f 100644 (file)
@@ -3389,8 +3389,12 @@ MachineInstr *X86InstrInfo::commuteInstructionImpl(MachineInstr &MI, bool NewMI,
     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(MachineInstr &MI, unsigned &SrcOpIdx1,
     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:
index d7b28d9..c1c8102 100644 (file)
@@ -2325,6 +2325,7 @@ multiclass sse12_cmp_scalar<RegisterClass RC, X86MemOperand x86memop,
                             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))],
index d15dd50..a4833a7 100644 (file)
@@ -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