From: Simon Pilgrim Date: Sun, 17 Jul 2016 18:29:19 +0000 (+0000) Subject: [X86] Add CTPOP/CTLZ/CTTZ scalar cost tests X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=47638635cca9376521d732c69c735273ef2c5759;p=platform%2Fupstream%2Fllvm.git [X86] Add CTPOP/CTLZ/CTTZ scalar cost tests llvm-svn: 275725 --- diff --git a/llvm/test/Analysis/CostModel/X86/ctbits-cost.ll b/llvm/test/Analysis/CostModel/X86/ctbits-cost.ll index 82b8bce..23bfafd 100644 --- a/llvm/test/Analysis/CostModel/X86/ctbits-cost.ll +++ b/llvm/test/Analysis/CostModel/X86/ctbits-cost.ll @@ -1,9 +1,48 @@ -; 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 -; 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 -; 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 -; 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 -; 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 -; 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 +; 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=XOP -check-prefix=XOPAVX1 -check-prefix=POPCNT +; 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 -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. @@ -89,6 +128,69 @@ define <32 x i8> @var_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) @@ -245,6 +347,69 @@ define <32 x i8> @var_ctlz_v32i8u(<32 x i8> %a) { 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)