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 4; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=core-avx2 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -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=XOPAVX 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 scalar bitreverse instructions. 9 10declare i64 @llvm.bitreverse.i64(i64) 11declare i32 @llvm.bitreverse.i32(i32) 12declare i16 @llvm.bitreverse.i16(i16) 13declare i8 @llvm.bitreverse.i8(i8) 14 15define i64 @var_bitreverse_i64(i64 %a) { 16; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_i64': 17; SSE2: Found an estimated cost of 1 for instruction: %bitreverse 18; SSE42: Found an estimated cost of 1 for instruction: %bitreverse 19; AVX: Found an estimated cost of 1 for instruction: %bitreverse 20; AVX2: Found an estimated cost of 1 for instruction: %bitreverse 21; XOP: Found an estimated cost of 3 for instruction: %bitreverse 22 %bitreverse = call i64 @llvm.bitreverse.i64(i64 %a) 23 ret i64 %bitreverse 24} 25 26define i32 @var_bitreverse_i32(i32 %a) { 27; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_i32': 28; SSE2: Found an estimated cost of 1 for instruction: %bitreverse 29; SSE42: Found an estimated cost of 1 for instruction: %bitreverse 30; AVX: Found an estimated cost of 1 for instruction: %bitreverse 31; AVX2: Found an estimated cost of 1 for instruction: %bitreverse 32; XOP: Found an estimated cost of 3 for instruction: %bitreverse 33 %bitreverse = call i32 @llvm.bitreverse.i32(i32 %a) 34 ret i32 %bitreverse 35} 36 37define i16 @var_bitreverse_i16(i16 %a) { 38; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_i16': 39; SSE2: Found an estimated cost of 1 for instruction: %bitreverse 40; SSE42: Found an estimated cost of 1 for instruction: %bitreverse 41; AVX: Found an estimated cost of 1 for instruction: %bitreverse 42; AVX2: Found an estimated cost of 1 for instruction: %bitreverse 43; XOP: Found an estimated cost of 3 for instruction: %bitreverse 44 %bitreverse = call i16 @llvm.bitreverse.i16(i16 %a) 45 ret i16 %bitreverse 46} 47 48define i8 @var_bitreverse_i8(i8 %a) { 49; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_i8': 50; SSE2: Found an estimated cost of 1 for instruction: %bitreverse 51; SSE42: Found an estimated cost of 1 for instruction: %bitreverse 52; AVX: Found an estimated cost of 1 for instruction: %bitreverse 53; AVX2: Found an estimated cost of 1 for instruction: %bitreverse 54; XOP: Found an estimated cost of 3 for instruction: %bitreverse 55 %bitreverse = call i8 @llvm.bitreverse.i8(i8 %a) 56 ret i8 %bitreverse 57} 58 59; Verify the cost of vector bitreverse instructions. 60 61declare <2 x i64> @llvm.bitreverse.v2i64(<2 x i64>) 62declare <4 x i32> @llvm.bitreverse.v4i32(<4 x i32>) 63declare <8 x i16> @llvm.bitreverse.v8i16(<8 x i16>) 64declare <16 x i8> @llvm.bitreverse.v16i8(<16 x i8>) 65 66declare <4 x i64> @llvm.bitreverse.v4i64(<4 x i64>) 67declare <8 x i32> @llvm.bitreverse.v8i32(<8 x i32>) 68declare <16 x i16> @llvm.bitreverse.v16i16(<16 x i16>) 69declare <32 x i8> @llvm.bitreverse.v32i8(<32 x i8>) 70 71define <2 x i64> @var_bitreverse_v2i64(<2 x i64> %a) { 72; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v2i64': 73; SSE2: Found an estimated cost of 6 for instruction: %bitreverse 74; SSE42: Found an estimated cost of 5 for instruction: %bitreverse 75; AVX: Found an estimated cost of 5 for instruction: %bitreverse 76; AVX2: Found an estimated cost of 5 for instruction: %bitreverse 77; XOP: Found an estimated cost of 1 for instruction: %bitreverse 78 %bitreverse = call <2 x i64> @llvm.bitreverse.v2i64(<2 x i64> %a) 79 ret <2 x i64> %bitreverse 80} 81 82define <4 x i64> @var_bitreverse_v4i64(<4 x i64> %a) { 83; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v4i64': 84; SSE2: Found an estimated cost of 12 for instruction: %bitreverse 85; SSE42: Found an estimated cost of 10 for instruction: %bitreverse 86; AVX: Found an estimated cost of 10 for instruction: %bitreverse 87; AVX2: Found an estimated cost of 5 for instruction: %bitreverse 88; XOP: Found an estimated cost of 4 for instruction: %bitreverse 89 %bitreverse = call <4 x i64> @llvm.bitreverse.v4i64(<4 x i64> %a) 90 ret <4 x i64> %bitreverse 91} 92 93define <4 x i32> @var_bitreverse_v4i32(<4 x i32> %a) { 94; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v4i32': 95; SSE2: Found an estimated cost of 12 for instruction: %bitreverse 96; SSE42: Found an estimated cost of 5 for instruction: %bitreverse 97; AVX: Found an estimated cost of 5 for instruction: %bitreverse 98; AVX2: Found an estimated cost of 5 for instruction: %bitreverse 99; XOP: Found an estimated cost of 1 for instruction: %bitreverse 100 %bitreverse = call <4 x i32> @llvm.bitreverse.v4i32(<4 x i32> %a) 101 ret <4 x i32> %bitreverse 102} 103 104define <8 x i32> @var_bitreverse_v8i32(<8 x i32> %a) { 105; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v8i32': 106; SSE2: Found an estimated cost of 24 for instruction: %bitreverse 107; SSE42: Found an estimated cost of 10 for instruction: %bitreverse 108; AVX: Found an estimated cost of 10 for instruction: %bitreverse 109; AVX2: Found an estimated cost of 5 for instruction: %bitreverse 110; XOP: Found an estimated cost of 4 for instruction: %bitreverse 111 %bitreverse = call <8 x i32> @llvm.bitreverse.v8i32(<8 x i32> %a) 112 ret <8 x i32> %bitreverse 113} 114 115define <8 x i16> @var_bitreverse_v8i16(<8 x i16> %a) { 116; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v8i16': 117; SSE2: Found an estimated cost of 24 for instruction: %bitreverse 118; SSE42: Found an estimated cost of 5 for instruction: %bitreverse 119; AVX: Found an estimated cost of 5 for instruction: %bitreverse 120; AVX2: Found an estimated cost of 5 for instruction: %bitreverse 121; XOP: Found an estimated cost of 1 for instruction: %bitreverse 122 %bitreverse = call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> %a) 123 ret <8 x i16> %bitreverse 124} 125 126define <16 x i16> @var_bitreverse_v16i16(<16 x i16> %a) { 127; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v16i16': 128; SSE2: Found an estimated cost of 48 for instruction: %bitreverse 129; SSE42: Found an estimated cost of 10 for instruction: %bitreverse 130; AVX: Found an estimated cost of 10 for instruction: %bitreverse 131; AVX2: Found an estimated cost of 5 for instruction: %bitreverse 132; XOP: Found an estimated cost of 4 for instruction: %bitreverse 133 %bitreverse = call <16 x i16> @llvm.bitreverse.v16i16(<16 x i16> %a) 134 ret <16 x i16> %bitreverse 135} 136 137define <16 x i8> @var_bitreverse_v16i8(<16 x i8> %a) { 138; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v16i8': 139; SSE2: Found an estimated cost of 48 for instruction: %bitreverse 140; SSE42: Found an estimated cost of 5 for instruction: %bitreverse 141; AVX: Found an estimated cost of 5 for instruction: %bitreverse 142; AVX2: Found an estimated cost of 5 for instruction: %bitreverse 143; XOP: Found an estimated cost of 1 for instruction: %bitreverse 144 %bitreverse = call <16 x i8> @llvm.bitreverse.v16i8(<16 x i8> %a) 145 ret <16 x i8> %bitreverse 146} 147 148define <32 x i8> @var_bitreverse_v32i8(<32 x i8> %a) { 149; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v32i8': 150; SSE2: Found an estimated cost of 96 for instruction: %bitreverse 151; SSE42: Found an estimated cost of 10 for instruction: %bitreverse 152; AVX: Found an estimated cost of 10 for instruction: %bitreverse 153; AVX2: Found an estimated cost of 5 for instruction: %bitreverse 154; XOP: Found an estimated cost of 4 for instruction: %bitreverse 155 %bitreverse = call <32 x i8> @llvm.bitreverse.v32i8(<32 x i8> %a) 156 ret <32 x i8> %bitreverse 157} 158