• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -O3 -mcpu=pwr8 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s
2
3; Test swap removal when a vector splat must be adjusted to make it legal.
4;
5; Test generated from following C code:
6;
7; vector char vc = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
8; vector char vcr;
9; vector short vs = {0, 1, 2, 3, 4, 5, 6, 7};
10; vector short vsr;
11; vector int vi = {0, 1, 2, 3};
12; vector int vir;
13;
14; void cfoo ()
15; {
16;   vcr = (vector char){vc[5], vc[5], vc[5], vc[5], vc[5], vc[5], vc[5], vc[5],
17;                       vc[5], vc[5], vc[5], vc[5], vc[5], vc[5], vc[5], vc[5]};
18; }
19;
20; void sfoo ()
21; {
22;   vsr = (vector short){vs[6], vs[6], vs[6], vs[6],
23;                        vs[6], vs[6], vs[6], vs[6]};
24; }
25;
26; void ifoo ()
27; {
28;   vir = (vector int){vi[1], vi[1], vi[1], vi[1]};
29; }
30
31@vc = global <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, align 16
32@vs = global <8 x i16> <i16 0, i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7>, align 16
33@vi = global <4 x i32> <i32 0, i32 1, i32 2, i32 3>, align 16
34@vcr = common global <16 x i8> zeroinitializer, align 16
35@vsr = common global <8 x i16> zeroinitializer, align 16
36@vir = common global <4 x i32> zeroinitializer, align 16
37
38; Function Attrs: nounwind
39define void @cfoo() {
40entry:
41  %0 = load <16 x i8>, <16 x i8>* @vc, align 16
42  %vecinit30 = shufflevector <16 x i8> %0, <16 x i8> undef, <16 x i32> <i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5>
43  store <16 x i8> %vecinit30, <16 x i8>* @vcr, align 16
44  ret void
45}
46
47; Function Attrs: nounwind
48define void @sfoo() {
49entry:
50  %0 = load <8 x i16>, <8 x i16>* @vs, align 16
51  %vecinit14 = shufflevector <8 x i16> %0, <8 x i16> undef, <8 x i32> <i32 6, i32 6, i32 6, i32 6, i32 6, i32 6, i32 6, i32 6>
52  store <8 x i16> %vecinit14, <8 x i16>* @vsr, align 16
53  ret void
54}
55
56; Function Attrs: nounwind
57define void @ifoo() {
58entry:
59  %0 = load <4 x i32>, <4 x i32>* @vi, align 16
60  %vecinit6 = shufflevector <4 x i32> %0, <4 x i32> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
61  store <4 x i32> %vecinit6, <4 x i32>* @vir, align 16
62  ret void
63}
64
65; Justification:
66;  Byte splat of element 5 (BE) becomes element 15-5 = 10 (LE)
67;  which becomes (10+8)%16 = 2 (LE swapped).
68;
69;  Halfword splat of element 6 (BE) becomes element 7-6 = 1 (LE)
70;  which becomes (1+4)%8 = 5 (LE swapped).
71;
72;  Word splat of element 1 (BE) becomes element 3-1 = 2 (LE)
73;  which becomes (2+2)%4 = 0 (LE swapped).
74
75; CHECK-NOT: xxpermdi
76; CHECK-NOT: xxswapd
77
78; CHECK-LABEL: @cfoo
79; CHECK: lxvd2x
80; CHECK: vspltb {{[0-9]+}}, {{[0-9]+}}, 2
81; CHECK: stxvd2x
82
83; CHECK-LABEL: @sfoo
84; CHECK: lxvd2x
85; CHECK: vsplth {{[0-9]+}}, {{[0-9]+}}, 5
86; CHECK: stxvd2x
87
88; CHECK-LABEL: @ifoo
89; CHECK: lxvd2x
90; CHECK: xxspltw {{[0-9]+}}, {{[0-9]+}}, 0
91; CHECK: stxvd2x
92