1; RUN: llc -mtriple=arm64-eabi -mattr=+crc -o - %s | FileCheck %s
2; RUN: llc -mtriple=arm64-eabi -mcpu=cortex-a53 -mattr=+crc -o - %s | FileCheck %s
3
4define i32 @test_crc32b(i32 %cur, i8 %next) {
5; CHECK-LABEL: test_crc32b:
6; CHECK: crc32b w0, w0, w1
7  %bits = zext i8 %next to i32
8  %val = call i32 @llvm.aarch64.crc32b(i32 %cur, i32 %bits)
9  ret i32 %val
10}
11
12define i32 @test_crc32h(i32 %cur, i16 %next) {
13; CHECK-LABEL: test_crc32h:
14; CHECK: crc32h w0, w0, w1
15  %bits = zext i16 %next to i32
16  %val = call i32 @llvm.aarch64.crc32h(i32 %cur, i32 %bits)
17  ret i32 %val
18}
19
20define i32 @test_crc32w(i32 %cur, i32 %next) {
21; CHECK-LABEL: test_crc32w:
22; CHECK: crc32w w0, w0, w1
23  %val = call i32 @llvm.aarch64.crc32w(i32 %cur, i32 %next)
24  ret i32 %val
25}
26
27define i32 @test_crc32x(i32 %cur, i64 %next) {
28; CHECK-LABEL: test_crc32x:
29; CHECK: crc32x w0, w0, x1
30  %val = call i32 @llvm.aarch64.crc32x(i32 %cur, i64 %next)
31  ret i32 %val
32}
33
34define i32 @test_crc32cb(i32 %cur, i8 %next) {
35; CHECK-LABEL: test_crc32cb:
36; CHECK: crc32cb w0, w0, w1
37  %bits = zext i8 %next to i32
38  %val = call i32 @llvm.aarch64.crc32cb(i32 %cur, i32 %bits)
39  ret i32 %val
40}
41
42define i32 @test_crc32ch(i32 %cur, i16 %next) {
43; CHECK-LABEL: test_crc32ch:
44; CHECK: crc32ch w0, w0, w1
45  %bits = zext i16 %next to i32
46  %val = call i32 @llvm.aarch64.crc32ch(i32 %cur, i32 %bits)
47  ret i32 %val
48}
49
50define i32 @test_crc32cw(i32 %cur, i32 %next) {
51; CHECK-LABEL: test_crc32cw:
52; CHECK: crc32cw w0, w0, w1
53  %val = call i32 @llvm.aarch64.crc32cw(i32 %cur, i32 %next)
54  ret i32 %val
55}
56
57define i32 @test_crc32cx(i32 %cur, i64 %next) {
58; CHECK-LABEL: test_crc32cx:
59; CHECK: crc32cx w0, w0, x1
60  %val = call i32 @llvm.aarch64.crc32cx(i32 %cur, i64 %next)
61  ret i32 %val
62}
63
64declare i32 @llvm.aarch64.crc32b(i32, i32)
65declare i32 @llvm.aarch64.crc32h(i32, i32)
66declare i32 @llvm.aarch64.crc32w(i32, i32)
67declare i32 @llvm.aarch64.crc32x(i32, i64)
68
69declare i32 @llvm.aarch64.crc32cb(i32, i32)
70declare i32 @llvm.aarch64.crc32ch(i32, i32)
71declare i32 @llvm.aarch64.crc32cw(i32, i32)
72declare i32 @llvm.aarch64.crc32cx(i32, i64)
73