[X86] Don't pass a scale value of 0 to scatter/gather intrinsics. This causes the...
[oota-llvm.git] / test / CodeGen / X86 / i64-mem-copy.ll
1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=sse2 | FileCheck %s --check-prefix=X64
2 ; RUN: llc < %s -mtriple=i386-unknown-unknown -mattr=sse2 | FileCheck %s --check-prefix=X32
3 ; RUN: llc < %s -mtriple=i386-unknown-unknown -mattr=avx2 | FileCheck %s --check-prefix=X32AVX
4
5 ; Use movq or movsd to load / store i64 values if sse2 is available.
6 ; rdar://6659858
7
8 define void @foo(i64* %x, i64* %y) {
9 ; X64-LABEL: foo:
10 ; X64:       # BB#0:
11 ; X64-NEXT:    movq (%rsi), %rax
12 ; X64-NEXT:    movq %rax, (%rdi)
13 ; X64-NEXT:    retq
14 ;
15 ; X32-LABEL: foo:
16 ; X32:       # BB#0:
17 ; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
18 ; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx
19 ; X32-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
20 ; X32-NEXT:    movsd %xmm0, (%eax)
21 ; X32-NEXT:    retl
22   %tmp1 = load i64, i64* %y, align 8
23   store i64 %tmp1, i64* %x, align 8
24   ret void
25 }
26
27 ; Verify that a 64-bit chunk extracted from a vector is stored with a movq
28 ; regardless of whether the system is 64-bit.
29
30 define void @store_i64_from_vector(<8 x i16> %x, <8 x i16> %y, i64* %i) {
31 ; X64-LABEL: store_i64_from_vector:
32 ; X64:       # BB#0:
33 ; X64-NEXT:    paddw %xmm1, %xmm0
34 ; X64-NEXT:    movq %xmm0, (%rdi)
35 ; X64-NEXT:    retq
36 ;
37 ; X32-LABEL: store_i64_from_vector:
38 ; X32:       # BB#0:
39 ; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
40 ; X32-NEXT:    paddw %xmm1, %xmm0
41 ; X32-NEXT:    movq %xmm0, (%eax)
42 ; X32-NEXT:    retl
43   %z = add <8 x i16> %x, %y                          ; force execution domain
44   %bc = bitcast <8 x i16> %z to <2 x i64>
45   %vecext = extractelement <2 x i64> %bc, i32 0
46   store i64 %vecext, i64* %i, align 8
47   ret void
48 }
49
50 define void @store_i64_from_vector256(<16 x i16> %x, <16 x i16> %y, i64* %i) {
51 ; X32AVX-LABEL: store_i64_from_vector256:
52 ; X32AVX:       # BB#0:
53 ; X32AVX-NEXT:    movl {{[0-9]+}}(%esp), %eax
54 ; X32AVX-NEXT:    vpaddw %ymm1, %ymm0, %ymm0
55 ; X32AVX-NEXT:    vextracti128 $1, %ymm0, %xmm0
56 ; X32AVX-NEXT:    vmovq %xmm0, (%eax)
57 ; X32AVX-NEXT:    vzeroupper
58 ; X32AVX-NEXT:    retl
59   %z = add <16 x i16> %x, %y                          ; force execution domain
60   %bc = bitcast <16 x i16> %z to <4 x i64>
61   %vecext = extractelement <4 x i64> %bc, i32 2
62   store i64 %vecext, i64* %i, align 8
63   ret void
64 }
65
66 ; PR23476
67 ; Handle extraction from a non-simple / pre-legalization type.
68
69 define void @PR23476(<5 x i64> %in, i64* %out, i32 %index) {
70 ; X32-LABEL: PR23476:
71 ; X32:         movsd {{.*#+}} xmm0 = mem[0],zero
72 ; X32-NEXT:    movsd %xmm0, (%eax)
73   %ext = extractelement <5 x i64> %in, i32 %index
74   store i64 %ext, i64* %out, align 8
75   ret void
76 }