Simon Pilgrim | 420852e | 2016-05-07 16:34:16 +0000 | [diff] [blame] | 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 | |
Simon Pilgrim | 6e9898f | 2016-05-15 17:40:48 +0000 | [diff] [blame^] | 8 | ; Verify the cost of scalar bitreverse instructions. |
| 9 | |
| 10 | declare i64 @llvm.bitreverse.i64(i64) |
| 11 | declare i32 @llvm.bitreverse.i32(i32) |
| 12 | declare i16 @llvm.bitreverse.i16(i16) |
| 13 | declare i8 @llvm.bitreverse.i8(i8) |
| 14 | |
| 15 | define 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 1 for instruction: %bitreverse |
| 22 | %bitreverse = call i64 @llvm.bitreverse.i64(i64 %a) |
| 23 | ret i64 %bitreverse |
| 24 | } |
| 25 | |
| 26 | define 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 1 for instruction: %bitreverse |
| 33 | %bitreverse = call i32 @llvm.bitreverse.i32(i32 %a) |
| 34 | ret i32 %bitreverse |
| 35 | } |
| 36 | |
| 37 | define 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 1 for instruction: %bitreverse |
| 44 | %bitreverse = call i16 @llvm.bitreverse.i16(i16 %a) |
| 45 | ret i16 %bitreverse |
| 46 | } |
| 47 | |
| 48 | define 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 1 for instruction: %bitreverse |
| 55 | %bitreverse = call i8 @llvm.bitreverse.i8(i8 %a) |
| 56 | ret i8 %bitreverse |
| 57 | } |
| 58 | |
Simon Pilgrim | 420852e | 2016-05-07 16:34:16 +0000 | [diff] [blame] | 59 | ; Verify the cost of vector bitreverse instructions. |
| 60 | |
| 61 | declare <2 x i64> @llvm.bitreverse.v2i64(<2 x i64>) |
| 62 | declare <4 x i32> @llvm.bitreverse.v4i32(<4 x i32>) |
| 63 | declare <8 x i16> @llvm.bitreverse.v8i16(<8 x i16>) |
| 64 | declare <16 x i8> @llvm.bitreverse.v16i8(<16 x i8>) |
| 65 | |
| 66 | declare <4 x i64> @llvm.bitreverse.v4i64(<4 x i64>) |
| 67 | declare <8 x i32> @llvm.bitreverse.v8i32(<8 x i32>) |
| 68 | declare <16 x i16> @llvm.bitreverse.v16i16(<16 x i16>) |
| 69 | declare <32 x i8> @llvm.bitreverse.v32i8(<32 x i8>) |
| 70 | |
| 71 | define <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 6 for instruction: %bitreverse |
| 75 | ; AVX: Found an estimated cost of 6 for instruction: %bitreverse |
| 76 | ; AVX2: Found an estimated cost of 6 for instruction: %bitreverse |
| 77 | ; XOP: Found an estimated cost of 6 for instruction: %bitreverse |
| 78 | %bitreverse = call <2 x i64> @llvm.bitreverse.v2i64(<2 x i64> %a) |
| 79 | ret <2 x i64> %bitreverse |
| 80 | } |
| 81 | |
| 82 | define <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 12 for instruction: %bitreverse |
| 86 | ; AVX: Found an estimated cost of 12 for instruction: %bitreverse |
| 87 | ; AVX2: Found an estimated cost of 12 for instruction: %bitreverse |
| 88 | ; XOP: Found an estimated cost of 12 for instruction: %bitreverse |
| 89 | %bitreverse = call <4 x i64> @llvm.bitreverse.v4i64(<4 x i64> %a) |
| 90 | ret <4 x i64> %bitreverse |
| 91 | } |
| 92 | |
| 93 | define <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 12 for instruction: %bitreverse |
| 97 | ; AVX: Found an estimated cost of 12 for instruction: %bitreverse |
| 98 | ; AVX2: Found an estimated cost of 12 for instruction: %bitreverse |
| 99 | ; XOP: Found an estimated cost of 12 for instruction: %bitreverse |
| 100 | %bitreverse = call <4 x i32> @llvm.bitreverse.v4i32(<4 x i32> %a) |
| 101 | ret <4 x i32> %bitreverse |
| 102 | } |
| 103 | |
| 104 | define <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 24 for instruction: %bitreverse |
| 108 | ; AVX: Found an estimated cost of 24 for instruction: %bitreverse |
| 109 | ; AVX2: Found an estimated cost of 24 for instruction: %bitreverse |
| 110 | ; XOP: Found an estimated cost of 24 for instruction: %bitreverse |
| 111 | %bitreverse = call <8 x i32> @llvm.bitreverse.v8i32(<8 x i32> %a) |
| 112 | ret <8 x i32> %bitreverse |
| 113 | } |
| 114 | |
| 115 | define <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 24 for instruction: %bitreverse |
| 119 | ; AVX: Found an estimated cost of 24 for instruction: %bitreverse |
| 120 | ; AVX2: Found an estimated cost of 24 for instruction: %bitreverse |
| 121 | ; XOP: Found an estimated cost of 24 for instruction: %bitreverse |
| 122 | %bitreverse = call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> %a) |
| 123 | ret <8 x i16> %bitreverse |
| 124 | } |
| 125 | |
| 126 | define <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 48 for instruction: %bitreverse |
| 130 | ; AVX: Found an estimated cost of 48 for instruction: %bitreverse |
| 131 | ; AVX2: Found an estimated cost of 48 for instruction: %bitreverse |
| 132 | ; XOP: Found an estimated cost of 48 for instruction: %bitreverse |
| 133 | %bitreverse = call <16 x i16> @llvm.bitreverse.v16i16(<16 x i16> %a) |
| 134 | ret <16 x i16> %bitreverse |
| 135 | } |
| 136 | |
| 137 | define <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 48 for instruction: %bitreverse |
| 141 | ; AVX: Found an estimated cost of 48 for instruction: %bitreverse |
| 142 | ; AVX2: Found an estimated cost of 48 for instruction: %bitreverse |
| 143 | ; XOP: Found an estimated cost of 48 for instruction: %bitreverse |
| 144 | %bitreverse = call <16 x i8> @llvm.bitreverse.v16i8(<16 x i8> %a) |
| 145 | ret <16 x i8> %bitreverse |
| 146 | } |
| 147 | |
| 148 | define <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 96 for instruction: %bitreverse |
| 152 | ; AVX: Found an estimated cost of 96 for instruction: %bitreverse |
| 153 | ; AVX2: Found an estimated cost of 96 for instruction: %bitreverse |
| 154 | ; XOP: Found an estimated cost of 96 for instruction: %bitreverse |
| 155 | %bitreverse = call <32 x i8> @llvm.bitreverse.v32i8(<32 x i8> %a) |
| 156 | ret <32 x i8> %bitreverse |
| 157 | } |