1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -mattr=+zbkb -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s -check-prefix=RV64ZBKB
5 declare i64 @llvm.riscv.brev8.i64(i64)
7 define i64 @brev8(i64 %a) nounwind {
8 ; RV64ZBKB-LABEL: brev8:
10 ; RV64ZBKB-NEXT: brev8 a0, a0
12 %val = call i64 @llvm.riscv.brev8.i64(i64 %a)
16 ; Test that rev8 is recognized as preserving zero extension.
17 define zeroext i16 @brev8_knownbits(i16 zeroext %a) nounwind {
18 ; RV64ZBKB-LABEL: brev8_knownbits:
20 ; RV64ZBKB-NEXT: brev8 a0, a0
22 %zext = zext i16 %a to i64
23 %val = call i64 @llvm.riscv.brev8.i64(i64 %zext)
24 %trunc = trunc i64 %val to i16
28 declare i64 @llvm.bswap.i64(i64)
30 define i64 @rev8_i64(i64 %a) {
31 ; RV64ZBKB-LABEL: rev8_i64:
33 ; RV64ZBKB-NEXT: rev8 a0, a0
35 %1 = call i64 @llvm.bswap.i64(i64 %a)
39 declare i32 @llvm.riscv.brev8.i32(i32)
41 define signext i32 @brev8_i32(i32 signext %a) nounwind {
42 ; RV64ZBKB-LABEL: brev8_i32:
44 ; RV64ZBKB-NEXT: brev8 a0, a0
45 ; RV64ZBKB-NEXT: sext.w a0, a0
47 %val = call i32 @llvm.riscv.brev8.i32(i32 %a)
51 ; Test that rev8 is recognized as preserving zero extension.
52 define zeroext i16 @brev8_i32_knownbits(i16 zeroext %a) nounwind {
53 ; RV64ZBKB-LABEL: brev8_i32_knownbits:
55 ; RV64ZBKB-NEXT: brev8 a0, a0
57 %zext = zext i16 %a to i32
58 %val = call i32 @llvm.riscv.brev8.i32(i32 %zext)
59 %trunc = trunc i32 %val to i16
63 declare i32 @llvm.bswap.i32(i32)
65 define signext i32 @rev8_i32(i32 signext %a) {
66 ; RV64ZBKB-LABEL: rev8_i32:
68 ; RV64ZBKB-NEXT: rev8 a0, a0
69 ; RV64ZBKB-NEXT: srai a0, a0, 32
71 %1 = call i32 @llvm.bswap.i32(i32 %a)