1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[NFC][X86][CostModel] Add tests for byteswap intrinsic

This commit is contained in:
Roman Lebedev 2021-05-05 19:21:22 +03:00
parent 0d572a30c9
commit 202c41a158
4 changed files with 478 additions and 113 deletions

View File

@ -0,0 +1,147 @@
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze | FileCheck %s --check-prefixes=ALL,NOMOVBE,X64
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze -mattr=+movbe | FileCheck %s --check-prefixes=ALL,MOVBE,X64
; RUN: opt < %s -mtriple=i686-unknown-linux-gnu -cost-model -analyze | FileCheck %s --check-prefixes=ALL,NOMOVBE,X86
; RUN: opt < %s -mtriple=i686-unknown-linux-gnu -cost-model -analyze -mattr=+movbe | FileCheck %s --check-prefixes=ALL,MOVBE,X86
declare i16 @llvm.bswap.i16(i16)
declare i32 @llvm.bswap.i32(i32)
declare i64 @llvm.bswap.i64(i64)
declare i128 @llvm.bswap.i128(i128)
define void @var_bswap_store_i16(i16 %a, i16* %dst) {
; NOMOVBE-LABEL: 'var_bswap_store_i16'
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i16 %bswap, i16* %dst, align 1
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
; MOVBE-LABEL: 'var_bswap_store_i16'
; MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
; MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i16 %bswap, i16* %dst, align 1
; MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
%bswap = call i16 @llvm.bswap.i16(i16 %a)
store i16 %bswap, i16* %dst, align 1
ret void
}
define void @var_bswap_store_i16_extrause(i16 %a, i16* %dst) {
; NOMOVBE-LABEL: 'var_bswap_store_i16_extrause'
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i16 %bswap, i16* %dst, align 1
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap2 = shl i16 %bswap, 2
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
; MOVBE-LABEL: 'var_bswap_store_i16_extrause'
; MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
; MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i16 %bswap, i16* %dst, align 1
; MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap2 = shl i16 %bswap, 2
; MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
%bswap = call i16 @llvm.bswap.i16(i16 %a)
store i16 %bswap, i16* %dst, align 1
%bswap2 = shl i16 %bswap, 2 ; incur an extra use to the bswap
ret void
}
define void @var_bswap_store_i32(i32 %a, i32* %dst) {
; ALL-LABEL: 'var_bswap_store_i32'
; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i32 @llvm.bswap.i32(i32 %a)
; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %bswap, i32* %dst, align 1
; ALL-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
%bswap = call i32 @llvm.bswap.i32(i32 %a)
store i32 %bswap, i32* %dst, align 1
ret void
}
define void @var_bswap_store_i32_extrause(i32 %a, i32* %dst) {
; ALL-LABEL: 'var_bswap_store_i32_extrause'
; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i32 @llvm.bswap.i32(i32 %a)
; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %bswap, i32* %dst, align 1
; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap2 = shl i32 %bswap, 2
; ALL-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
%bswap = call i32 @llvm.bswap.i32(i32 %a)
store i32 %bswap, i32* %dst, align 1
%bswap2 = shl i32 %bswap, 2 ; incur an extra use to the bswap
ret void
}
define void @var_bswap_store_i64(i64 %a, i64* %dst) {
; X64-LABEL: 'var_bswap_store_i64'
; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i64 %bswap, i64* %dst, align 1
; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
; X86-LABEL: 'var_bswap_store_i64'
; X86-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
; X86-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i64 %bswap, i64* %dst, align 1
; X86-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
%bswap = call i64 @llvm.bswap.i64(i64 %a)
store i64 %bswap, i64* %dst, align 1
ret void
}
define void @var_bswap_store_i64_extrause(i64 %a, i64* %dst) {
; X64-LABEL: 'var_bswap_store_i64_extrause'
; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i64 %bswap, i64* %dst, align 1
; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap2 = shl i64 %bswap, 2
; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
; X86-LABEL: 'var_bswap_store_i64_extrause'
; X86-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
; X86-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i64 %bswap, i64* %dst, align 1
; X86-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap2 = shl i64 %bswap, 2
; X86-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
%bswap = call i64 @llvm.bswap.i64(i64 %a)
store i64 %bswap, i64* %dst, align 1
%bswap2 = shl i64 %bswap, 2 ; incur an extra use to the bswap
ret void
}
define void @var_bswap_store_i128(i128 %a, i128* %dst) {
; X64-LABEL: 'var_bswap_store_i128'
; X64-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
; X64-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i128 %bswap, i128* %dst, align 1
; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
; X86-LABEL: 'var_bswap_store_i128'
; X86-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
; X86-NEXT: Cost Model: Found an estimated cost of 4 for instruction: store i128 %bswap, i128* %dst, align 1
; X86-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
%bswap = call i128 @llvm.bswap.i128(i128 %a)
store i128 %bswap, i128* %dst, align 1
ret void
}
define void @var_bswap_store_i128_extrause(i128 %a, i128* %dst) {
; X64-LABEL: 'var_bswap_store_i128_extrause'
; X64-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
; X64-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i128 %bswap, i128* %dst, align 1
; X64-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap2 = shl i128 %bswap, 2
; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
; X86-LABEL: 'var_bswap_store_i128_extrause'
; X86-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
; X86-NEXT: Cost Model: Found an estimated cost of 4 for instruction: store i128 %bswap, i128* %dst, align 1
; X86-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap2 = shl i128 %bswap, 2
; X86-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
%bswap = call i128 @llvm.bswap.i128(i128 %a)
store i128 %bswap, i128* %dst, align 1
%bswap2 = shl i128 %bswap, 2 ; incur an extra use to the bswap
ret void
}

View File

@ -0,0 +1,131 @@
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze -mattr=+sse2 | FileCheck %s -check-prefixes=SSE2
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze -mattr=+sse4.2 | FileCheck %s -check-prefixes=SSE42
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze -mattr=+avx | FileCheck %s -check-prefixes=AVX,AVX1
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze -mattr=+avx2 | FileCheck %s -check-prefixes=AVX,AVX2
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze -mattr=+xop,+avx | FileCheck %s -check-prefixes=AVX,AVX1
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze -mattr=+xop,+avx2 | FileCheck %s -check-prefixes=AVX,AVX2
; Verify the cost of vector bswap instructions.
declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>)
declare <8 x i16> @llvm.bswap.v8i16(<8 x i16>)
declare <4 x i64> @llvm.bswap.v4i64(<4 x i64>)
declare <8 x i32> @llvm.bswap.v8i32(<8 x i32>)
declare <16 x i16> @llvm.bswap.v16i16(<16 x i16>)
define <2 x i64> @var_bswap_v2i64(<2 x i64> %a) {
; SSE2-LABEL: 'var_bswap_v2i64'
; SSE2-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %bswap = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %a)
; SSE2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %bswap
;
; SSE42-LABEL: 'var_bswap_v2i64'
; SSE42-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %a)
; SSE42-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %bswap
;
; AVX-LABEL: 'var_bswap_v2i64'
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %a)
; AVX-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %bswap
;
%bswap = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %a)
ret <2 x i64> %bswap
}
define <4 x i64> @var_bswap_v4i64(<4 x i64> %a) {
; SSE2-LABEL: 'var_bswap_v4i64'
; SSE2-NEXT: Cost Model: Found an estimated cost of 14 for instruction: %bswap = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %a)
; SSE2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %bswap
;
; SSE42-LABEL: 'var_bswap_v4i64'
; SSE42-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %a)
; SSE42-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %bswap
;
; AVX1-LABEL: 'var_bswap_v4i64'
; AVX1-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %a)
; AVX1-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %bswap
;
; AVX2-LABEL: 'var_bswap_v4i64'
; AVX2-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %a)
; AVX2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %bswap
;
%bswap = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %a)
ret <4 x i64> %bswap
}
define <4 x i32> @var_bswap_v4i32(<4 x i32> %a) {
; SSE2-LABEL: 'var_bswap_v4i32'
; SSE2-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %bswap = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %a)
; SSE2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %bswap
;
; SSE42-LABEL: 'var_bswap_v4i32'
; SSE42-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %a)
; SSE42-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %bswap
;
; AVX-LABEL: 'var_bswap_v4i32'
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %a)
; AVX-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %bswap
;
%bswap = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %a)
ret <4 x i32> %bswap
}
define <8 x i32> @var_bswap_v8i32(<8 x i32> %a) {
; SSE2-LABEL: 'var_bswap_v8i32'
; SSE2-NEXT: Cost Model: Found an estimated cost of 14 for instruction: %bswap = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %a)
; SSE2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %bswap
;
; SSE42-LABEL: 'var_bswap_v8i32'
; SSE42-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %a)
; SSE42-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %bswap
;
; AVX1-LABEL: 'var_bswap_v8i32'
; AVX1-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %a)
; AVX1-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %bswap
;
; AVX2-LABEL: 'var_bswap_v8i32'
; AVX2-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %a)
; AVX2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %bswap
;
%bswap = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %a)
ret <8 x i32> %bswap
}
define <8 x i16> @var_bswap_v8i16(<8 x i16> %a) {
; SSE2-LABEL: 'var_bswap_v8i16'
; SSE2-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %bswap = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %a)
; SSE2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %bswap
;
; SSE42-LABEL: 'var_bswap_v8i16'
; SSE42-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %a)
; SSE42-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %bswap
;
; AVX-LABEL: 'var_bswap_v8i16'
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %a)
; AVX-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %bswap
;
%bswap = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %a)
ret <8 x i16> %bswap
}
define <16 x i16> @var_bswap_v16i16(<16 x i16> %a) {
; SSE2-LABEL: 'var_bswap_v16i16'
; SSE2-NEXT: Cost Model: Found an estimated cost of 14 for instruction: %bswap = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %a)
; SSE2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i16> %bswap
;
; SSE42-LABEL: 'var_bswap_v16i16'
; SSE42-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %a)
; SSE42-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i16> %bswap
;
; AVX1-LABEL: 'var_bswap_v16i16'
; AVX1-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %a)
; AVX1-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i16> %bswap
;
; AVX2-LABEL: 'var_bswap_v16i16'
; AVX2-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %a)
; AVX2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i16> %bswap
;
%bswap = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %a)
ret <16 x i16> %bswap
}

View File

@ -1,131 +1,60 @@
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze -mattr=+sse2 | FileCheck %s -check-prefixes=SSE2
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze -mattr=+sse4.2 | FileCheck %s -check-prefixes=SSE42
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze -mattr=+avx | FileCheck %s -check-prefixes=AVX,AVX1
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze -mattr=+avx2 | FileCheck %s -check-prefixes=AVX,AVX2
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze -mattr=+xop,+avx | FileCheck %s -check-prefixes=AVX,AVX1
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze -mattr=+xop,+avx2 | FileCheck %s -check-prefixes=AVX,AVX2
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze | FileCheck %s --check-prefixes=ALL,NOMOVBE,X64
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze -mattr=+movbe | FileCheck %s --check-prefixes=ALL,MOVBE,X64
; RUN: opt < %s -mtriple=i686-unknown-linux-gnu -cost-model -analyze | FileCheck %s --check-prefixes=ALL,NOMOVBE,X86
; RUN: opt < %s -mtriple=i686-unknown-linux-gnu -cost-model -analyze -mattr=+movbe | FileCheck %s --check-prefixes=ALL,MOVBE,X86
; Verify the cost of vector bswap instructions.
declare i16 @llvm.bswap.i16(i16)
declare i32 @llvm.bswap.i32(i32)
declare i64 @llvm.bswap.i64(i64)
declare i128 @llvm.bswap.i128(i128)
declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>)
declare <8 x i16> @llvm.bswap.v8i16(<8 x i16>)
; Verify the cost of scalar bswap instructions.
declare <4 x i64> @llvm.bswap.v4i64(<4 x i64>)
declare <8 x i32> @llvm.bswap.v8i32(<8 x i32>)
declare <16 x i16> @llvm.bswap.v16i16(<16 x i16>)
define <2 x i64> @var_bswap_v2i64(<2 x i64> %a) {
; SSE2-LABEL: 'var_bswap_v2i64'
; SSE2-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %bswap = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %a)
; SSE2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %bswap
define i16 @var_bswap_i16(i16 %a) {
; NOMOVBE-LABEL: 'var_bswap_i16'
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %bswap
;
; SSE42-LABEL: 'var_bswap_v2i64'
; SSE42-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %a)
; SSE42-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %bswap
; MOVBE-LABEL: 'var_bswap_i16'
; MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
; MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %bswap
;
; AVX-LABEL: 'var_bswap_v2i64'
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %a)
; AVX-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %bswap
;
%bswap = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %a)
ret <2 x i64> %bswap
%bswap = call i16 @llvm.bswap.i16(i16 %a)
ret i16 %bswap
}
define <4 x i64> @var_bswap_v4i64(<4 x i64> %a) {
; SSE2-LABEL: 'var_bswap_v4i64'
; SSE2-NEXT: Cost Model: Found an estimated cost of 14 for instruction: %bswap = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %a)
; SSE2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %bswap
define i32 @var_bswap_i32(i32 %a) {
; ALL-LABEL: 'var_bswap_i32'
; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i32 @llvm.bswap.i32(i32 %a)
; ALL-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %bswap
;
; SSE42-LABEL: 'var_bswap_v4i64'
; SSE42-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %a)
; SSE42-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %bswap
;
; AVX1-LABEL: 'var_bswap_v4i64'
; AVX1-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %a)
; AVX1-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %bswap
;
; AVX2-LABEL: 'var_bswap_v4i64'
; AVX2-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %a)
; AVX2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %bswap
;
%bswap = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %a)
ret <4 x i64> %bswap
%bswap = call i32 @llvm.bswap.i32(i32 %a)
ret i32 %bswap
}
define <4 x i32> @var_bswap_v4i32(<4 x i32> %a) {
; SSE2-LABEL: 'var_bswap_v4i32'
; SSE2-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %bswap = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %a)
; SSE2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %bswap
define i64 @var_bswap_i64(i64 %a) {
; X64-LABEL: 'var_bswap_i64'
; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %bswap
;
; SSE42-LABEL: 'var_bswap_v4i32'
; SSE42-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %a)
; SSE42-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %bswap
; X86-LABEL: 'var_bswap_i64'
; X86-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
; X86-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %bswap
;
; AVX-LABEL: 'var_bswap_v4i32'
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %a)
; AVX-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %bswap
;
%bswap = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %a)
ret <4 x i32> %bswap
%bswap = call i64 @llvm.bswap.i64(i64 %a)
ret i64 %bswap
}
define <8 x i32> @var_bswap_v8i32(<8 x i32> %a) {
; SSE2-LABEL: 'var_bswap_v8i32'
; SSE2-NEXT: Cost Model: Found an estimated cost of 14 for instruction: %bswap = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %a)
; SSE2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %bswap
define i128 @var_bswap_i128(i128 %a) {
; X64-LABEL: 'var_bswap_i128'
; X64-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i128 %bswap
;
; SSE42-LABEL: 'var_bswap_v8i32'
; SSE42-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %a)
; SSE42-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %bswap
; X86-LABEL: 'var_bswap_i128'
; X86-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
; X86-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i128 %bswap
;
; AVX1-LABEL: 'var_bswap_v8i32'
; AVX1-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %a)
; AVX1-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %bswap
;
; AVX2-LABEL: 'var_bswap_v8i32'
; AVX2-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %a)
; AVX2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %bswap
;
%bswap = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %a)
ret <8 x i32> %bswap
}
define <8 x i16> @var_bswap_v8i16(<8 x i16> %a) {
; SSE2-LABEL: 'var_bswap_v8i16'
; SSE2-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %bswap = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %a)
; SSE2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %bswap
;
; SSE42-LABEL: 'var_bswap_v8i16'
; SSE42-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %a)
; SSE42-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %bswap
;
; AVX-LABEL: 'var_bswap_v8i16'
; AVX-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %a)
; AVX-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %bswap
;
%bswap = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %a)
ret <8 x i16> %bswap
}
define <16 x i16> @var_bswap_v16i16(<16 x i16> %a) {
; SSE2-LABEL: 'var_bswap_v16i16'
; SSE2-NEXT: Cost Model: Found an estimated cost of 14 for instruction: %bswap = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %a)
; SSE2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i16> %bswap
;
; SSE42-LABEL: 'var_bswap_v16i16'
; SSE42-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %a)
; SSE42-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i16> %bswap
;
; AVX1-LABEL: 'var_bswap_v16i16'
; AVX1-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %a)
; AVX1-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i16> %bswap
;
; AVX2-LABEL: 'var_bswap_v16i16'
; AVX2-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %a)
; AVX2-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i16> %bswap
;
%bswap = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %a)
ret <16 x i16> %bswap
%bswap = call i128 @llvm.bswap.i128(i128 %a)
ret i128 %bswap
}

View File

@ -0,0 +1,158 @@
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze | FileCheck %s --check-prefixes=ALL,NOMOVBE,X64
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -cost-model -analyze -mattr=+movbe | FileCheck %s --check-prefixes=ALL,MOVBE,X64
; RUN: opt < %s -mtriple=i686-unknown-linux-gnu -cost-model -analyze | FileCheck %s --check-prefixes=ALL,NOMOVBE,X86
; RUN: opt < %s -mtriple=i686-unknown-linux-gnu -cost-model -analyze -mattr=+movbe | FileCheck %s --check-prefixes=ALL,MOVBE,X86
declare i16 @llvm.bswap.i16(i16)
declare i32 @llvm.bswap.i32(i32)
declare i64 @llvm.bswap.i64(i64)
declare i128 @llvm.bswap.i128(i128)
define i16 @var_load_bswap_i16(i16* %src) {
; NOMOVBE-LABEL: 'var_load_bswap_i16'
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = load i16, i16* %src, align 1
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %bswap
;
; MOVBE-LABEL: 'var_load_bswap_i16'
; MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = load i16, i16* %src, align 1
; MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
; MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %bswap
;
%a = load i16, i16* %src, align 1
%bswap = call i16 @llvm.bswap.i16(i16 %a)
ret i16 %bswap
}
define i16 @var_load_bswap_i16_extrause(i16* %src, i16* %clobberdst) {
; NOMOVBE-LABEL: 'var_load_bswap_i16_extrause'
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = load i16, i16* %src, align 1
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 10 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a2 = shl i16 %a, 2
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i16 %a2, i16* %clobberdst, align 1
; NOMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %bswap
;
; MOVBE-LABEL: 'var_load_bswap_i16_extrause'
; MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = load i16, i16* %src, align 1
; MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
; MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a2 = shl i16 %a, 2
; MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i16 %a2, i16* %clobberdst, align 1
; MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %bswap
;
%a = load i16, i16* %src, align 1
%bswap = call i16 @llvm.bswap.i16(i16 %a)
%a2 = shl i16 %a, 2 ; incur an extra use to the load
store i16 %a2, i16* %clobberdst, align 1
ret i16 %bswap
}
define i32 @var_load_bswap_i32(i32* %src) {
; ALL-LABEL: 'var_load_bswap_i32'
; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = load i32, i32* %src, align 1
; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i32 @llvm.bswap.i32(i32 %a)
; ALL-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %bswap
;
%a = load i32, i32* %src, align 1
%bswap = call i32 @llvm.bswap.i32(i32 %a)
ret i32 %bswap
}
define i32 @var_load_bswap_i32_extrause(i32* %src, i32* %clobberdst) {
; ALL-LABEL: 'var_load_bswap_i32_extrause'
; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = load i32, i32* %src, align 1
; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i32 @llvm.bswap.i32(i32 %a)
; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a2 = shl i32 %a, 2
; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %a2, i32* %clobberdst, align 1
; ALL-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %bswap
;
%a = load i32, i32* %src, align 1
%bswap = call i32 @llvm.bswap.i32(i32 %a)
%a2 = shl i32 %a, 2 ; incur an extra use to the load
store i32 %a2, i32* %clobberdst, align 1
ret i32 %bswap
}
define i64 @var_load_bswap_i64(i64* %src) {
; X64-LABEL: 'var_load_bswap_i64'
; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = load i64, i64* %src, align 1
; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %bswap
;
; X86-LABEL: 'var_load_bswap_i64'
; X86-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %a = load i64, i64* %src, align 1
; X86-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
; X86-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %bswap
;
%a = load i64, i64* %src, align 1
%bswap = call i64 @llvm.bswap.i64(i64 %a)
ret i64 %bswap
}
define i64 @var_load_bswap_i64_extrause(i64* %src, i64* %clobberdst) {
; X64-LABEL: 'var_load_bswap_i64_extrause'
; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = load i64, i64* %src, align 1
; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a2 = shl i64 %a, 2
; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i64 %a2, i64* %clobberdst, align 1
; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %bswap
;
; X86-LABEL: 'var_load_bswap_i64_extrause'
; X86-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %a = load i64, i64* %src, align 1
; X86-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
; X86-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %a2 = shl i64 %a, 2
; X86-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i64 %a2, i64* %clobberdst, align 1
; X86-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %bswap
;
%a = load i64, i64* %src, align 1
%bswap = call i64 @llvm.bswap.i64(i64 %a)
%a2 = shl i64 %a, 2 ; incur an extra use to the load
store i64 %a2, i64* %clobberdst, align 1
ret i64 %bswap
}
define i128 @var_load_bswap_i128(i128* %src) {
; X64-LABEL: 'var_load_bswap_i128'
; X64-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %a = load i128, i128* %src, align 1
; X64-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i128 %bswap
;
; X86-LABEL: 'var_load_bswap_i128'
; X86-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %a = load i128, i128* %src, align 1
; X86-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
; X86-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i128 %bswap
;
%a = load i128, i128* %src, align 1
%bswap = call i128 @llvm.bswap.i128(i128 %a)
ret i128 %bswap
}
define i128 @var_load_bswap_i128_extrause(i128* %src, i128* %clobberdst) {
; X64-LABEL: 'var_load_bswap_i128_extrause'
; X64-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %a = load i128, i128* %src, align 1
; X64-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
; X64-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %a2 = shl i128 %a, 2
; X64-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i128 %a2, i128* %clobberdst, align 1
; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i128 %bswap
;
; X86-LABEL: 'var_load_bswap_i128_extrause'
; X86-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %a = load i128, i128* %src, align 1
; X86-NEXT: Cost Model: Found an estimated cost of 8 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
; X86-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %a2 = shl i128 %a, 2
; X86-NEXT: Cost Model: Found an estimated cost of 4 for instruction: store i128 %a2, i128* %clobberdst, align 1
; X86-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i128 %bswap
;
%a = load i128, i128* %src, align 1
%bswap = call i128 @llvm.bswap.i128(i128 %a)
%a2 = shl i128 %a, 2 ; incur an extra use to the load
store i128 %a2, i128* %clobberdst, align 1
ret i128 %bswap
}