• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -march=mips < %s | FileCheck %s -check-prefixes=ALL,MIPS
2; RUN: llc -march=mips < %s -mattr=+micromips | FileCheck %s -check-prefixes=ALL,MM
3
4; Test the patterns used for constant materialization.
5
6; Constants generated using li16
7define i32 @Li16LowBoundary() {
8entry:
9  ; ALL-LABEL: Li16LowBoundary:
10  ; MIPS:     addiu	$2, $zero, -1
11  ; MM:       li16	$2, -1
12  ; ALL-NOT:  lui
13  ; ALL-NOT:  ori
14  ; MIPS-NOT: li16
15  ; MM-NOT:   addiu
16
17  ret i32 -1
18}
19
20define i32 @Li16HighBoundary() {
21entry:
22  ; ALL-LABEL: Li16HighBoundary:
23  ; MIPS:     addiu	$2, $zero, 126
24  ; MM:       li16	$2, 126
25  ; ALL-NOT:  lui
26  ; ALL-NOT:  ori
27  ; MM-NOT:   addiu
28  ; MIPS-NOT: li16
29
30  ret i32 126
31}
32
33; Constants generated using addiu
34define i32 @AddiuLowBoundary() {
35entry:
36  ; ALL-LABEL: AddiuLowBoundary:
37  ; ALL:      addiu	$2, $zero, -32768
38  ; ALL-NOT:  lui
39  ; ALL-NOT:  ori
40  ; ALL-NOT:  li16
41
42  ret i32 -32768
43}
44
45define i32 @AddiuZero() {
46entry:
47  ; ALL-LABEL: AddiuZero:
48  ; MIPS:     addiu	$2, $zero, 0
49  ; MM:       li16	$2, 0
50  ; ALL-NOT:  lui
51  ; ALL-NOT:  ori
52  ; MIPS-NOT: li16
53  ; MM-NOT:   addiu
54
55  ret i32 0
56}
57
58define i32 @AddiuHighBoundary() {
59entry:
60  ; ALL-LABEL: AddiuHighBoundary:
61  ; ALL:     addiu	$2, $zero, 32767
62  ; ALL-NOT: lui
63  ; ALL-NOT: ori
64  ; ALL-NOT: li16
65
66  ret i32 32767
67}
68
69; Constants generated using ori
70define i32 @OriLowBoundary() {
71entry:
72  ; ALL-LABEL: OriLowBoundary:
73  ; ALL:     ori	$2, $zero, 32768
74  ; ALL-NOT: addiu
75  ; ALL-NOT: lui
76  ; ALL-NOT: li16
77
78  ret i32 32768
79}
80
81define i32 @OriHighBoundary() {
82entry:
83  ; ALL-LABEL: OriHighBoundary:
84  ; ALL:     ori	$2, $zero, 65535
85  ; ALL-NOT: addiu
86  ; ALL-NOT: lui
87  ; ALL-NOT: li16
88
89  ret i32 65535
90}
91
92; Constants generated using lui
93define i32 @LuiPositive() {
94entry:
95  ; ALL-LABEL: LuiPositive:
96  ; ALL:     lui	$2, 1
97  ; ALL-NOT: addiu
98  ; ALL-NOT: ori
99  ; ALL-NOT: li16
100
101  ret i32 65536
102}
103
104define i32 @LuiNegative() {
105entry:
106  ; ALL-LABEL: LuiNegative:
107  ; ALL:     lui	$2, 65535
108  ; ALL-NOT: addiu
109  ; ALL-NOT: ori
110  ; ALL-NOT: li16
111
112  ret i32 -65536
113}
114
115; Constants generated using a combination of lui and ori
116define i32 @LuiWithLowBitsSet() {
117entry:
118  ; ALL-LABEL: LuiWithLowBitsSet:
119  ; ALL:     lui	$1, 1
120  ; ALL:     ori	$2, $1, 1
121  ; ALL-NOT: addiu
122  ; ALL-NOT: li16
123
124  ret i32 65537
125}
126
127define i32 @BelowAddiuLowBoundary() {
128entry:
129  ; ALL-LABEL: BelowAddiuLowBoundary:
130  ; ALL:     lui	$1, 65535
131  ; ALL:     ori	$2, $1, 32767
132  ; ALL-NOT: addiu
133  ; ALL-NOT: li16
134
135  ret i32 -32769
136}
137