1; Test whether the following functions, with vectors featuring negative or values larger than the element
2; bit size have their results of operations generated correctly when placed into constant pools
3
4; RUN: llc -march=mips64 -mattr=+msa,+fp64 -relocation-model=pic < %s | FileCheck -check-prefixes=ALL,MIPS64 %s
5; RUN: llc -march=mips -mattr=+msa,+fp64 -relocation-model=pic < %s | FileCheck -check-prefixes=ALL,MIPS32 %s
6; RUN: llc -march=mips64el -mattr=+msa,+fp64 -relocation-model=pic < %s | FileCheck -check-prefixes=ALL,MIPS64 %s
7; RUN: llc -march=mipsel -mattr=+msa,+fp64 -relocation-model=pic < %s | FileCheck -check-prefixes=ALL,MIPS32 %s
8
9@llvm_mips_bclr_w_test_const_vec_res = global <4 x i32> zeroinitializer, align 16
10
11define void @llvm_mips_bclr_w_test_const_vec() nounwind {
12entry:
13  %0 = tail call <4 x i32> @llvm.mips.bclr.w(<4 x i32> <i32 2147483649, i32 2147483649, i32 7, i32 7>, <4 x i32> <i32 -1, i32 31, i32 2, i32 34>)
14  store <4 x i32> %0, <4 x i32>* @llvm_mips_bclr_w_test_const_vec_res
15  ret void
16}
17
18declare <4 x i32> @llvm.mips.bclr.w(<4 x i32>, <4 x i32>) nounwind
19
20; MIPS32: [[LABEL:\$CPI[0-9]+_[0-9]+]]:
21; MIPS64: [[LABEL:\.LCPI[0-9]+_[0-9]+]]:
22; ALL:	.4byte	1                       # 0x1
23; ALL:	.4byte	1                       # 0x1
24; ALL:	.4byte	3                       # 0x3
25; ALL:	.4byte	3                       # 0x3
26; ALL-LABEL: llvm_mips_bclr_w_test_const_vec:
27; MIPS32: lw $[[R2:[0-9]+]], %got([[LABEL]])($[[R1:[0-9]+]])
28; MIPS32: addiu $[[R2]], $[[R2]], %lo([[LABEL]])
29; MIPS32: lw $[[R3:[0-9]+]], %got(llvm_mips_bclr_w_test_const_vec_res)($[[R1]])
30; MIPS64: ld $[[R2:[0-9]+]], %got_page([[LABEL]])($[[R1:[0-9]+]])
31; MIPS64: daddiu $[[R2]], $[[R2]], %got_ofst([[LABEL]])
32; MIPS64: ld $[[R3:[0-9]+]], %got_disp(llvm_mips_bclr_w_test_const_vec_res)($[[R1]])
33; ALL: ld.w $w0, 0($[[R2]])
34; ALL: st.w $w0, 0($[[R3]])
35
36
37@llvm_mips_bneg_w_test_const_vec_res = global <4 x i32> zeroinitializer, align 16
38
39define void @llvm_mips_bneg_w_test_const_vec() nounwind {
40entry:
41  %0 = tail call <4 x i32> @llvm.mips.bneg.w(<4 x i32> <i32 2147483649, i32 2147483649, i32 7, i32 7>, <4 x i32> <i32 -1, i32 31, i32 2, i32 34>)
42  store <4 x i32> %0, <4 x i32>* @llvm_mips_bneg_w_test_const_vec_res
43  ret void
44}
45
46declare <4 x i32> @llvm.mips.bneg.w(<4 x i32>, <4 x i32>) nounwind
47
48; MIPS32: [[LABEL:\$CPI[0-9]+_[0-9]+]]:
49; MIPS64: [[LABEL:\.LCPI[0-9]+_[0-9]+]]:
50; ALL:	.4byte	1                       # 0x1
51; ALL:	.4byte	1                       # 0x1
52; ALL:	.4byte	3                       # 0x3
53; ALL:	.4byte	3                       # 0x3
54; ALL-LABEL: llvm_mips_bneg_w_test_const_vec:
55; MIPS32: lw $[[R2:[0-9]+]], %got([[LABEL]])($[[R1:[0-9]+]])
56; MIPS32: addiu $[[R2]], $[[R2]], %lo([[LABEL]])
57; MIPS32: lw $[[R3:[0-9]+]], %got(llvm_mips_bneg_w_test_const_vec_res)($[[R1]])
58; MIPS64: ld $[[R2:[0-9]+]], %got_page([[LABEL]])($[[R1:[0-9]+]])
59; MIPS64: daddiu $[[R2]], $[[R2]], %got_ofst([[LABEL]])
60; MIPS64: ld $[[R3:[0-9]+]], %got_disp(llvm_mips_bneg_w_test_const_vec_res)($[[R1]])
61; ALL: ld.w $w0, 0($[[R2]])
62; ALL: st.w $w0, 0($[[R3]])
63
64
65@llvm_mips_bset_w_test_const_vec_res = global <4 x i32> zeroinitializer, align 16
66
67define void @llvm_mips_bset_w_test_const_vec() nounwind {
68entry:
69  %0 = tail call <4 x i32> @llvm.mips.bset.w(<4 x i32> <i32 0, i32 0, i32 0, i32 0>, <4 x i32> <i32 -1, i32 31, i32 2, i32 34>)
70  store <4 x i32> %0, <4 x i32>* @llvm_mips_bset_w_test_const_vec_res
71  ret void
72}
73
74declare <4 x i32> @llvm.mips.bset.w(<4 x i32>, <4 x i32>) nounwind
75
76; MIPS32: [[LABEL:\$CPI[0-9]+_[0-9]+]]:
77; MIPS64: [[LABEL:\.LCPI[0-9]+_[0-9]+]]:
78; ALL:	.4byte	2147483648              # 0x80000000
79; ALL:	.4byte	2147483648              # 0x80000000
80; ALL:	.4byte	4                       # 0x4
81; ALL:	.4byte	4                       # 0x4
82; ALL-LABEL: llvm_mips_bset_w_test_const_vec:
83; MIPS32: lw $[[R2:[0-9]+]], %got([[LABEL]])($[[R1:[0-9]+]])
84; MIPS32: addiu $[[R2]], $[[R2]], %lo([[LABEL]])
85; MIPS32: lw $[[R3:[0-9]+]], %got(llvm_mips_bset_w_test_const_vec_res)($[[R1]])
86; MIPS64: ld $[[R2:[0-9]+]], %got_page([[LABEL]])($[[R1:[0-9]+]])
87; MIPS64: daddiu $[[R2]], $[[R2]], %got_ofst([[LABEL]])
88; MIPS64: ld $[[R3:[0-9]+]], %got_disp(llvm_mips_bset_w_test_const_vec_res)($[[R1]])
89; ALL: ld.w $w0, 0($[[R2]])
90; ALL: st.w $w0, 0($[[R3]])
91
92@llvm_mips_sll_w_test_const_vec_res = global <4 x i32> zeroinitializer, align 16
93
94define void @llvm_mips_sll_w_test_const_vec() nounwind {
95entry:
96  %0 = tail call <4 x i32> @llvm.mips.sll.w(<4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> <i32 -1, i32 31, i32 2, i32 34>)
97  store <4 x i32> %0, <4 x i32>* @llvm_mips_sll_w_test_const_vec_res
98  ret void
99}
100
101declare <4 x i32> @llvm.mips.sll.w(<4 x i32>, <4 x i32>) nounwind
102
103; MIPS32: [[LABEL:\$CPI[0-9]+_[0-9]+]]:
104; MIPS64: [[LABEL:\.LCPI[0-9]+_[0-9]+]]:
105; ALL: .4byte 2147483648              # 0x80000000
106; ALL: .4byte 2147483648              # 0x80000000
107; ALL: .4byte 4                       # 0x4
108; ALL: .4byte 4                       # 0x4
109; ALL-LABEL: llvm_mips_sll_w_test_const_vec:
110; MIPS32: lw $[[R2:[0-9]+]], %got([[LABEL]])($[[R1:[0-9]+]])
111; MIPS32: addiu $[[R2]], $[[R2]], %lo([[LABEL]])
112; MIPS32: lw $[[R3:[0-9]+]], %got(llvm_mips_sll_w_test_const_vec_res)($[[R1]])
113; MIPS64: ld $[[R2:[0-9]+]], %got_page([[LABEL]])($[[R1:[0-9]+]])
114; MIPS64: daddiu $[[R2]], $[[R2]], %got_ofst([[LABEL]])
115; MIPS64: ld $[[R3:[0-9]+]], %got_disp(llvm_mips_sll_w_test_const_vec_res)($[[R1]])
116; ALL: ld.w $w0, 0($[[R2]])
117; ALL: st.w $w0, 0($[[R3]])
118
119@llvm_mips_sra_w_test_const_vec_res = global <4 x i32> zeroinitializer, align 16
120
121define void @llvm_mips_sra_w_test_const_vec() nounwind {
122entry:
123  %0 = tail call <4 x i32> @llvm.mips.sra.w(<4 x i32> <i32 -16, i32 16, i32 16, i32 16>, <4 x i32> <i32 2, i32 -30, i32 33, i32 1>)
124  store <4 x i32> %0, <4 x i32>* @llvm_mips_sra_w_test_const_vec_res
125  ret void
126}
127
128declare <4 x i32> @llvm.mips.sra.w(<4 x i32>, <4 x i32>) nounwind
129
130; MIPS32: [[LABEL:\$CPI[0-9]+_[0-9]+]]:
131; MIPS64: [[LABEL:\.LCPI[0-9]+_[0-9]+]]:
132; ALL: .4byte 4294967292              # 0xfffffffc
133; ALL: .4byte 4                       # 0x4
134; ALL: .4byte 8                       # 0x8
135; ALL: .4byte 8                       # 0x8
136; ALL-LABEL: llvm_mips_sra_w_test_const_vec:
137; MIPS32: lw $[[R2:[0-9]+]], %got([[LABEL]])($[[R1:[0-9]+]])
138; MIPS32: addiu $[[R2]], $[[R2]], %lo([[LABEL]])
139; MIPS32: lw $[[R3:[0-9]+]], %got(llvm_mips_sra_w_test_const_vec_res)($[[R1]])
140; MIPS64: ld $[[R2:[0-9]+]], %got_page([[LABEL]])($[[R1:[0-9]+]])
141; MIPS64: daddiu $[[R2]], $[[R2]], %got_ofst([[LABEL]])
142; MIPS64: ld $[[R3:[0-9]+]], %got_disp(llvm_mips_sra_w_test_const_vec_res)($[[R1]])
143; ALL: ld.w $w0, 0($[[R2]])
144; ALL: st.w $w0, 0($[[R3]])
145
146@llvm_mips_srl_w_test_const_vec_res = global <4 x i32> zeroinitializer, align 16
147
148define void @llvm_mips_srl_w_test_const_vec() nounwind {
149entry:
150  %0 = tail call <4 x i32> @llvm.mips.srl.w(<4 x i32> <i32 -16, i32 16, i32 16, i32 16>, <4 x i32> <i32 2, i32 -30, i32 33, i32 1>)
151  store <4 x i32> %0, <4 x i32>* @llvm_mips_srl_w_test_const_vec_res
152  ret void
153}
154
155declare <4 x i32> @llvm.mips.srl.w(<4 x i32>, <4 x i32>) nounwind
156
157; MIPS32: [[LABEL:\$CPI[0-9]+_[0-9]+]]:
158; MIPS64: [[LABEL:\.LCPI[0-9]+_[0-9]+]]:
159; ALL: .4byte 1073741820              # 0x3ffffffc
160; ALL: .4byte 4                       # 0x4
161; ALL: .4byte 8                       # 0x8
162; ALL: .4byte 8                       # 0x8
163; ALL-LABEL: llvm_mips_srl_w_test_const_vec:
164; MIPS32: lw $[[R2:[0-9]+]], %got([[LABEL]])($[[R1:[0-9]+]])
165; MIPS32: addiu $[[R2]], $[[R2]], %lo([[LABEL]])
166; MIPS32: lw $[[R3:[0-9]+]], %got(llvm_mips_srl_w_test_const_vec_res)($[[R1]])
167; MIPS64: ld $[[R2:[0-9]+]], %got_page([[LABEL]])($[[R1:[0-9]+]])
168; MIPS64: daddiu $[[R2]], $[[R2]], %got_ofst([[LABEL]])
169; MIPS64: ld $[[R3:[0-9]+]], %got_disp(llvm_mips_srl_w_test_const_vec_res)($[[R1]])
170; ALL: ld.w $w0, 0($[[R2]])
171; ALL: st.w $w0, 0($[[R3]])
172