• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=pentium4 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=SSE2
2; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=SSE42
3; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7-avx -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX1
4; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=core-avx2 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX2
5; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver2 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=XOP -check-prefix=XOPAVX1
6; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver4 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=XOP -check-prefix=XOPAVX2
7
8; Verify the cost of vector bswap instructions.
9
10declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
11declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>)
12declare <8 x i16> @llvm.bswap.v8i16(<8 x i16>)
13
14declare <4 x i64> @llvm.bswap.v4i64(<4 x i64>)
15declare <8 x i32> @llvm.bswap.v8i32(<8 x i32>)
16declare <16 x i16> @llvm.bswap.v16i16(<16 x i16>)
17
18define <2 x i64> @var_bswap_v2i64(<2 x i64> %a) {
19; CHECK: 'Cost Model Analysis' for function 'var_bswap_v2i64':
20; SSE2: Found an estimated cost of 7 for instruction:   %bswap
21; SSE42: Found an estimated cost of 1 for instruction:   %bswap
22; AVX: Found an estimated cost of 1 for instruction:   %bswap
23; XOP: Found an estimated cost of 1 for instruction:   %bswap
24  %bswap = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %a)
25  ret <2 x i64> %bswap
26}
27
28define <4 x i64> @var_bswap_v4i64(<4 x i64> %a) {
29; CHECK: 'Cost Model Analysis' for function 'var_bswap_v4i64':
30; SSE2: Found an estimated cost of 14 for instruction:   %bswap
31; SSE42: Found an estimated cost of 2 for instruction:   %bswap
32; AVX1: Found an estimated cost of 4 for instruction:   %bswap
33; AVX2: Found an estimated cost of 1 for instruction:   %bswap
34; XOPAVX1: Found an estimated cost of 4 for instruction:   %bswap
35; XOPAVX2: Found an estimated cost of 1 for instruction:   %bswap
36  %bswap = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %a)
37  ret <4 x i64> %bswap
38}
39
40define <4 x i32> @var_bswap_v4i32(<4 x i32> %a) {
41; CHECK: 'Cost Model Analysis' for function 'var_bswap_v4i32':
42; SSE2: Found an estimated cost of 7 for instruction:   %bswap
43; SSE42: Found an estimated cost of 1 for instruction:   %bswap
44; AVX: Found an estimated cost of 1 for instruction:   %bswap
45; XOP: Found an estimated cost of 1 for instruction:   %bswap
46  %bswap = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %a)
47  ret <4 x i32> %bswap
48}
49
50define <8 x i32> @var_bswap_v8i32(<8 x i32> %a) {
51; CHECK: 'Cost Model Analysis' for function 'var_bswap_v8i32':
52; SSE2: Found an estimated cost of 14 for instruction:   %bswap
53; SSE42: Found an estimated cost of 2 for instruction:   %bswap
54; AVX1: Found an estimated cost of 4 for instruction:   %bswap
55; AVX2: Found an estimated cost of 1 for instruction:   %bswap
56; XOPAVX1: Found an estimated cost of 4 for instruction:   %bswap
57; XOPAVX2: Found an estimated cost of 1 for instruction:   %bswap
58  %bswap = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %a)
59  ret <8 x i32> %bswap
60}
61
62define <8 x i16> @var_bswap_v8i16(<8 x i16> %a) {
63; CHECK: 'Cost Model Analysis' for function 'var_bswap_v8i16':
64; SSE2: Found an estimated cost of 7 for instruction:   %bswap
65; SSE42: Found an estimated cost of 1 for instruction:   %bswap
66; AVX: Found an estimated cost of 1 for instruction:   %bswap
67; XOP: Found an estimated cost of 1 for instruction:   %bswap
68  %bswap = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %a)
69  ret <8 x i16> %bswap
70}
71
72define <16 x i16> @var_bswap_v16i16(<16 x i16> %a) {
73; CHECK: 'Cost Model Analysis' for function 'var_bswap_v16i16':
74; SSE2: Found an estimated cost of 14 for instruction:   %bswap
75; SSE42: Found an estimated cost of 2 for instruction:   %bswap
76; AVX1: Found an estimated cost of 4 for instruction:   %bswap
77; AVX2: Found an estimated cost of 1 for instruction:   %bswap
78; XOPAVX1: Found an estimated cost of 4 for instruction:   %bswap
79; XOPAVX2: Found an estimated cost of 1 for instruction:   %bswap
80  %bswap = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %a)
81  ret <16 x i16> %bswap
82}
83