File: shift.ll

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,245,064 kB
  • sloc: cpp: 7,619,731; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,676; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (107 lines) | stat: -rw-r--r-- 2,796 bytes parent folder | download | duplicates (4)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc -mtriple=riscv32 -global-isel -global-isel-abort=1 -verify-machineinstrs < %s 2>&1 | FileCheck %s --check-prefixes=RV32
; RUN: llc -mtriple=riscv64 -global-isel -global-isel-abort=1 -verify-machineinstrs < %s 2>&1 | FileCheck %s --check-prefixes=RV64

define i16 @test_lshr_i48(i48 %x) {
; RV32-LABEL: test_lshr_i48:
; RV32:       # %bb.0:
; RV32-NEXT:    srli a0, a0, 16
; RV32-NEXT:    ret
;
; RV64-LABEL: test_lshr_i48:
; RV64:       # %bb.0:
; RV64-NEXT:    srliw a0, a0, 16
; RV64-NEXT:    ret
  %lshr = lshr i48 %x, 16
  %trunc = trunc i48 %lshr to i16
  ret i16 %trunc
}

define i16 @test_ashr_i48(i48 %x) {
; RV32-LABEL: test_ashr_i48:
; RV32:       # %bb.0:
; RV32-NEXT:    srai a0, a0, 16
; RV32-NEXT:    ret
;
; RV64-LABEL: test_ashr_i48:
; RV64:       # %bb.0:
; RV64-NEXT:    sraiw a0, a0, 16
; RV64-NEXT:    ret
  %ashr = ashr i48 %x, 16
  %trunc = trunc i48 %ashr to i16
  ret i16 %trunc
}

define i16 @test_shl_i48(i48 %x) {
; RV32-LABEL: test_shl_i48:
; RV32:       # %bb.0:
; RV32-NEXT:    slli a0, a0, 8
; RV32-NEXT:    ret
;
; RV64-LABEL: test_shl_i48:
; RV64:       # %bb.0:
; RV64-NEXT:    slli a0, a0, 8
; RV64-NEXT:    ret
  %shl = shl i48 %x, 8
  %trunc = trunc i48 %shl to i16
  ret i16 %trunc
}

; FIXME: Could use srlw to remove slli+srli.
define i16 @test_lshr_i48_2(i48 %x, i48 %y) {
; RV32-LABEL: test_lshr_i48_2:
; RV32:       # %bb.0:
; RV32-NEXT:    andi a2, a2, 15
; RV32-NEXT:    srl a0, a0, a2
; RV32-NEXT:    ret
;
; RV64-LABEL: test_lshr_i48_2:
; RV64:       # %bb.0:
; RV64-NEXT:    andi a1, a1, 15
; RV64-NEXT:    slli a0, a0, 32
; RV64-NEXT:    srli a0, a0, 32
; RV64-NEXT:    srl a0, a0, a1
; RV64-NEXT:    ret
  %and = and i48 %y, 15
  %lshr = lshr i48 %x, %and
  %trunc = trunc i48 %lshr to i16
  ret i16 %trunc
}

; FIXME: Could use sraw to remove the sext.w.
define i16 @test_ashr_i48_2(i48 %x, i48 %y) {
; RV32-LABEL: test_ashr_i48_2:
; RV32:       # %bb.0:
; RV32-NEXT:    andi a2, a2, 15
; RV32-NEXT:    sra a0, a0, a2
; RV32-NEXT:    ret
;
; RV64-LABEL: test_ashr_i48_2:
; RV64:       # %bb.0:
; RV64-NEXT:    andi a1, a1, 15
; RV64-NEXT:    sext.w a0, a0
; RV64-NEXT:    sra a0, a0, a1
; RV64-NEXT:    ret
  %and = and i48 %y, 15
  %ashr = ashr i48 %x, %and
  %trunc = trunc i48 %ashr to i16
  ret i16 %trunc
}

define i16 @test_shl_i48_2(i48 %x, i48 %y) {
; RV32-LABEL: test_shl_i48_2:
; RV32:       # %bb.0:
; RV32-NEXT:    andi a2, a2, 15
; RV32-NEXT:    sll a0, a0, a2
; RV32-NEXT:    ret
;
; RV64-LABEL: test_shl_i48_2:
; RV64:       # %bb.0:
; RV64-NEXT:    andi a1, a1, 15
; RV64-NEXT:    sll a0, a0, a1
; RV64-NEXT:    ret
  %and = and i48 %y, 15
  %shl = shl i48 %x, %and
  %trunc = trunc i48 %shl to i16
  ret i16 %trunc
}