1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc -mtriple=riscv32 -global-isel -global-isel-abort=1 -verify-machineinstrs < %s 2>&1 | FileCheck %s --check-prefixes=RV32
3 ; RUN: llc -mtriple=riscv64 -global-isel -global-isel-abort=1 -verify-machineinstrs < %s 2>&1 | FileCheck %s --check-prefixes=RV64
5 define i16 @test_lshr_i48(i48 %x) {
6 ; RV32-LABEL: test_lshr_i48:
8 ; RV32-NEXT: srli a0, a0, 16
11 ; RV64-LABEL: test_lshr_i48:
13 ; RV64-NEXT: srliw a0, a0, 16
15 %lshr = lshr i48 %x, 16
16 %trunc = trunc i48 %lshr to i16
20 define i16 @test_ashr_i48(i48 %x) {
21 ; RV32-LABEL: test_ashr_i48:
23 ; RV32-NEXT: srai a0, a0, 16
26 ; RV64-LABEL: test_ashr_i48:
28 ; RV64-NEXT: sraiw a0, a0, 16
30 %ashr = ashr i48 %x, 16
31 %trunc = trunc i48 %ashr to i16
35 define i16 @test_shl_i48(i48 %x) {
36 ; RV32-LABEL: test_shl_i48:
38 ; RV32-NEXT: slli a0, a0, 8
41 ; RV64-LABEL: test_shl_i48:
43 ; RV64-NEXT: slli a0, a0, 8
46 %trunc = trunc i48 %shl to i16
50 ; FIXME: Could use srlw to remove slli+srli.
51 define i16 @test_lshr_i48_2(i48 %x, i48 %y) {
52 ; RV32-LABEL: test_lshr_i48_2:
54 ; RV32-NEXT: andi a2, a2, 15
55 ; RV32-NEXT: srl a0, a0, a2
58 ; RV64-LABEL: test_lshr_i48_2:
60 ; RV64-NEXT: andi a1, a1, 15
61 ; RV64-NEXT: slli a0, a0, 32
62 ; RV64-NEXT: srli a0, a0, 32
63 ; RV64-NEXT: srl a0, a0, a1
66 %lshr = lshr i48 %x, %and
67 %trunc = trunc i48 %lshr to i16
71 ; FIXME: Could use sraw to remove the sext.w.
72 define i16 @test_ashr_i48_2(i48 %x, i48 %y) {
73 ; RV32-LABEL: test_ashr_i48_2:
75 ; RV32-NEXT: andi a2, a2, 15
76 ; RV32-NEXT: sra a0, a0, a2
79 ; RV64-LABEL: test_ashr_i48_2:
81 ; RV64-NEXT: andi a1, a1, 15
82 ; RV64-NEXT: sext.w a0, a0
83 ; RV64-NEXT: sra a0, a0, a1
86 %ashr = ashr i48 %x, %and
87 %trunc = trunc i48 %ashr to i16
91 define i16 @test_shl_i48_2(i48 %x, i48 %y) {
92 ; RV32-LABEL: test_shl_i48_2:
94 ; RV32-NEXT: andi a2, a2, 15
95 ; RV32-NEXT: sll a0, a0, a2
98 ; RV64-LABEL: test_shl_i48_2:
100 ; RV64-NEXT: andi a1, a1, 15
101 ; RV64-NEXT: sll a0, a0, a1
103 %and = and i48 %y, 15
104 %shl = shl i48 %x, %and
105 %trunc = trunc i48 %shl to i16