[X86,AVX] Add an isel pattern for X86VBroadcast.
authorAkira Hatanaka <ahatanaka@apple.com>
Thu, 25 Sep 2014 00:26:15 +0000 (00:26 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Thu, 25 Sep 2014 00:26:15 +0000 (00:26 +0000)
This fixes PR21050 and rdar://problem/18434607.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218431 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86InstrSSE.td
test/CodeGen/X86/avx-movdup.ll

index a186899d23104ff7b64cafdcf5e6e183737bdadc..b6210e7eb0bf113c56f84e4c5bf99c2d7783a4c7 100644 (file)
@@ -8775,6 +8775,9 @@ let Predicates = [HasAVX] in {
               (VPSHUFDri (COPY_TO_REGCLASS GR64:$src, VR128), 0x44), sub_xmm),
               (VPSHUFDri (COPY_TO_REGCLASS GR64:$src, VR128), 0x44), 1)>;
   }
+
+  def : Pat<(v2f64 (X86VBroadcast f64:$src)),
+            (VMOVDDUPrr (COPY_TO_REGCLASS FR64:$src, VR128))>;
 }
 
 //===----------------------------------------------------------------------===//
index 42d84def98a0eb83482a1b8539edbb6383f34286..19a0325937836a89773053089554be180da456f6 100644 (file)
@@ -32,3 +32,22 @@ entry:
   ret <4 x i64> %1
 }
 
+; Check that there is a pattern (v2f64 (X86VBroadcast f64:$src)).
+
+; CHECK-LABEL: _vbroadcast_v128_f64
+; CHECK: vmovsd LCPI{{[0-9]+}}_0(%rip), %xmm[[R0:[0-9]+]]
+; CHECK: vmovddup %xmm[[R0]], %xmm{{[0-9]+}}
+
+@E1 = external global [5 x double], align 16
+@.str3 = external unnamed_addr constant [44 x i8], align 1
+
+define void @vbroadcast_v128_f64() #0 {
+entry:
+  store <2 x double> <double -1.000000e+00, double -1.000000e+00>, <2 x double>* bitcast (double* getelementptr inbounds ([5 x double]* @E1, i64 0, i64 2) to <2 x double>*), align 16
+  tail call void @foo1(double -1.000000e+00)
+  ret void
+}
+
+declare void @foo1(double)
+
+attributes #0 = { optsize }