File: bswap.ll

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (70 lines) | stat: -rw-r--r-- 2,205 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
; RUN: opt -passes='print<cost-model>' 2>&1 -disable-output -mtriple=aarch64--linux-gnu < %s | FileCheck %s

; Verify the cost of bswap instructions.

declare i16 @llvm.bswap.i16(i16)
declare i32 @llvm.bswap.i32(i32)
declare i64 @llvm.bswap.i64(i64)

declare <2 x i32> @llvm.bswap.v2i32(<2 x i32>)
declare <4 x i16> @llvm.bswap.v4i16(<4 x i16>)

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>)

define i16 @bswap_i16(i16 %a) {
; CHECK: function 'bswap_i16'
; CHECK: Found an estimated cost of 1 for instruction:   %bswap
  %bswap = tail call i16 @llvm.bswap.i16(i16 %a)
  ret i16 %bswap
}

define i32 @bswap_i32(i32 %a) {
; CHECK: function 'bswap_i32'
; CHECK: Found an estimated cost of 1 for instruction:   %bswap
  %bswap = tail call i32 @llvm.bswap.i32(i32 %a)
  ret i32 %bswap
}

define i64 @bswap_i64(i64 %a) {
; CHECK: function 'bswap_i64'
; CHECK: Found an estimated cost of 1 for instruction:   %bswap
  %bswap = tail call i64 @llvm.bswap.i64(i64 %a)
  ret i64 %bswap
}

define <2 x i32> @bswap_v2i32(<2 x i32> %a) {
; CHECK: function 'bswap_v2i32'
; CHECK: Found an estimated cost of 8 for instruction:   %bswap
  %bswap = call <2 x i32> @llvm.bswap.v2i32(<2 x i32> %a)
  ret <2 x i32> %bswap
}

define <4 x i16> @bswap_v4i16(<4 x i16> %a) {
; CHECK: function 'bswap_v4i16'
; CHECK: Found an estimated cost of 22 for instruction:   %bswap
  %bswap = call <4 x i16> @llvm.bswap.v4i16(<4 x i16> %a)
  ret <4 x i16> %bswap
}

define <2 x i64> @bswap_v2i64(<2 x i64> %a) {
; CHECK: function 'bswap_v2i64'
; CHECK: Found an estimated cost of 8 for instruction:   %bswap
  %bswap = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %a)
  ret <2 x i64> %bswap
}

define <4 x i32> @bswap_v4i32(<4 x i32> %a) {
; CHECK: function 'bswap_v4i32'
; CHECK: Found an estimated cost of 22 for instruction:   %bswap
  %bswap = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %a)
  ret <4 x i32> %bswap
}

define <8 x i16> @bswap_v8i16(<8 x i16> %a) {
; CHECK: function 'bswap_v8i16'
; CHECK: Found an estimated cost of 50 for instruction:   %bswap
  %bswap = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %a)
  ret <8 x i16> %bswap
}