blob: e75973af05ed2a87dd478f46e761f01f9cd16f69 [file] [log] [blame]
Simon Pilgrimd1282222017-07-04 12:33:53 +00001; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx,+xop | FileCheck %s --check-prefix=XOP
3; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f,+avx512vl | FileCheck %s --check-prefix=AVX512
4
5; fold (rot (rot x, c1), c2) -> rot x, c1+c2
6define <4 x i32> @combine_vec_rot_rot(<4 x i32> %x) {
7; XOP-LABEL: combine_vec_rot_rot:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +00008; XOP: # %bb.0:
Andrew Zhogin67a64042017-07-16 23:11:45 +00009; XOP-NEXT: vprotd {{.*}}(%rip), %xmm0, %xmm0
Simon Pilgrimd1282222017-07-04 12:33:53 +000010; XOP-NEXT: retq
11;
12; AVX512-LABEL: combine_vec_rot_rot:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000013; AVX512: # %bb.0:
Simon Pilgrim1cbe8c22017-07-17 14:11:30 +000014; AVX512-NEXT: vprolvd {{.*}}(%rip), %xmm0, %xmm0
Simon Pilgrimd1282222017-07-04 12:33:53 +000015; AVX512-NEXT: retq
16 %1 = lshr <4 x i32> %x, <i32 1, i32 2, i32 3, i32 4>
17 %2 = shl <4 x i32> %x, <i32 31, i32 30, i32 29, i32 28>
18 %3 = or <4 x i32> %1, %2
19 %4 = lshr <4 x i32> %3, <i32 12, i32 13, i32 14, i32 15>
20 %5 = shl <4 x i32> %3, <i32 20, i32 19, i32 18, i32 17>
21 %6 = or <4 x i32> %4, %5
22 ret <4 x i32> %6
23}
24
25define <4 x i32> @combine_vec_rot_rot_splat(<4 x i32> %x) {
26; XOP-LABEL: combine_vec_rot_rot_splat:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000027; XOP: # %bb.0:
Andrew Zhogin45d19282017-07-05 17:55:42 +000028; XOP-NEXT: vprotd $7, %xmm0, %xmm0
Simon Pilgrimd1282222017-07-04 12:33:53 +000029; XOP-NEXT: retq
30;
31; AVX512-LABEL: combine_vec_rot_rot_splat:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000032; AVX512: # %bb.0:
Simon Pilgrim1cbe8c22017-07-17 14:11:30 +000033; AVX512-NEXT: vprold $7, %xmm0, %xmm0
Simon Pilgrimd1282222017-07-04 12:33:53 +000034; AVX512-NEXT: retq
35 %1 = lshr <4 x i32> %x, <i32 3, i32 3, i32 3, i32 3>
36 %2 = shl <4 x i32> %x, <i32 29, i32 29, i32 29, i32 29>
37 %3 = or <4 x i32> %1, %2
38 %4 = lshr <4 x i32> %3, <i32 22, i32 22, i32 22, i32 22>
39 %5 = shl <4 x i32> %3, <i32 10, i32 10, i32 10, i32 10>
40 %6 = or <4 x i32> %4, %5
41 ret <4 x i32> %6
42}
43
44define <4 x i32> @combine_vec_rot_rot_splat_zero(<4 x i32> %x) {
45; XOP-LABEL: combine_vec_rot_rot_splat_zero:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000046; XOP: # %bb.0:
Simon Pilgrimd1282222017-07-04 12:33:53 +000047; XOP-NEXT: retq
48;
49; AVX512-LABEL: combine_vec_rot_rot_splat_zero:
Francis Visoiu Mistrih25528d62017-12-04 17:18:51 +000050; AVX512: # %bb.0:
Simon Pilgrimd1282222017-07-04 12:33:53 +000051; AVX512-NEXT: retq
52 %1 = lshr <4 x i32> %x, <i32 1, i32 1, i32 1, i32 1>
53 %2 = shl <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
54 %3 = or <4 x i32> %1, %2
55 %4 = lshr <4 x i32> %3, <i32 31, i32 31, i32 31, i32 31>
56 %5 = shl <4 x i32> %3, <i32 1, i32 1, i32 1, i32 1>
57 %6 = or <4 x i32> %4, %5
58 ret <4 x i32> %6
59}