File: or-is-add.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (109 lines) | stat: -rw-r--r-- 2,454 bytes parent folder | download | duplicates (5)
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
108
109
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=riscv32 | FileCheck %s --check-prefixes=RV32
; RUN: llc < %s -mtriple=riscv64 | FileCheck %s --check-prefixes=RV64

define signext i32 @test1(i32 signext %x) {
; RV32-LABEL: test1:
; RV32:       # %bb.0:
; RV32-NEXT:    slli a0, a0, 1
; RV32-NEXT:    addi a0, a0, 1
; RV32-NEXT:    ret
;
; RV64-LABEL: test1:
; RV64:       # %bb.0:
; RV64-NEXT:    slliw a0, a0, 1
; RV64-NEXT:    addi a0, a0, 1
; RV64-NEXT:    ret
  %a = shl i32 %x, 1
  %b = or i32 %a, 1
  ret i32 %b
}

define i64 @test2(i64 %x) {
; RV32-LABEL: test2:
; RV32:       # %bb.0:
; RV32-NEXT:    andi a0, a0, -4
; RV32-NEXT:    addi a0, a0, 2
; RV32-NEXT:    ret
;
; RV64-LABEL: test2:
; RV64:       # %bb.0:
; RV64-NEXT:    andi a0, a0, -4
; RV64-NEXT:    addi a0, a0, 2
; RV64-NEXT:    ret
  %a = and i64 %x, -4
  %b = or i64 %a, 2
  ret i64 %b
}

define signext i32 @test3(i32 signext %x) {
; RV32-LABEL: test3:
; RV32:       # %bb.0:
; RV32-NEXT:    slli a0, a0, 3
; RV32-NEXT:    addi a0, a0, 6
; RV32-NEXT:    ret
;
; RV64-LABEL: test3:
; RV64:       # %bb.0:
; RV64-NEXT:    slliw a0, a0, 3
; RV64-NEXT:    addi a0, a0, 6
; RV64-NEXT:    ret
  %a = shl i32 %x, 3
  %b = add i32 %a, 6
  ret i32 %b
}

define i64 @test4(i64 %x) {
; RV32-LABEL: test4:
; RV32:       # %bb.0:
; RV32-NEXT:    srli a2, a0, 28
; RV32-NEXT:    slli a1, a1, 4
; RV32-NEXT:    or a1, a1, a2
; RV32-NEXT:    slli a0, a0, 4
; RV32-NEXT:    addi a0, a0, 13
; RV32-NEXT:    ret
;
; RV64-LABEL: test4:
; RV64:       # %bb.0:
; RV64-NEXT:    slli a0, a0, 4
; RV64-NEXT:    addi a0, a0, 13
; RV64-NEXT:    ret
  %a = shl i64 %x, 4
  %b = add i64 %a, 13
  ret i64 %b
}

define signext i32 @test5(i32 signext %x) {
; RV32-LABEL: test5:
; RV32:       # %bb.0:
; RV32-NEXT:    srli a0, a0, 24
; RV32-NEXT:    addi a0, a0, 256
; RV32-NEXT:    ret
;
; RV64-LABEL: test5:
; RV64:       # %bb.0:
; RV64-NEXT:    srliw a0, a0, 24
; RV64-NEXT:    addi a0, a0, 256
; RV64-NEXT:    ret
  %a = lshr i32 %x, 24
  %b = xor i32 %a, 256
  ret i32 %b
}

define i64 @test6(i64 %x) {
; RV32-LABEL: test6:
; RV32:       # %bb.0:
; RV32-NEXT:    srli a1, a1, 22
; RV32-NEXT:    addi a0, a1, 1024
; RV32-NEXT:    li a1, 0
; RV32-NEXT:    ret
;
; RV64-LABEL: test6:
; RV64:       # %bb.0:
; RV64-NEXT:    srli a0, a0, 54
; RV64-NEXT:    addi a0, a0, 1024
; RV64-NEXT:    ret
  %a = lshr i64 %x, 54
  %b = xor i64 %a, 1024
  ret i64 %b
}