diff options
Diffstat (limited to 'test/Analysis/CostModel')
-rw-r--r-- | test/Analysis/CostModel/SystemZ/div-pow2.ll | 154 | ||||
-rw-r--r-- | test/Analysis/CostModel/X86/bitreverse.ll | 69 | ||||
-rw-r--r-- | test/Analysis/CostModel/X86/ctbits-cost.ll | 587 | ||||
-rw-r--r-- | test/Analysis/CostModel/X86/ctlz.ll | 233 | ||||
-rw-r--r-- | test/Analysis/CostModel/X86/ctpop.ll | 133 | ||||
-rw-r--r-- | test/Analysis/CostModel/X86/cttz.ll | 233 |
6 files changed, 822 insertions, 587 deletions
diff --git a/test/Analysis/CostModel/SystemZ/div-pow2.ll b/test/Analysis/CostModel/SystemZ/div-pow2.ll new file mode 100644 index 0000000000000..9ef2dd71e8fa7 --- /dev/null +++ b/test/Analysis/CostModel/SystemZ/div-pow2.ll @@ -0,0 +1,154 @@ +; RUN: opt < %s -cost-model -analyze -mtriple=systemz-unknown -mcpu=z13 | FileCheck %s + +; Scalar sdiv + +define i64 @fun0(i64 %a) { + %r = sdiv i64 %a, 2 + ret i64 %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i64 %a, 2 +} + +define i64 @fun1(i64 %a) { + %r = sdiv i64 %a, -4 + ret i64 %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i64 %a, -4 +} + +define i32 @fun2(i32 %a) { + %r = sdiv i32 %a, 8 + ret i32 %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i32 %a, 8 +} + +define i32 @fun3(i32 %a) { + %r = sdiv i32 %a, -16 + ret i32 %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i32 %a, -16 +} + +define i16 @fun4(i16 %a) { + %r = sdiv i16 %a, 32 + ret i16 %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i16 %a, 32 +} + +define i16 @fun5(i16 %a) { + %r = sdiv i16 %a, -64 + ret i16 %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i16 %a, -64 +} + +define i8 @fun6(i8 %a) { + %r = sdiv i8 %a, 64 + ret i8 %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i8 %a, 64 +} + +define i8 @fun7(i8 %a) { + %r = sdiv i8 %a, -128 + ret i8 %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i8 %a, -128 +} + + +; Vector sdiv + +define <2 x i64> @fun8(<2 x i64> %a) { + %r = sdiv <2 x i64> %a, <i64 2, i64 2> + ret <2 x i64> %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <2 x i64> %a, <i64 2, i64 2> +} + +define <2 x i64> @fun9(<2 x i64> %a) { + %r = sdiv <2 x i64> %a, <i64 -4, i64 -4> + ret <2 x i64> %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <2 x i64> %a, <i64 -4, i64 -4> +} + +define <4 x i32> @fun10(<4 x i32> %a) { + %r = sdiv <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8> + ret <4 x i32> %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8> +} + +define <4 x i32> @fun11(<4 x i32> %a) { + %r = sdiv <4 x i32> %a, <i32 -16, i32 -16, i32 -16, i32 -16> + ret <4 x i32> %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <4 x i32> %a, <i32 -16 +} + +define <8 x i16> @fun12(<8 x i16> %a) { + %r = sdiv <8 x i16> %a, <i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32> + ret <8 x i16> %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <8 x i16> %a, <i16 32 +} + +define <8 x i16> @fun13(<8 x i16> %a) { + %r = sdiv <8 x i16> %a, <i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64> + ret <8 x i16> %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <8 x i16> %a, <i16 -64 +} + +define <16 x i8> @fun14(<16 x i8> %a) { + %r = sdiv <16 x i8> %a, <i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64> + ret <16 x i8> %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <16 x i8> %a, <i8 64 +} + +define <16 x i8> @fun15(<16 x i8> %a) { + %r = sdiv <16 x i8> %a, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128> + ret <16 x i8> %r +; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <16 x i8> %a, <i8 -128 +} + +; Scalar udiv + +define i64 @fun16(i64 %a) { + %r = udiv i64 %a, 2 + ret i64 %r +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv i64 %a, 2 +} + +define i32 @fun17(i32 %a) { + %r = udiv i32 %a, 8 + ret i32 %r +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv i32 %a, 8 +} + +define i16 @fun18(i16 %a) { + %r = udiv i16 %a, 32 + ret i16 %r +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv i16 %a, 32 +} + +define i8 @fun19(i8 %a) { + %r = udiv i8 %a, 128 + ret i8 %r +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv i8 %a, -128 +} + +; Vector udiv + +define <2 x i64> @fun20(<2 x i64> %a) { + %r = udiv <2 x i64> %a, <i64 2, i64 2> + ret <2 x i64> %r +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <2 x i64> %a, <i64 2 +} + +define <4 x i32> @fun21(<4 x i32> %a) { + %r = udiv <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8> + ret <4 x i32> %r +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <4 x i32> %a, <i32 8 +} + +define <8 x i16> @fun22(<8 x i16> %a) { + %r = udiv <8 x i16> %a, <i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32> + ret <8 x i16> %r +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <8 x i16> %a, <i16 32 +} + +define <16 x i8> @fun23(<16 x i8> %a) { + %r = udiv <16 x i8> %a, <i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128> + ret <16 x i8> %r +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <16 x i8> %a, <i8 -128 +} diff --git a/test/Analysis/CostModel/X86/bitreverse.ll b/test/Analysis/CostModel/X86/bitreverse.ll index 8d5e1421eb829..9321b7323b57f 100644 --- a/test/Analysis/CostModel/X86/bitreverse.ll +++ b/test/Analysis/CostModel/X86/bitreverse.ll @@ -2,10 +2,14 @@ ; RUN: opt < %s -mtriple=i686-unknown-linux-gnu -mcpu=corei7 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=X86 -check-prefix=SSE42 ; RUN: opt < %s -mtriple=i686-unknown-linux-gnu -mcpu=corei7-avx -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=X86 -check-prefix=AVX ; RUN: opt < %s -mtriple=i686-unknown-linux-gnu -mcpu=core-avx2 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=X86 -check-prefix=AVX2 +; RUN: opt < %s -mtriple=i686-unknown-linux-gnu -mcpu=knl -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=X86 -check-prefix=AVX512 -check-prefix=AVX512F +; RUN: opt < %s -mtriple=i686-unknown-linux-gnu -mcpu=skx -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=X86 -check-prefix=AVX512 -check-prefix=AVX512BW ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=pentium4 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=X64 -check-prefix=SSE2 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=X64 -check-prefix=SSE42 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7-avx -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=X64 -check-prefix=AVX ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=core-avx2 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=X64 -check-prefix=AVX2 +; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=knl -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=X64 -check-prefix=AVX512 -check-prefix=AVX512F +; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=skx -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=X64 -check-prefix=AVX512 -check-prefix=AVX512BW ; 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 ; 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 @@ -64,12 +68,18 @@ declare <8 x i32> @llvm.bitreverse.v8i32(<8 x i32>) declare <16 x i16> @llvm.bitreverse.v16i16(<16 x i16>) declare <32 x i8> @llvm.bitreverse.v32i8(<32 x i8>) +declare <8 x i64> @llvm.bitreverse.v8i64(<8 x i64>) +declare <16 x i32> @llvm.bitreverse.v16i32(<16 x i32>) +declare <32 x i16> @llvm.bitreverse.v32i16(<32 x i16>) +declare <64 x i8> @llvm.bitreverse.v64i8(<64 x i8>) + define <2 x i64> @var_bitreverse_v2i64(<2 x i64> %a) { ; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v2i64': ; SSE2: Found an estimated cost of 29 for instruction: %bitreverse ; SSE42: Found an estimated cost of 5 for instruction: %bitreverse ; AVX: Found an estimated cost of 5 for instruction: %bitreverse ; AVX2: Found an estimated cost of 5 for instruction: %bitreverse +; AVX512: Found an estimated cost of 5 for instruction: %bitreverse ; XOP: Found an estimated cost of 1 for instruction: %bitreverse %bitreverse = call <2 x i64> @llvm.bitreverse.v2i64(<2 x i64> %a) ret <2 x i64> %bitreverse @@ -81,17 +91,32 @@ define <4 x i64> @var_bitreverse_v4i64(<4 x i64> %a) { ; SSE42: Found an estimated cost of 10 for instruction: %bitreverse ; AVX: Found an estimated cost of 12 for instruction: %bitreverse ; AVX2: Found an estimated cost of 5 for instruction: %bitreverse +; AVX512: Found an estimated cost of 5 for instruction: %bitreverse ; XOP: Found an estimated cost of 4 for instruction: %bitreverse %bitreverse = call <4 x i64> @llvm.bitreverse.v4i64(<4 x i64> %a) ret <4 x i64> %bitreverse } +define <8 x i64> @var_bitreverse_v8i64(<8 x i64> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v8i64': +; SSE2: Found an estimated cost of 116 for instruction: %bitreverse +; SSE42: Found an estimated cost of 20 for instruction: %bitreverse +; AVX: Found an estimated cost of 24 for instruction: %bitreverse +; AVX2: Found an estimated cost of 10 for instruction: %bitreverse +; AVX512F: Found an estimated cost of 36 for instruction: %bitreverse +; AVX512BW: Found an estimated cost of 5 for instruction: %bitreverse +; XOP: Found an estimated cost of 8 for instruction: %bitreverse + %bitreverse = call <8 x i64> @llvm.bitreverse.v8i64(<8 x i64> %a) + ret <8 x i64> %bitreverse +} + define <4 x i32> @var_bitreverse_v4i32(<4 x i32> %a) { ; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v4i32': ; SSE2: Found an estimated cost of 27 for instruction: %bitreverse ; SSE42: Found an estimated cost of 5 for instruction: %bitreverse ; AVX: Found an estimated cost of 5 for instruction: %bitreverse ; AVX2: Found an estimated cost of 5 for instruction: %bitreverse +; AVX512: Found an estimated cost of 5 for instruction: %bitreverse ; XOP: Found an estimated cost of 1 for instruction: %bitreverse %bitreverse = call <4 x i32> @llvm.bitreverse.v4i32(<4 x i32> %a) ret <4 x i32> %bitreverse @@ -103,17 +128,32 @@ define <8 x i32> @var_bitreverse_v8i32(<8 x i32> %a) { ; SSE42: Found an estimated cost of 10 for instruction: %bitreverse ; AVX: Found an estimated cost of 12 for instruction: %bitreverse ; AVX2: Found an estimated cost of 5 for instruction: %bitreverse +; AVX512: Found an estimated cost of 5 for instruction: %bitreverse ; XOP: Found an estimated cost of 4 for instruction: %bitreverse %bitreverse = call <8 x i32> @llvm.bitreverse.v8i32(<8 x i32> %a) ret <8 x i32> %bitreverse } +define <16 x i32> @var_bitreverse_v16i32(<16 x i32> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v16i32': +; SSE2: Found an estimated cost of 108 for instruction: %bitreverse +; SSE42: Found an estimated cost of 20 for instruction: %bitreverse +; AVX: Found an estimated cost of 24 for instruction: %bitreverse +; AVX2: Found an estimated cost of 10 for instruction: %bitreverse +; AVX512F: Found an estimated cost of 24 for instruction: %bitreverse +; AVX512BW: Found an estimated cost of 5 for instruction: %bitreverse +; XOP: Found an estimated cost of 8 for instruction: %bitreverse + %bitreverse = call <16 x i32> @llvm.bitreverse.v16i32(<16 x i32> %a) + ret <16 x i32> %bitreverse +} + define <8 x i16> @var_bitreverse_v8i16(<8 x i16> %a) { ; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v8i16': ; SSE2: Found an estimated cost of 27 for instruction: %bitreverse ; SSE42: Found an estimated cost of 5 for instruction: %bitreverse ; AVX: Found an estimated cost of 5 for instruction: %bitreverse ; AVX2: Found an estimated cost of 5 for instruction: %bitreverse +; AVX512: Found an estimated cost of 5 for instruction: %bitreverse ; XOP: Found an estimated cost of 1 for instruction: %bitreverse %bitreverse = call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> %a) ret <8 x i16> %bitreverse @@ -125,17 +165,32 @@ define <16 x i16> @var_bitreverse_v16i16(<16 x i16> %a) { ; SSE42: Found an estimated cost of 10 for instruction: %bitreverse ; AVX: Found an estimated cost of 12 for instruction: %bitreverse ; AVX2: Found an estimated cost of 5 for instruction: %bitreverse +; AVX512: Found an estimated cost of 5 for instruction: %bitreverse ; XOP: Found an estimated cost of 4 for instruction: %bitreverse %bitreverse = call <16 x i16> @llvm.bitreverse.v16i16(<16 x i16> %a) ret <16 x i16> %bitreverse } +define <32 x i16> @var_bitreverse_v32i16(<32 x i16> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v32i16': +; SSE2: Found an estimated cost of 108 for instruction: %bitreverse +; SSE42: Found an estimated cost of 20 for instruction: %bitreverse +; AVX: Found an estimated cost of 24 for instruction: %bitreverse +; AVX2: Found an estimated cost of 10 for instruction: %bitreverse +; AVX512F: Found an estimated cost of 10 for instruction: %bitreverse +; AVX512BW: Found an estimated cost of 5 for instruction: %bitreverse +; XOP: Found an estimated cost of 8 for instruction: %bitreverse + %bitreverse = call <32 x i16> @llvm.bitreverse.v32i16(<32 x i16> %a) + ret <32 x i16> %bitreverse +} + define <16 x i8> @var_bitreverse_v16i8(<16 x i8> %a) { ; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v16i8': ; SSE2: Found an estimated cost of 20 for instruction: %bitreverse ; SSE42: Found an estimated cost of 5 for instruction: %bitreverse ; AVX: Found an estimated cost of 5 for instruction: %bitreverse ; AVX2: Found an estimated cost of 5 for instruction: %bitreverse +; AVX512: Found an estimated cost of 5 for instruction: %bitreverse ; XOP: Found an estimated cost of 1 for instruction: %bitreverse %bitreverse = call <16 x i8> @llvm.bitreverse.v16i8(<16 x i8> %a) ret <16 x i8> %bitreverse @@ -147,7 +202,21 @@ define <32 x i8> @var_bitreverse_v32i8(<32 x i8> %a) { ; SSE42: Found an estimated cost of 10 for instruction: %bitreverse ; AVX: Found an estimated cost of 12 for instruction: %bitreverse ; AVX2: Found an estimated cost of 5 for instruction: %bitreverse +; AVX512: Found an estimated cost of 5 for instruction: %bitreverse ; XOP: Found an estimated cost of 4 for instruction: %bitreverse %bitreverse = call <32 x i8> @llvm.bitreverse.v32i8(<32 x i8> %a) ret <32 x i8> %bitreverse } + +define <64 x i8> @var_bitreverse_v64i8(<64 x i8> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_bitreverse_v64i8': +; SSE2: Found an estimated cost of 80 for instruction: %bitreverse +; SSE42: Found an estimated cost of 20 for instruction: %bitreverse +; AVX: Found an estimated cost of 24 for instruction: %bitreverse +; AVX2: Found an estimated cost of 10 for instruction: %bitreverse +; AVX512F: Found an estimated cost of 10 for instruction: %bitreverse +; AVX512BW: Found an estimated cost of 5 for instruction: %bitreverse +; XOP: Found an estimated cost of 8 for instruction: %bitreverse + %bitreverse = call <64 x i8> @llvm.bitreverse.v64i8(<64 x i8> %a) + ret <64 x i8> %bitreverse +} diff --git a/test/Analysis/CostModel/X86/ctbits-cost.ll b/test/Analysis/CostModel/X86/ctbits-cost.ll deleted file mode 100644 index aaf092c7b1d75..0000000000000 --- a/test/Analysis/CostModel/X86/ctbits-cost.ll +++ /dev/null @@ -1,587 +0,0 @@ -; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=pentium4 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=SSE -check-prefix=SSE2 -check-prefix=NOPOPCNT -; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=SSE -check-prefix=SSE42 -check-prefix=POPCNT -; 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 -check-prefix=POPCNT -; 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 -check-prefix=POPCNT -; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver2 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX1 -check-prefix=POPCNT -; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver4 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX2 -check-prefix=POPCNT - -; Verify the cost of scalar population count instructions. - -declare i64 @llvm.ctpop.i64(i64) -declare i32 @llvm.ctpop.i32(i32) -declare i16 @llvm.ctpop.i16(i16) -declare i8 @llvm.ctpop.i8(i8) - -define i64 @var_ctpop_i64(i64 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctpop_i64': -; NOPOPCNT: Found an estimated cost of 4 for instruction: %ctpop -; POPCNT: Found an estimated cost of 1 for instruction: %ctpop - %ctpop = call i64 @llvm.ctpop.i64(i64 %a) - ret i64 %ctpop -} - -define i32 @var_ctpop_i32(i32 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctpop_i32': -; NOPOPCNT: Found an estimated cost of 4 for instruction: %ctpop -; POPCNT: Found an estimated cost of 1 for instruction: %ctpop - %ctpop = call i32 @llvm.ctpop.i32(i32 %a) - ret i32 %ctpop -} - -define i16 @var_ctpop_i16(i16 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctpop_i16': -; NOPOPCNT: Found an estimated cost of 4 for instruction: %ctpop -; POPCNT: Found an estimated cost of 1 for instruction: %ctpop - %ctpop = call i16 @llvm.ctpop.i16(i16 %a) - ret i16 %ctpop -} - -define i8 @var_ctpop_i8(i8 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctpop_i8': -; NOPOPCNT: Found an estimated cost of 4 for instruction: %ctpop -; POPCNT: Found an estimated cost of 1 for instruction: %ctpop - %ctpop = call i8 @llvm.ctpop.i8(i8 %a) - ret i8 %ctpop -} - -; Verify the cost of vector population count instructions. - -declare <2 x i64> @llvm.ctpop.v2i64(<2 x i64>) -declare <4 x i32> @llvm.ctpop.v4i32(<4 x i32>) -declare <8 x i16> @llvm.ctpop.v8i16(<8 x i16>) -declare <16 x i8> @llvm.ctpop.v16i8(<16 x i8>) - -declare <4 x i64> @llvm.ctpop.v4i64(<4 x i64>) -declare <8 x i32> @llvm.ctpop.v8i32(<8 x i32>) -declare <16 x i16> @llvm.ctpop.v16i16(<16 x i16>) -declare <32 x i8> @llvm.ctpop.v32i8(<32 x i8>) - -define <2 x i64> @var_ctpop_v2i64(<2 x i64> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v2i64': -; SSE2: Found an estimated cost of 12 for instruction: %ctpop -; SSE42: Found an estimated cost of 7 for instruction: %ctpop -; AVX: Found an estimated cost of 7 for instruction: %ctpop - %ctpop = call <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %a) - ret <2 x i64> %ctpop -} - -define <4 x i64> @var_ctpop_v4i64(<4 x i64> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v4i64': -; SSE2: Found an estimated cost of 24 for instruction: %ctpop -; SSE42: Found an estimated cost of 14 for instruction: %ctpop -; AVX1: Found an estimated cost of 16 for instruction: %ctpop -; AVX2: Found an estimated cost of 7 for instruction: %ctpop - %ctpop = call <4 x i64> @llvm.ctpop.v4i64(<4 x i64> %a) - ret <4 x i64> %ctpop -} - -define <4 x i32> @var_ctpop_v4i32(<4 x i32> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v4i32': -; SSE2: Found an estimated cost of 15 for instruction: %ctpop -; SSE42: Found an estimated cost of 11 for instruction: %ctpop -; AVX: Found an estimated cost of 11 for instruction: %ctpop - %ctpop = call <4 x i32> @llvm.ctpop.v4i32(<4 x i32> %a) - ret <4 x i32> %ctpop -} - -define <8 x i32> @var_ctpop_v8i32(<8 x i32> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v8i32': -; SSE2: Found an estimated cost of 30 for instruction: %ctpop -; SSE42: Found an estimated cost of 22 for instruction: %ctpop -; AVX1: Found an estimated cost of 24 for instruction: %ctpop -; AVX2: Found an estimated cost of 11 for instruction: %ctpop - %ctpop = call <8 x i32> @llvm.ctpop.v8i32(<8 x i32> %a) - ret <8 x i32> %ctpop -} - -define <8 x i16> @var_ctpop_v8i16(<8 x i16> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v8i16': -; SSE2: Found an estimated cost of 13 for instruction: %ctpop -; SSE42: Found an estimated cost of 9 for instruction: %ctpop -; AVX: Found an estimated cost of 9 for instruction: %ctpop - %ctpop = call <8 x i16> @llvm.ctpop.v8i16(<8 x i16> %a) - ret <8 x i16> %ctpop -} - -define <16 x i16> @var_ctpop_v16i16(<16 x i16> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v16i16': -; SSE2: Found an estimated cost of 26 for instruction: %ctpop -; SSE42: Found an estimated cost of 18 for instruction: %ctpop -; AVX1: Found an estimated cost of 20 for instruction: %ctpop -; AVX2: Found an estimated cost of 9 for instruction: %ctpop - %ctpop = call <16 x i16> @llvm.ctpop.v16i16(<16 x i16> %a) - ret <16 x i16> %ctpop -} - -define <16 x i8> @var_ctpop_v16i8(<16 x i8> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v16i8': -; SSE2: Found an estimated cost of 10 for instruction: %ctpop -; SSE42: Found an estimated cost of 6 for instruction: %ctpop -; AVX: Found an estimated cost of 6 for instruction: %ctpop - %ctpop = call <16 x i8> @llvm.ctpop.v16i8(<16 x i8> %a) - ret <16 x i8> %ctpop -} - -define <32 x i8> @var_ctpop_v32i8(<32 x i8> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v32i8': -; SSE2: Found an estimated cost of 20 for instruction: %ctpop -; SSE42: Found an estimated cost of 12 for instruction: %ctpop -; AVX1: Found an estimated cost of 14 for instruction: %ctpop -; AVX2: Found an estimated cost of 6 for instruction: %ctpop - %ctpop = call <32 x i8> @llvm.ctpop.v32i8(<32 x i8> %a) - ret <32 x i8> %ctpop -} - -; Verify the cost of scalar leading zero count instructions. - -declare i64 @llvm.ctlz.i64(i64, i1) -declare i32 @llvm.ctlz.i32(i32, i1) -declare i16 @llvm.ctlz.i16(i16, i1) -declare i8 @llvm.ctlz.i8(i8, i1) - -define i64 @var_ctlz_i64(i64 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i64': -; CHECK: Found an estimated cost of 1 for instruction: %ctlz - %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 0) - ret i64 %ctlz -} - -define i64 @var_ctlz_i64u(i64 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i64u': -; CHECK: Found an estimated cost of 1 for instruction: %ctlz - %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 1) - ret i64 %ctlz -} - -define i32 @var_ctlz_i32(i32 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i32': -; CHECK: Found an estimated cost of 1 for instruction: %ctlz - %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 0) - ret i32 %ctlz -} - -define i32 @var_ctlz_i32u(i32 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i32u': -; CHECK: Found an estimated cost of 1 for instruction: %ctlz - %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 1) - ret i32 %ctlz -} - -define i16 @var_ctlz_i16(i16 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i16': -; CHECK: Found an estimated cost of 1 for instruction: %ctlz - %ctlz = call i16 @llvm.ctlz.i16(i16 %a, i1 0) - ret i16 %ctlz -} - -define i16 @var_ctlz_i16u(i16 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i16u': -; CHECK: Found an estimated cost of 1 for instruction: %ctlz - %ctlz = call i16 @llvm.ctlz.i16(i16 %a, i1 1) - ret i16 %ctlz -} - -define i8 @var_ctlz_i8(i8 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i8': -; CHECK: Found an estimated cost of 1 for instruction: %ctlz - %ctlz = call i8 @llvm.ctlz.i8(i8 %a, i1 0) - ret i8 %ctlz -} - -define i8 @var_ctlz_i8u(i8 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i8u': -; CHECK: Found an estimated cost of 1 for instruction: %ctlz - %ctlz = call i8 @llvm.ctlz.i8(i8 %a, i1 1) - ret i8 %ctlz -} - -; Verify the cost of vector leading zero count instructions. - -declare <2 x i64> @llvm.ctlz.v2i64(<2 x i64>, i1) -declare <4 x i32> @llvm.ctlz.v4i32(<4 x i32>, i1) -declare <8 x i16> @llvm.ctlz.v8i16(<8 x i16>, i1) -declare <16 x i8> @llvm.ctlz.v16i8(<16 x i8>, i1) - -declare <4 x i64> @llvm.ctlz.v4i64(<4 x i64>, i1) -declare <8 x i32> @llvm.ctlz.v8i32(<8 x i32>, i1) -declare <16 x i16> @llvm.ctlz.v16i16(<16 x i16>, i1) -declare <32 x i8> @llvm.ctlz.v32i8(<32 x i8>, i1) - -define <2 x i64> @var_ctlz_v2i64(<2 x i64> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v2i64': -; SSE2: Found an estimated cost of 25 for instruction: %ctlz -; SSE42: Found an estimated cost of 23 for instruction: %ctlz -; AVX: Found an estimated cost of 23 for instruction: %ctlz - %ctlz = call <2 x i64> @llvm.ctlz.v2i64(<2 x i64> %a, i1 0) - ret <2 x i64> %ctlz -} - -define <2 x i64> @var_ctlz_v2i64u(<2 x i64> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v2i64u': -; SSE2: Found an estimated cost of 25 for instruction: %ctlz -; SSE42: Found an estimated cost of 23 for instruction: %ctlz -; AVX: Found an estimated cost of 23 for instruction: %ctlz - %ctlz = call <2 x i64> @llvm.ctlz.v2i64(<2 x i64> %a, i1 1) - ret <2 x i64> %ctlz -} - -define <4 x i64> @var_ctlz_v4i64(<4 x i64> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v4i64': -; SSE2: Found an estimated cost of 50 for instruction: %ctlz -; SSE42: Found an estimated cost of 46 for instruction: %ctlz -; AVX1: Found an estimated cost of 48 for instruction: %ctlz -; AVX2: Found an estimated cost of 23 for instruction: %ctlz - %ctlz = call <4 x i64> @llvm.ctlz.v4i64(<4 x i64> %a, i1 0) - ret <4 x i64> %ctlz -} - -define <4 x i64> @var_ctlz_v4i64u(<4 x i64> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v4i64u': -; SSE2: Found an estimated cost of 50 for instruction: %ctlz -; SSE42: Found an estimated cost of 46 for instruction: %ctlz -; AVX1: Found an estimated cost of 48 for instruction: %ctlz -; AVX2: Found an estimated cost of 23 for instruction: %ctlz - %ctlz = call <4 x i64> @llvm.ctlz.v4i64(<4 x i64> %a, i1 1) - ret <4 x i64> %ctlz -} - -define <4 x i32> @var_ctlz_v4i32(<4 x i32> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v4i32': -; SSE2: Found an estimated cost of 26 for instruction: %ctlz -; SSE42: Found an estimated cost of 18 for instruction: %ctlz -; AVX: Found an estimated cost of 18 for instruction: %ctlz - %ctlz = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %a, i1 0) - ret <4 x i32> %ctlz -} - -define <4 x i32> @var_ctlz_v4i32u(<4 x i32> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v4i32u': -; SSE2: Found an estimated cost of 26 for instruction: %ctlz -; SSE42: Found an estimated cost of 18 for instruction: %ctlz -; AVX: Found an estimated cost of 18 for instruction: %ctlz - %ctlz = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %a, i1 1) - ret <4 x i32> %ctlz -} - -define <8 x i32> @var_ctlz_v8i32(<8 x i32> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v8i32': -; SSE2: Found an estimated cost of 52 for instruction: %ctlz -; SSE42: Found an estimated cost of 36 for instruction: %ctlz -; AVX1: Found an estimated cost of 38 for instruction: %ctlz -; AVX2: Found an estimated cost of 18 for instruction: %ctlz - %ctlz = call <8 x i32> @llvm.ctlz.v8i32(<8 x i32> %a, i1 0) - ret <8 x i32> %ctlz -} - -define <8 x i32> @var_ctlz_v8i32u(<8 x i32> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v8i32u': -; SSE2: Found an estimated cost of 52 for instruction: %ctlz -; SSE42: Found an estimated cost of 36 for instruction: %ctlz -; AVX1: Found an estimated cost of 38 for instruction: %ctlz -; AVX2: Found an estimated cost of 18 for instruction: %ctlz - %ctlz = call <8 x i32> @llvm.ctlz.v8i32(<8 x i32> %a, i1 1) - ret <8 x i32> %ctlz -} - -define <8 x i16> @var_ctlz_v8i16(<8 x i16> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v8i16': -; SSE2: Found an estimated cost of 20 for instruction: %ctlz -; SSE42: Found an estimated cost of 14 for instruction: %ctlz -; AVX: Found an estimated cost of 14 for instruction: %ctlz - %ctlz = call <8 x i16> @llvm.ctlz.v8i16(<8 x i16> %a, i1 0) - ret <8 x i16> %ctlz -} - -define <8 x i16> @var_ctlz_v8i16u(<8 x i16> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v8i16u': -; SSE2: Found an estimated cost of 20 for instruction: %ctlz -; SSE42: Found an estimated cost of 14 for instruction: %ctlz -; AVX: Found an estimated cost of 14 for instruction: %ctlz - %ctlz = call <8 x i16> @llvm.ctlz.v8i16(<8 x i16> %a, i1 1) - ret <8 x i16> %ctlz -} - -define <16 x i16> @var_ctlz_v16i16(<16 x i16> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v16i16': -; SSE2: Found an estimated cost of 40 for instruction: %ctlz -; SSE42: Found an estimated cost of 28 for instruction: %ctlz -; AVX1: Found an estimated cost of 30 for instruction: %ctlz -; AVX2: Found an estimated cost of 14 for instruction: %ctlz - %ctlz = call <16 x i16> @llvm.ctlz.v16i16(<16 x i16> %a, i1 0) - ret <16 x i16> %ctlz -} - -define <16 x i16> @var_ctlz_v16i16u(<16 x i16> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v16i16u': -; SSE2: Found an estimated cost of 40 for instruction: %ctlz -; SSE42: Found an estimated cost of 28 for instruction: %ctlz -; AVX1: Found an estimated cost of 30 for instruction: %ctlz -; AVX2: Found an estimated cost of 14 for instruction: %ctlz - %ctlz = call <16 x i16> @llvm.ctlz.v16i16(<16 x i16> %a, i1 1) - ret <16 x i16> %ctlz -} - -define <16 x i8> @var_ctlz_v16i8(<16 x i8> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v16i8': -; SSE2: Found an estimated cost of 17 for instruction: %ctlz -; SSE42: Found an estimated cost of 9 for instruction: %ctlz -; AVX: Found an estimated cost of 9 for instruction: %ctlz - %ctlz = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> %a, i1 0) - ret <16 x i8> %ctlz -} - -define <16 x i8> @var_ctlz_v16i8u(<16 x i8> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v16i8u': -; SSE2: Found an estimated cost of 17 for instruction: %ctlz -; SSE42: Found an estimated cost of 9 for instruction: %ctlz -; AVX: Found an estimated cost of 9 for instruction: %ctlz - %ctlz = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> %a, i1 1) - ret <16 x i8> %ctlz -} - -define <32 x i8> @var_ctlz_v32i8(<32 x i8> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v32i8': -; SSE2: Found an estimated cost of 34 for instruction: %ctlz -; SSE42: Found an estimated cost of 18 for instruction: %ctlz -; AVX1: Found an estimated cost of 20 for instruction: %ctlz -; AVX2: Found an estimated cost of 9 for instruction: %ctlz - %ctlz = call <32 x i8> @llvm.ctlz.v32i8(<32 x i8> %a, i1 0) - ret <32 x i8> %ctlz -} - -define <32 x i8> @var_ctlz_v32i8u(<32 x i8> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v32i8u': -; SSE2: Found an estimated cost of 34 for instruction: %ctlz -; SSE42: Found an estimated cost of 18 for instruction: %ctlz -; AVX1: Found an estimated cost of 20 for instruction: %ctlz -; AVX2: Found an estimated cost of 9 for instruction: %ctlz - %ctlz = call <32 x i8> @llvm.ctlz.v32i8(<32 x i8> %a, i1 1) - ret <32 x i8> %ctlz -} - -; Verify the cost of scalar trailing zero count instructions. - -declare i64 @llvm.cttz.i64(i64, i1) -declare i32 @llvm.cttz.i32(i32, i1) -declare i16 @llvm.cttz.i16(i16, i1) -declare i8 @llvm.cttz.i8(i8, i1) - -define i64 @var_cttz_i64(i64 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_i64': -; CHECK: Found an estimated cost of 1 for instruction: %cttz - %cttz = call i64 @llvm.cttz.i64(i64 %a, i1 0) - ret i64 %cttz -} - -define i64 @var_cttz_i64u(i64 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_i64u': -; CHECK: Found an estimated cost of 1 for instruction: %cttz - %cttz = call i64 @llvm.cttz.i64(i64 %a, i1 1) - ret i64 %cttz -} - -define i32 @var_cttz_i32(i32 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_i32': -; CHECK: Found an estimated cost of 1 for instruction: %cttz - %cttz = call i32 @llvm.cttz.i32(i32 %a, i1 0) - ret i32 %cttz -} - -define i32 @var_cttz_i32u(i32 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_i32u': -; CHECK: Found an estimated cost of 1 for instruction: %cttz - %cttz = call i32 @llvm.cttz.i32(i32 %a, i1 1) - ret i32 %cttz -} - -define i16 @var_cttz_i16(i16 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_i16': -; CHECK: Found an estimated cost of 1 for instruction: %cttz - %cttz = call i16 @llvm.cttz.i16(i16 %a, i1 0) - ret i16 %cttz -} - -define i16 @var_cttz_i16u(i16 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_i16u': -; CHECK: Found an estimated cost of 1 for instruction: %cttz - %cttz = call i16 @llvm.cttz.i16(i16 %a, i1 1) - ret i16 %cttz -} - -define i8 @var_cttz_i8(i8 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_i8': -; CHECK: Found an estimated cost of 1 for instruction: %cttz - %cttz = call i8 @llvm.cttz.i8(i8 %a, i1 0) - ret i8 %cttz -} - -define i8 @var_cttz_i8u(i8 %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_i8u': -; CHECK: Found an estimated cost of 1 for instruction: %cttz - %cttz = call i8 @llvm.cttz.i8(i8 %a, i1 1) - ret i8 %cttz -} - -; Verify the cost of vector trailing zero count instructions. - -declare <2 x i64> @llvm.cttz.v2i64(<2 x i64>, i1) -declare <4 x i32> @llvm.cttz.v4i32(<4 x i32>, i1) -declare <8 x i16> @llvm.cttz.v8i16(<8 x i16>, i1) -declare <16 x i8> @llvm.cttz.v16i8(<16 x i8>, i1) - -declare <4 x i64> @llvm.cttz.v4i64(<4 x i64>, i1) -declare <8 x i32> @llvm.cttz.v8i32(<8 x i32>, i1) -declare <16 x i16> @llvm.cttz.v16i16(<16 x i16>, i1) -declare <32 x i8> @llvm.cttz.v32i8(<32 x i8>, i1) - -define <2 x i64> @var_cttz_v2i64(<2 x i64> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v2i64': -; SSE2: Found an estimated cost of 14 for instruction: %cttz -; SSE42: Found an estimated cost of 10 for instruction: %cttz -; AVX: Found an estimated cost of 10 for instruction: %cttz - %cttz = call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %a, i1 0) - ret <2 x i64> %cttz -} - -define <2 x i64> @var_cttz_v2i64u(<2 x i64> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v2i64u': -; SSE2: Found an estimated cost of 14 for instruction: %cttz -; SSE42: Found an estimated cost of 10 for instruction: %cttz -; AVX: Found an estimated cost of 10 for instruction: %cttz - %cttz = call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %a, i1 1) - ret <2 x i64> %cttz -} - -define <4 x i64> @var_cttz_v4i64(<4 x i64> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v4i64': -; SSE2: Found an estimated cost of 28 for instruction: %cttz -; SSE42: Found an estimated cost of 20 for instruction: %cttz -; AVX1: Found an estimated cost of 22 for instruction: %cttz -; AVX2: Found an estimated cost of 10 for instruction: %cttz - %cttz = call <4 x i64> @llvm.cttz.v4i64(<4 x i64> %a, i1 0) - ret <4 x i64> %cttz -} - -define <4 x i64> @var_cttz_v4i64u(<4 x i64> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v4i64u': -; SSE2: Found an estimated cost of 28 for instruction: %cttz -; SSE42: Found an estimated cost of 20 for instruction: %cttz -; AVX1: Found an estimated cost of 22 for instruction: %cttz -; AVX2: Found an estimated cost of 10 for instruction: %cttz - %cttz = call <4 x i64> @llvm.cttz.v4i64(<4 x i64> %a, i1 1) - ret <4 x i64> %cttz -} - -define <4 x i32> @var_cttz_v4i32(<4 x i32> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v4i32': -; SSE2: Found an estimated cost of 18 for instruction: %cttz -; SSE42: Found an estimated cost of 14 for instruction: %cttz -; AVX: Found an estimated cost of 14 for instruction: %cttz - %cttz = call <4 x i32> @llvm.cttz.v4i32(<4 x i32> %a, i1 0) - ret <4 x i32> %cttz -} - -define <4 x i32> @var_cttz_v4i32u(<4 x i32> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v4i32u': -; SSE2: Found an estimated cost of 18 for instruction: %cttz -; SSE42: Found an estimated cost of 14 for instruction: %cttz -; AVX: Found an estimated cost of 14 for instruction: %cttz - %cttz = call <4 x i32> @llvm.cttz.v4i32(<4 x i32> %a, i1 1) - ret <4 x i32> %cttz -} - -define <8 x i32> @var_cttz_v8i32(<8 x i32> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v8i32': -; SSE2: Found an estimated cost of 36 for instruction: %cttz -; SSE42: Found an estimated cost of 28 for instruction: %cttz -; AVX1: Found an estimated cost of 30 for instruction: %cttz -; AVX2: Found an estimated cost of 14 for instruction: %cttz - %cttz = call <8 x i32> @llvm.cttz.v8i32(<8 x i32> %a, i1 0) - ret <8 x i32> %cttz -} - -define <8 x i32> @var_cttz_v8i32u(<8 x i32> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v8i32u': -; SSE2: Found an estimated cost of 36 for instruction: %cttz -; SSE42: Found an estimated cost of 28 for instruction: %cttz -; AVX1: Found an estimated cost of 30 for instruction: %cttz -; AVX2: Found an estimated cost of 14 for instruction: %cttz - %cttz = call <8 x i32> @llvm.cttz.v8i32(<8 x i32> %a, i1 1) - ret <8 x i32> %cttz -} - -define <8 x i16> @var_cttz_v8i16(<8 x i16> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v8i16': -; SSE2: Found an estimated cost of 16 for instruction: %cttz -; SSE42: Found an estimated cost of 12 for instruction: %cttz -; AVX: Found an estimated cost of 12 for instruction: %cttz - %cttz = call <8 x i16> @llvm.cttz.v8i16(<8 x i16> %a, i1 0) - ret <8 x i16> %cttz -} - -define <8 x i16> @var_cttz_v8i16u(<8 x i16> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v8i16u': -; SSE2: Found an estimated cost of 16 for instruction: %cttz -; SSE42: Found an estimated cost of 12 for instruction: %cttz -; AVX: Found an estimated cost of 12 for instruction: %cttz - %cttz = call <8 x i16> @llvm.cttz.v8i16(<8 x i16> %a, i1 1) - ret <8 x i16> %cttz -} - -define <16 x i16> @var_cttz_v16i16(<16 x i16> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v16i16': -; SSE2: Found an estimated cost of 32 for instruction: %cttz -; SSE42: Found an estimated cost of 24 for instruction: %cttz -; AVX1: Found an estimated cost of 26 for instruction: %cttz -; AVX2: Found an estimated cost of 12 for instruction: %cttz - %cttz = call <16 x i16> @llvm.cttz.v16i16(<16 x i16> %a, i1 0) - ret <16 x i16> %cttz -} - -define <16 x i16> @var_cttz_v16i16u(<16 x i16> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v16i16u': -; SSE2: Found an estimated cost of 32 for instruction: %cttz -; SSE42: Found an estimated cost of 24 for instruction: %cttz -; AVX1: Found an estimated cost of 26 for instruction: %cttz -; AVX2: Found an estimated cost of 12 for instruction: %cttz - %cttz = call <16 x i16> @llvm.cttz.v16i16(<16 x i16> %a, i1 1) - ret <16 x i16> %cttz -} - -define <16 x i8> @var_cttz_v16i8(<16 x i8> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v16i8': -; SSE2: Found an estimated cost of 13 for instruction: %cttz -; SSE42: Found an estimated cost of 9 for instruction: %cttz -; AVX: Found an estimated cost of 9 for instruction: %cttz - %cttz = call <16 x i8> @llvm.cttz.v16i8(<16 x i8> %a, i1 0) - ret <16 x i8> %cttz -} - -define <16 x i8> @var_cttz_v16i8u(<16 x i8> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v16i8u': -; SSE2: Found an estimated cost of 13 for instruction: %cttz -; SSE42: Found an estimated cost of 9 for instruction: %cttz -; AVX: Found an estimated cost of 9 for instruction: %cttz - %cttz = call <16 x i8> @llvm.cttz.v16i8(<16 x i8> %a, i1 1) - ret <16 x i8> %cttz -} - -define <32 x i8> @var_cttz_v32i8(<32 x i8> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v32i8': -; SSE2: Found an estimated cost of 26 for instruction: %cttz -; SSE42: Found an estimated cost of 18 for instruction: %cttz -; AVX1: Found an estimated cost of 20 for instruction: %cttz -; AVX2: Found an estimated cost of 9 for instruction: %cttz - %cttz = call <32 x i8> @llvm.cttz.v32i8(<32 x i8> %a, i1 0) - ret <32 x i8> %cttz -} - -define <32 x i8> @var_cttz_v32i8u(<32 x i8> %a) { -; CHECK: 'Cost Model Analysis' for function 'var_cttz_v32i8u': -; SSE2: Found an estimated cost of 26 for instruction: %cttz -; SSE42: Found an estimated cost of 18 for instruction: %cttz -; AVX1: Found an estimated cost of 20 for instruction: %cttz -; AVX2: Found an estimated cost of 9 for instruction: %cttz - %cttz = call <32 x i8> @llvm.cttz.v32i8(<32 x i8> %a, i1 1) - ret <32 x i8> %cttz -} diff --git a/test/Analysis/CostModel/X86/ctlz.ll b/test/Analysis/CostModel/X86/ctlz.ll new file mode 100644 index 0000000000000..2c97da15aee5b --- /dev/null +++ b/test/Analysis/CostModel/X86/ctlz.ll @@ -0,0 +1,233 @@ +; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=pentium4 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=SSE -check-prefix=SSE2 -check-prefix=NOPOPCNT +; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=SSE -check-prefix=SSE42 -check-prefix=POPCNT +; 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 -check-prefix=POPCNT +; 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 -check-prefix=POPCNT +; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver2 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX1 -check-prefix=POPCNT +; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver4 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX2 -check-prefix=POPCNT + +; Verify the cost of scalar leading zero count instructions. + +declare i64 @llvm.ctlz.i64(i64, i1) +declare i32 @llvm.ctlz.i32(i32, i1) +declare i16 @llvm.ctlz.i16(i16, i1) +declare i8 @llvm.ctlz.i8(i8, i1) + +define i64 @var_ctlz_i64(i64 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i64': +; CHECK: Found an estimated cost of 1 for instruction: %ctlz + %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 0) + ret i64 %ctlz +} + +define i64 @var_ctlz_i64u(i64 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i64u': +; CHECK: Found an estimated cost of 1 for instruction: %ctlz + %ctlz = call i64 @llvm.ctlz.i64(i64 %a, i1 1) + ret i64 %ctlz +} + +define i32 @var_ctlz_i32(i32 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i32': +; CHECK: Found an estimated cost of 1 for instruction: %ctlz + %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 0) + ret i32 %ctlz +} + +define i32 @var_ctlz_i32u(i32 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i32u': +; CHECK: Found an estimated cost of 1 for instruction: %ctlz + %ctlz = call i32 @llvm.ctlz.i32(i32 %a, i1 1) + ret i32 %ctlz +} + +define i16 @var_ctlz_i16(i16 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i16': +; CHECK: Found an estimated cost of 1 for instruction: %ctlz + %ctlz = call i16 @llvm.ctlz.i16(i16 %a, i1 0) + ret i16 %ctlz +} + +define i16 @var_ctlz_i16u(i16 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i16u': +; CHECK: Found an estimated cost of 1 for instruction: %ctlz + %ctlz = call i16 @llvm.ctlz.i16(i16 %a, i1 1) + ret i16 %ctlz +} + +define i8 @var_ctlz_i8(i8 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i8': +; CHECK: Found an estimated cost of 1 for instruction: %ctlz + %ctlz = call i8 @llvm.ctlz.i8(i8 %a, i1 0) + ret i8 %ctlz +} + +define i8 @var_ctlz_i8u(i8 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_i8u': +; CHECK: Found an estimated cost of 1 for instruction: %ctlz + %ctlz = call i8 @llvm.ctlz.i8(i8 %a, i1 1) + ret i8 %ctlz +} + +; Verify the cost of vector leading zero count instructions. + +declare <2 x i64> @llvm.ctlz.v2i64(<2 x i64>, i1) +declare <4 x i32> @llvm.ctlz.v4i32(<4 x i32>, i1) +declare <8 x i16> @llvm.ctlz.v8i16(<8 x i16>, i1) +declare <16 x i8> @llvm.ctlz.v16i8(<16 x i8>, i1) + +declare <4 x i64> @llvm.ctlz.v4i64(<4 x i64>, i1) +declare <8 x i32> @llvm.ctlz.v8i32(<8 x i32>, i1) +declare <16 x i16> @llvm.ctlz.v16i16(<16 x i16>, i1) +declare <32 x i8> @llvm.ctlz.v32i8(<32 x i8>, i1) + +define <2 x i64> @var_ctlz_v2i64(<2 x i64> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v2i64': +; SSE2: Found an estimated cost of 25 for instruction: %ctlz +; SSE42: Found an estimated cost of 23 for instruction: %ctlz +; AVX: Found an estimated cost of 23 for instruction: %ctlz + %ctlz = call <2 x i64> @llvm.ctlz.v2i64(<2 x i64> %a, i1 0) + ret <2 x i64> %ctlz +} + +define <2 x i64> @var_ctlz_v2i64u(<2 x i64> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v2i64u': +; SSE2: Found an estimated cost of 25 for instruction: %ctlz +; SSE42: Found an estimated cost of 23 for instruction: %ctlz +; AVX: Found an estimated cost of 23 for instruction: %ctlz + %ctlz = call <2 x i64> @llvm.ctlz.v2i64(<2 x i64> %a, i1 1) + ret <2 x i64> %ctlz +} + +define <4 x i64> @var_ctlz_v4i64(<4 x i64> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v4i64': +; SSE2: Found an estimated cost of 50 for instruction: %ctlz +; SSE42: Found an estimated cost of 46 for instruction: %ctlz +; AVX1: Found an estimated cost of 48 for instruction: %ctlz +; AVX2: Found an estimated cost of 23 for instruction: %ctlz + %ctlz = call <4 x i64> @llvm.ctlz.v4i64(<4 x i64> %a, i1 0) + ret <4 x i64> %ctlz +} + +define <4 x i64> @var_ctlz_v4i64u(<4 x i64> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v4i64u': +; SSE2: Found an estimated cost of 50 for instruction: %ctlz +; SSE42: Found an estimated cost of 46 for instruction: %ctlz +; AVX1: Found an estimated cost of 48 for instruction: %ctlz +; AVX2: Found an estimated cost of 23 for instruction: %ctlz + %ctlz = call <4 x i64> @llvm.ctlz.v4i64(<4 x i64> %a, i1 1) + ret <4 x i64> %ctlz +} + +define <4 x i32> @var_ctlz_v4i32(<4 x i32> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v4i32': +; SSE2: Found an estimated cost of 26 for instruction: %ctlz +; SSE42: Found an estimated cost of 18 for instruction: %ctlz +; AVX: Found an estimated cost of 18 for instruction: %ctlz + %ctlz = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %a, i1 0) + ret <4 x i32> %ctlz +} + +define <4 x i32> @var_ctlz_v4i32u(<4 x i32> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v4i32u': +; SSE2: Found an estimated cost of 26 for instruction: %ctlz +; SSE42: Found an estimated cost of 18 for instruction: %ctlz +; AVX: Found an estimated cost of 18 for instruction: %ctlz + %ctlz = call <4 x i32> @llvm.ctlz.v4i32(<4 x i32> %a, i1 1) + ret <4 x i32> %ctlz +} + +define <8 x i32> @var_ctlz_v8i32(<8 x i32> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v8i32': +; SSE2: Found an estimated cost of 52 for instruction: %ctlz +; SSE42: Found an estimated cost of 36 for instruction: %ctlz +; AVX1: Found an estimated cost of 38 for instruction: %ctlz +; AVX2: Found an estimated cost of 18 for instruction: %ctlz + %ctlz = call <8 x i32> @llvm.ctlz.v8i32(<8 x i32> %a, i1 0) + ret <8 x i32> %ctlz +} + +define <8 x i32> @var_ctlz_v8i32u(<8 x i32> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v8i32u': +; SSE2: Found an estimated cost of 52 for instruction: %ctlz +; SSE42: Found an estimated cost of 36 for instruction: %ctlz +; AVX1: Found an estimated cost of 38 for instruction: %ctlz +; AVX2: Found an estimated cost of 18 for instruction: %ctlz + %ctlz = call <8 x i32> @llvm.ctlz.v8i32(<8 x i32> %a, i1 1) + ret <8 x i32> %ctlz +} + +define <8 x i16> @var_ctlz_v8i16(<8 x i16> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v8i16': +; SSE2: Found an estimated cost of 20 for instruction: %ctlz +; SSE42: Found an estimated cost of 14 for instruction: %ctlz +; AVX: Found an estimated cost of 14 for instruction: %ctlz + %ctlz = call <8 x i16> @llvm.ctlz.v8i16(<8 x i16> %a, i1 0) + ret <8 x i16> %ctlz +} + +define <8 x i16> @var_ctlz_v8i16u(<8 x i16> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v8i16u': +; SSE2: Found an estimated cost of 20 for instruction: %ctlz +; SSE42: Found an estimated cost of 14 for instruction: %ctlz +; AVX: Found an estimated cost of 14 for instruction: %ctlz + %ctlz = call <8 x i16> @llvm.ctlz.v8i16(<8 x i16> %a, i1 1) + ret <8 x i16> %ctlz +} + +define <16 x i16> @var_ctlz_v16i16(<16 x i16> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v16i16': +; SSE2: Found an estimated cost of 40 for instruction: %ctlz +; SSE42: Found an estimated cost of 28 for instruction: %ctlz +; AVX1: Found an estimated cost of 30 for instruction: %ctlz +; AVX2: Found an estimated cost of 14 for instruction: %ctlz + %ctlz = call <16 x i16> @llvm.ctlz.v16i16(<16 x i16> %a, i1 0) + ret <16 x i16> %ctlz +} + +define <16 x i16> @var_ctlz_v16i16u(<16 x i16> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v16i16u': +; SSE2: Found an estimated cost of 40 for instruction: %ctlz +; SSE42: Found an estimated cost of 28 for instruction: %ctlz +; AVX1: Found an estimated cost of 30 for instruction: %ctlz +; AVX2: Found an estimated cost of 14 for instruction: %ctlz + %ctlz = call <16 x i16> @llvm.ctlz.v16i16(<16 x i16> %a, i1 1) + ret <16 x i16> %ctlz +} + +define <16 x i8> @var_ctlz_v16i8(<16 x i8> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v16i8': +; SSE2: Found an estimated cost of 17 for instruction: %ctlz +; SSE42: Found an estimated cost of 9 for instruction: %ctlz +; AVX: Found an estimated cost of 9 for instruction: %ctlz + %ctlz = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> %a, i1 0) + ret <16 x i8> %ctlz +} + +define <16 x i8> @var_ctlz_v16i8u(<16 x i8> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v16i8u': +; SSE2: Found an estimated cost of 17 for instruction: %ctlz +; SSE42: Found an estimated cost of 9 for instruction: %ctlz +; AVX: Found an estimated cost of 9 for instruction: %ctlz + %ctlz = call <16 x i8> @llvm.ctlz.v16i8(<16 x i8> %a, i1 1) + ret <16 x i8> %ctlz +} + +define <32 x i8> @var_ctlz_v32i8(<32 x i8> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v32i8': +; SSE2: Found an estimated cost of 34 for instruction: %ctlz +; SSE42: Found an estimated cost of 18 for instruction: %ctlz +; AVX1: Found an estimated cost of 20 for instruction: %ctlz +; AVX2: Found an estimated cost of 9 for instruction: %ctlz + %ctlz = call <32 x i8> @llvm.ctlz.v32i8(<32 x i8> %a, i1 0) + ret <32 x i8> %ctlz +} + +define <32 x i8> @var_ctlz_v32i8u(<32 x i8> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctlz_v32i8u': +; SSE2: Found an estimated cost of 34 for instruction: %ctlz +; SSE42: Found an estimated cost of 18 for instruction: %ctlz +; AVX1: Found an estimated cost of 20 for instruction: %ctlz +; AVX2: Found an estimated cost of 9 for instruction: %ctlz + %ctlz = call <32 x i8> @llvm.ctlz.v32i8(<32 x i8> %a, i1 1) + ret <32 x i8> %ctlz +} diff --git a/test/Analysis/CostModel/X86/ctpop.ll b/test/Analysis/CostModel/X86/ctpop.ll new file mode 100644 index 0000000000000..f072cbaec4926 --- /dev/null +++ b/test/Analysis/CostModel/X86/ctpop.ll @@ -0,0 +1,133 @@ +; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=pentium4 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=SSE -check-prefix=SSE2 -check-prefix=NOPOPCNT +; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=SSE -check-prefix=SSE42 -check-prefix=POPCNT +; 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 -check-prefix=POPCNT +; 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 -check-prefix=POPCNT +; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver2 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX1 -check-prefix=POPCNT +; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver4 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX2 -check-prefix=POPCNT + +; Verify the cost of scalar population count instructions. + +declare i64 @llvm.ctpop.i64(i64) +declare i32 @llvm.ctpop.i32(i32) +declare i16 @llvm.ctpop.i16(i16) +declare i8 @llvm.ctpop.i8(i8) + +define i64 @var_ctpop_i64(i64 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctpop_i64': +; NOPOPCNT: Found an estimated cost of 4 for instruction: %ctpop +; POPCNT: Found an estimated cost of 1 for instruction: %ctpop + %ctpop = call i64 @llvm.ctpop.i64(i64 %a) + ret i64 %ctpop +} + +define i32 @var_ctpop_i32(i32 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctpop_i32': +; NOPOPCNT: Found an estimated cost of 4 for instruction: %ctpop +; POPCNT: Found an estimated cost of 1 for instruction: %ctpop + %ctpop = call i32 @llvm.ctpop.i32(i32 %a) + ret i32 %ctpop +} + +define i16 @var_ctpop_i16(i16 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctpop_i16': +; NOPOPCNT: Found an estimated cost of 4 for instruction: %ctpop +; POPCNT: Found an estimated cost of 1 for instruction: %ctpop + %ctpop = call i16 @llvm.ctpop.i16(i16 %a) + ret i16 %ctpop +} + +define i8 @var_ctpop_i8(i8 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctpop_i8': +; NOPOPCNT: Found an estimated cost of 4 for instruction: %ctpop +; POPCNT: Found an estimated cost of 1 for instruction: %ctpop + %ctpop = call i8 @llvm.ctpop.i8(i8 %a) + ret i8 %ctpop +} + +; Verify the cost of vector population count instructions. + +declare <2 x i64> @llvm.ctpop.v2i64(<2 x i64>) +declare <4 x i32> @llvm.ctpop.v4i32(<4 x i32>) +declare <8 x i16> @llvm.ctpop.v8i16(<8 x i16>) +declare <16 x i8> @llvm.ctpop.v16i8(<16 x i8>) + +declare <4 x i64> @llvm.ctpop.v4i64(<4 x i64>) +declare <8 x i32> @llvm.ctpop.v8i32(<8 x i32>) +declare <16 x i16> @llvm.ctpop.v16i16(<16 x i16>) +declare <32 x i8> @llvm.ctpop.v32i8(<32 x i8>) + +define <2 x i64> @var_ctpop_v2i64(<2 x i64> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v2i64': +; SSE2: Found an estimated cost of 12 for instruction: %ctpop +; SSE42: Found an estimated cost of 7 for instruction: %ctpop +; AVX: Found an estimated cost of 7 for instruction: %ctpop + %ctpop = call <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %a) + ret <2 x i64> %ctpop +} + +define <4 x i64> @var_ctpop_v4i64(<4 x i64> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v4i64': +; SSE2: Found an estimated cost of 24 for instruction: %ctpop +; SSE42: Found an estimated cost of 14 for instruction: %ctpop +; AVX1: Found an estimated cost of 16 for instruction: %ctpop +; AVX2: Found an estimated cost of 7 for instruction: %ctpop + %ctpop = call <4 x i64> @llvm.ctpop.v4i64(<4 x i64> %a) + ret <4 x i64> %ctpop +} + +define <4 x i32> @var_ctpop_v4i32(<4 x i32> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v4i32': +; SSE2: Found an estimated cost of 15 for instruction: %ctpop +; SSE42: Found an estimated cost of 11 for instruction: %ctpop +; AVX: Found an estimated cost of 11 for instruction: %ctpop + %ctpop = call <4 x i32> @llvm.ctpop.v4i32(<4 x i32> %a) + ret <4 x i32> %ctpop +} + +define <8 x i32> @var_ctpop_v8i32(<8 x i32> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v8i32': +; SSE2: Found an estimated cost of 30 for instruction: %ctpop +; SSE42: Found an estimated cost of 22 for instruction: %ctpop +; AVX1: Found an estimated cost of 24 for instruction: %ctpop +; AVX2: Found an estimated cost of 11 for instruction: %ctpop + %ctpop = call <8 x i32> @llvm.ctpop.v8i32(<8 x i32> %a) + ret <8 x i32> %ctpop +} + +define <8 x i16> @var_ctpop_v8i16(<8 x i16> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v8i16': +; SSE2: Found an estimated cost of 13 for instruction: %ctpop +; SSE42: Found an estimated cost of 9 for instruction: %ctpop +; AVX: Found an estimated cost of 9 for instruction: %ctpop + %ctpop = call <8 x i16> @llvm.ctpop.v8i16(<8 x i16> %a) + ret <8 x i16> %ctpop +} + +define <16 x i16> @var_ctpop_v16i16(<16 x i16> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v16i16': +; SSE2: Found an estimated cost of 26 for instruction: %ctpop +; SSE42: Found an estimated cost of 18 for instruction: %ctpop +; AVX1: Found an estimated cost of 20 for instruction: %ctpop +; AVX2: Found an estimated cost of 9 for instruction: %ctpop + %ctpop = call <16 x i16> @llvm.ctpop.v16i16(<16 x i16> %a) + ret <16 x i16> %ctpop +} + +define <16 x i8> @var_ctpop_v16i8(<16 x i8> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v16i8': +; SSE2: Found an estimated cost of 10 for instruction: %ctpop +; SSE42: Found an estimated cost of 6 for instruction: %ctpop +; AVX: Found an estimated cost of 6 for instruction: %ctpop + %ctpop = call <16 x i8> @llvm.ctpop.v16i8(<16 x i8> %a) + ret <16 x i8> %ctpop +} + +define <32 x i8> @var_ctpop_v32i8(<32 x i8> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v32i8': +; SSE2: Found an estimated cost of 20 for instruction: %ctpop +; SSE42: Found an estimated cost of 12 for instruction: %ctpop +; AVX1: Found an estimated cost of 14 for instruction: %ctpop +; AVX2: Found an estimated cost of 6 for instruction: %ctpop + %ctpop = call <32 x i8> @llvm.ctpop.v32i8(<32 x i8> %a) + ret <32 x i8> %ctpop +} diff --git a/test/Analysis/CostModel/X86/cttz.ll b/test/Analysis/CostModel/X86/cttz.ll new file mode 100644 index 0000000000000..5d3c59b602320 --- /dev/null +++ b/test/Analysis/CostModel/X86/cttz.ll @@ -0,0 +1,233 @@ +; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=pentium4 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=SSE -check-prefix=SSE2 -check-prefix=NOPOPCNT +; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=SSE -check-prefix=SSE42 -check-prefix=POPCNT +; 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 -check-prefix=POPCNT +; 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 -check-prefix=POPCNT +; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver2 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX1 -check-prefix=POPCNT +; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver4 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX2 -check-prefix=POPCNT + +; Verify the cost of scalar trailing zero count instructions. + +declare i64 @llvm.cttz.i64(i64, i1) +declare i32 @llvm.cttz.i32(i32, i1) +declare i16 @llvm.cttz.i16(i16, i1) +declare i8 @llvm.cttz.i8(i8, i1) + +define i64 @var_cttz_i64(i64 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_i64': +; CHECK: Found an estimated cost of 1 for instruction: %cttz + %cttz = call i64 @llvm.cttz.i64(i64 %a, i1 0) + ret i64 %cttz +} + +define i64 @var_cttz_i64u(i64 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_i64u': +; CHECK: Found an estimated cost of 1 for instruction: %cttz + %cttz = call i64 @llvm.cttz.i64(i64 %a, i1 1) + ret i64 %cttz +} + +define i32 @var_cttz_i32(i32 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_i32': +; CHECK: Found an estimated cost of 1 for instruction: %cttz + %cttz = call i32 @llvm.cttz.i32(i32 %a, i1 0) + ret i32 %cttz +} + +define i32 @var_cttz_i32u(i32 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_i32u': +; CHECK: Found an estimated cost of 1 for instruction: %cttz + %cttz = call i32 @llvm.cttz.i32(i32 %a, i1 1) + ret i32 %cttz +} + +define i16 @var_cttz_i16(i16 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_i16': +; CHECK: Found an estimated cost of 1 for instruction: %cttz + %cttz = call i16 @llvm.cttz.i16(i16 %a, i1 0) + ret i16 %cttz +} + +define i16 @var_cttz_i16u(i16 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_i16u': +; CHECK: Found an estimated cost of 1 for instruction: %cttz + %cttz = call i16 @llvm.cttz.i16(i16 %a, i1 1) + ret i16 %cttz +} + +define i8 @var_cttz_i8(i8 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_i8': +; CHECK: Found an estimated cost of 1 for instruction: %cttz + %cttz = call i8 @llvm.cttz.i8(i8 %a, i1 0) + ret i8 %cttz +} + +define i8 @var_cttz_i8u(i8 %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_i8u': +; CHECK: Found an estimated cost of 1 for instruction: %cttz + %cttz = call i8 @llvm.cttz.i8(i8 %a, i1 1) + ret i8 %cttz +} + +; Verify the cost of vector trailing zero count instructions. + +declare <2 x i64> @llvm.cttz.v2i64(<2 x i64>, i1) +declare <4 x i32> @llvm.cttz.v4i32(<4 x i32>, i1) +declare <8 x i16> @llvm.cttz.v8i16(<8 x i16>, i1) +declare <16 x i8> @llvm.cttz.v16i8(<16 x i8>, i1) + +declare <4 x i64> @llvm.cttz.v4i64(<4 x i64>, i1) +declare <8 x i32> @llvm.cttz.v8i32(<8 x i32>, i1) +declare <16 x i16> @llvm.cttz.v16i16(<16 x i16>, i1) +declare <32 x i8> @llvm.cttz.v32i8(<32 x i8>, i1) + +define <2 x i64> @var_cttz_v2i64(<2 x i64> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v2i64': +; SSE2: Found an estimated cost of 14 for instruction: %cttz +; SSE42: Found an estimated cost of 10 for instruction: %cttz +; AVX: Found an estimated cost of 10 for instruction: %cttz + %cttz = call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %a, i1 0) + ret <2 x i64> %cttz +} + +define <2 x i64> @var_cttz_v2i64u(<2 x i64> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v2i64u': +; SSE2: Found an estimated cost of 14 for instruction: %cttz +; SSE42: Found an estimated cost of 10 for instruction: %cttz +; AVX: Found an estimated cost of 10 for instruction: %cttz + %cttz = call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %a, i1 1) + ret <2 x i64> %cttz +} + +define <4 x i64> @var_cttz_v4i64(<4 x i64> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v4i64': +; SSE2: Found an estimated cost of 28 for instruction: %cttz +; SSE42: Found an estimated cost of 20 for instruction: %cttz +; AVX1: Found an estimated cost of 22 for instruction: %cttz +; AVX2: Found an estimated cost of 10 for instruction: %cttz + %cttz = call <4 x i64> @llvm.cttz.v4i64(<4 x i64> %a, i1 0) + ret <4 x i64> %cttz +} + +define <4 x i64> @var_cttz_v4i64u(<4 x i64> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v4i64u': +; SSE2: Found an estimated cost of 28 for instruction: %cttz +; SSE42: Found an estimated cost of 20 for instruction: %cttz +; AVX1: Found an estimated cost of 22 for instruction: %cttz +; AVX2: Found an estimated cost of 10 for instruction: %cttz + %cttz = call <4 x i64> @llvm.cttz.v4i64(<4 x i64> %a, i1 1) + ret <4 x i64> %cttz +} + +define <4 x i32> @var_cttz_v4i32(<4 x i32> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v4i32': +; SSE2: Found an estimated cost of 18 for instruction: %cttz +; SSE42: Found an estimated cost of 14 for instruction: %cttz +; AVX: Found an estimated cost of 14 for instruction: %cttz + %cttz = call <4 x i32> @llvm.cttz.v4i32(<4 x i32> %a, i1 0) + ret <4 x i32> %cttz +} + +define <4 x i32> @var_cttz_v4i32u(<4 x i32> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v4i32u': +; SSE2: Found an estimated cost of 18 for instruction: %cttz +; SSE42: Found an estimated cost of 14 for instruction: %cttz +; AVX: Found an estimated cost of 14 for instruction: %cttz + %cttz = call <4 x i32> @llvm.cttz.v4i32(<4 x i32> %a, i1 1) + ret <4 x i32> %cttz +} + +define <8 x i32> @var_cttz_v8i32(<8 x i32> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v8i32': +; SSE2: Found an estimated cost of 36 for instruction: %cttz +; SSE42: Found an estimated cost of 28 for instruction: %cttz +; AVX1: Found an estimated cost of 30 for instruction: %cttz +; AVX2: Found an estimated cost of 14 for instruction: %cttz + %cttz = call <8 x i32> @llvm.cttz.v8i32(<8 x i32> %a, i1 0) + ret <8 x i32> %cttz +} + +define <8 x i32> @var_cttz_v8i32u(<8 x i32> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v8i32u': +; SSE2: Found an estimated cost of 36 for instruction: %cttz +; SSE42: Found an estimated cost of 28 for instruction: %cttz +; AVX1: Found an estimated cost of 30 for instruction: %cttz +; AVX2: Found an estimated cost of 14 for instruction: %cttz + %cttz = call <8 x i32> @llvm.cttz.v8i32(<8 x i32> %a, i1 1) + ret <8 x i32> %cttz +} + +define <8 x i16> @var_cttz_v8i16(<8 x i16> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v8i16': +; SSE2: Found an estimated cost of 16 for instruction: %cttz +; SSE42: Found an estimated cost of 12 for instruction: %cttz +; AVX: Found an estimated cost of 12 for instruction: %cttz + %cttz = call <8 x i16> @llvm.cttz.v8i16(<8 x i16> %a, i1 0) + ret <8 x i16> %cttz +} + +define <8 x i16> @var_cttz_v8i16u(<8 x i16> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v8i16u': +; SSE2: Found an estimated cost of 16 for instruction: %cttz +; SSE42: Found an estimated cost of 12 for instruction: %cttz +; AVX: Found an estimated cost of 12 for instruction: %cttz + %cttz = call <8 x i16> @llvm.cttz.v8i16(<8 x i16> %a, i1 1) + ret <8 x i16> %cttz +} + +define <16 x i16> @var_cttz_v16i16(<16 x i16> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v16i16': +; SSE2: Found an estimated cost of 32 for instruction: %cttz +; SSE42: Found an estimated cost of 24 for instruction: %cttz +; AVX1: Found an estimated cost of 26 for instruction: %cttz +; AVX2: Found an estimated cost of 12 for instruction: %cttz + %cttz = call <16 x i16> @llvm.cttz.v16i16(<16 x i16> %a, i1 0) + ret <16 x i16> %cttz +} + +define <16 x i16> @var_cttz_v16i16u(<16 x i16> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v16i16u': +; SSE2: Found an estimated cost of 32 for instruction: %cttz +; SSE42: Found an estimated cost of 24 for instruction: %cttz +; AVX1: Found an estimated cost of 26 for instruction: %cttz +; AVX2: Found an estimated cost of 12 for instruction: %cttz + %cttz = call <16 x i16> @llvm.cttz.v16i16(<16 x i16> %a, i1 1) + ret <16 x i16> %cttz +} + +define <16 x i8> @var_cttz_v16i8(<16 x i8> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v16i8': +; SSE2: Found an estimated cost of 13 for instruction: %cttz +; SSE42: Found an estimated cost of 9 for instruction: %cttz +; AVX: Found an estimated cost of 9 for instruction: %cttz + %cttz = call <16 x i8> @llvm.cttz.v16i8(<16 x i8> %a, i1 0) + ret <16 x i8> %cttz +} + +define <16 x i8> @var_cttz_v16i8u(<16 x i8> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v16i8u': +; SSE2: Found an estimated cost of 13 for instruction: %cttz +; SSE42: Found an estimated cost of 9 for instruction: %cttz +; AVX: Found an estimated cost of 9 for instruction: %cttz + %cttz = call <16 x i8> @llvm.cttz.v16i8(<16 x i8> %a, i1 1) + ret <16 x i8> %cttz +} + +define <32 x i8> @var_cttz_v32i8(<32 x i8> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v32i8': +; SSE2: Found an estimated cost of 26 for instruction: %cttz +; SSE42: Found an estimated cost of 18 for instruction: %cttz +; AVX1: Found an estimated cost of 20 for instruction: %cttz +; AVX2: Found an estimated cost of 9 for instruction: %cttz + %cttz = call <32 x i8> @llvm.cttz.v32i8(<32 x i8> %a, i1 0) + ret <32 x i8> %cttz +} + +define <32 x i8> @var_cttz_v32i8u(<32 x i8> %a) { +; CHECK: 'Cost Model Analysis' for function 'var_cttz_v32i8u': +; SSE2: Found an estimated cost of 26 for instruction: %cttz +; SSE42: Found an estimated cost of 18 for instruction: %cttz +; AVX1: Found an estimated cost of 20 for instruction: %cttz +; AVX2: Found an estimated cost of 9 for instruction: %cttz + %cttz = call <32 x i8> @llvm.cttz.v32i8(<32 x i8> %a, i1 1) + ret <32 x i8> %cttz +} |