[llvm] r241871 - [x86] enable machine combiner reassociations for scalar double-precision adds

Sanjay Patel spatel at rotateright.com
Thu Jul 9 15:48:55 PDT 2015


Author: spatel
Date: Thu Jul  9 17:48:54 2015
New Revision: 241871

URL: http://llvm.org/viewvc/llvm-project?rev=241871&view=rev
Log:
[x86] enable machine combiner reassociations for scalar double-precision adds

Modified:
    llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
    llvm/trunk/test/CodeGen/X86/machine-combiner.ll

Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=241871&r1=241870&r2=241871&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Thu Jul  9 17:48:54 2015
@@ -6408,7 +6408,9 @@ static bool hasReassocSibling(const Mach
 //       2. Other math / logic operations (and, or)
 static bool isAssociativeAndCommutative(unsigned Opcode) {
   switch (Opcode) {
+  case X86::ADDSDrr:
   case X86::ADDSSrr:
+  case X86::VADDSDrr:
   case X86::VADDSSrr:
   case X86::MULSSrr:
   case X86::VMULSSrr:

Modified: llvm/trunk/test/CodeGen/X86/machine-combiner.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/machine-combiner.ll?rev=241871&r1=241870&r2=241871&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/machine-combiner.ll (original)
+++ llvm/trunk/test/CodeGen/X86/machine-combiner.ll Thu Jul  9 17:48:54 2015
@@ -144,7 +144,7 @@ define float @reassociate_adds6(float %x
   ret float %t2
 }
 
-; Verify that SSE and AVX scalar single precison multiplies are reassociated.
+; Verify that SSE and AVX scalar single-precison multiplies are reassociated.
 
 define float @reassociate_muls1(float %x0, float %x1, float %x2, float %x3) {
 ; SSE-LABEL: reassociate_muls1:
@@ -165,3 +165,25 @@ define float @reassociate_muls1(float %x
   %t2 = fmul float %x3, %t1
   ret float %t2
 }
+
+; Verify that SSE and AVX scalar double-precison adds are reassociated.
+
+define double @reassociate_adds_double(double %x0, double %x1, double %x2, double %x3) {
+; SSE-LABEL: reassociate_adds_double:
+; SSE:       # BB#0:
+; SSE-NEXT:    divsd %xmm1, %xmm0
+; SSE-NEXT:    addsd %xmm3, %xmm2
+; SSE-NEXT:    addsd %xmm2, %xmm0
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: reassociate_adds_double:
+; AVX:       # BB#0:
+; AVX-NEXT:    vdivsd %xmm1, %xmm0, %xmm0
+; AVX-NEXT:    vaddsd %xmm3, %xmm2, %xmm1
+; AVX-NEXT:    vaddsd %xmm1, %xmm0, %xmm0
+; AVX-NEXT:    retq
+  %t0 = fdiv double %x0, %x1
+  %t1 = fadd double %x2, %t0
+  %t2 = fadd double %x3, %t1
+  ret double %t2
+}





More information about the llvm-commits mailing list