blob: 603a99e267f6b62549b60043af308db28493582f [file] [log] [blame]
Daniel Sandersfbb6a232015-11-26 11:23:03 +00001; RUN: llc -march=mipsel -mcpu=mips32 -mattr=+fp64,+msa,-nooddspreg \
Daniel Sanders0d972702016-06-24 12:23:17 +00002; RUN: -no-integrated-as -relocation-model=pic < %s | \
3; RUN: FileCheck %s -check-prefixes=ALL,ODDSPREG
Daniel Sandersfbb6a232015-11-26 11:23:03 +00004; RUN: llc -march=mipsel -mcpu=mips32 -mattr=+fp64,+msa,+nooddspreg \
Daniel Sanders0d972702016-06-24 12:23:17 +00005; RUN: -no-integrated-as -relocation-model=pic < %s | \
6; RUN: FileCheck %s -check-prefixes=ALL,NOODDSPREG
Daniel Sandersafe27c72015-02-23 17:22:16 +00007
8@v4f32 = global <4 x float> zeroinitializer
9
10define void @msa_insert_0(float %a) {
11entry:
12 ; Force the float into an odd-numbered register using named registers and
13 ; load the vector.
14 %b = call float asm sideeffect "mov.s $0, $1", "={$f13},{$f12}" (float %a)
David Blaikiea79ac142015-02-27 21:17:42 +000015 %0 = load volatile <4 x float>, <4 x float>* @v4f32
Daniel Sandersafe27c72015-02-23 17:22:16 +000016
17 ; Clobber all except $f12/$w12 and $f13
18 ;
19 ; The intention is that if odd single precision registers are permitted, the
20 ; allocator will choose $f12/$w12 for the vector and $f13 for the float to
21 ; avoid the spill/reload.
22 ;
23 ; On the other hand, if odd single precision registers are not permitted, it
24 ; must copy $f13 to an even-numbered register before inserting into the
25 ; vector.
Daniel Sandersf2b5bff2015-11-26 10:26:18 +000026 call void asm sideeffect "teqi $$zero, 1", "~{$f0},~{$f1},~{$f2},~{$f3},~{$f4},~{$f5},~{$f6},~{$f7},~{$f8},~{$f9},~{$f10},~{$f11},~{$f14},~{$f15},~{$f16},~{$f17},~{$f18},~{$f19},~{$f20},~{$f21},~{$f22},~{$f23},~{$f24},~{$f25},~{$f26},~{$f27},~{$f28},~{$f29},~{$f30},~{$f31}"()
Daniel Sandersafe27c72015-02-23 17:22:16 +000027 %1 = insertelement <4 x float> %0, float %b, i32 0
28 store <4 x float> %1, <4 x float>* @v4f32
29 ret void
30}
31
32; ALL-LABEL: msa_insert_0:
33; ALL: mov.s $f13, $f12
34; ALL: lw $[[R0:[0-9]+]], %got(v4f32)(
35; ALL: ld.w $w[[W0:[0-9]+]], 0($[[R0]])
36; NOODDSPREG: mov.s $f[[F0:[0-9]+]], $f13
37; NOODDSPREG: insve.w $w[[W0]][0], $w[[F0]][0]
38; ODDSPREG: insve.w $w[[W0]][0], $w13[0]
Daniel Sandersf2b5bff2015-11-26 10:26:18 +000039; ALL: teqi $zero, 1
Daniel Sandersafe27c72015-02-23 17:22:16 +000040; ALL-NOT: sdc1
41; ALL-NOT: ldc1
42; ALL: st.w $w[[W0]], 0($[[R0]])
43
44define void @msa_insert_1(float %a) {
45entry:
46 ; Force the float into an odd-numbered register using named registers and
47 ; load the vector.
48 %b = call float asm sideeffect "mov.s $0, $1", "={$f13},{$f12}" (float %a)
David Blaikiea79ac142015-02-27 21:17:42 +000049 %0 = load volatile <4 x float>, <4 x float>* @v4f32
Daniel Sandersafe27c72015-02-23 17:22:16 +000050
51 ; Clobber all except $f12/$w12 and $f13
52 ;
53 ; The intention is that if odd single precision registers are permitted, the
54 ; allocator will choose $f12/$w12 for the vector and $f13 for the float to
55 ; avoid the spill/reload.
56 ;
57 ; On the other hand, if odd single precision registers are not permitted, it
58 ; must copy $f13 to an even-numbered register before inserting into the
59 ; vector.
Daniel Sandersf2b5bff2015-11-26 10:26:18 +000060 call void asm sideeffect "teqi $$zero, 1", "~{$f0},~{$f1},~{$f2},~{$f3},~{$f4},~{$f5},~{$f6},~{$f7},~{$f8},~{$f9},~{$f10},~{$f11},~{$f14},~{$f15},~{$f16},~{$f17},~{$f18},~{$f19},~{$f20},~{$f21},~{$f22},~{$f23},~{$f24},~{$f25},~{$f26},~{$f27},~{$f28},~{$f29},~{$f30},~{$f31}"()
Daniel Sandersafe27c72015-02-23 17:22:16 +000061 %1 = insertelement <4 x float> %0, float %b, i32 1
62 store <4 x float> %1, <4 x float>* @v4f32
63 ret void
64}
65
66; ALL-LABEL: msa_insert_1:
67; ALL: mov.s $f13, $f12
68; ALL: lw $[[R0:[0-9]+]], %got(v4f32)(
69; ALL: ld.w $w[[W0:[0-9]+]], 0($[[R0]])
70; NOODDSPREG: mov.s $f[[F0:[0-9]+]], $f13
71; NOODDSPREG: insve.w $w[[W0]][1], $w[[F0]][0]
72; ODDSPREG: insve.w $w[[W0]][1], $w13[0]
Daniel Sandersf2b5bff2015-11-26 10:26:18 +000073; ALL: teqi $zero, 1
Daniel Sandersafe27c72015-02-23 17:22:16 +000074; ALL-NOT: sdc1
75; ALL-NOT: ldc1
76; ALL: st.w $w[[W0]], 0($[[R0]])
77
78define float @msa_extract_0() {
79entry:
David Blaikiea79ac142015-02-27 21:17:42 +000080 %0 = load volatile <4 x float>, <4 x float>* @v4f32
Daniel Sandersafe27c72015-02-23 17:22:16 +000081 %1 = call <4 x float> asm sideeffect "move.v $0, $1", "={$w13},{$w12}" (<4 x float> %0)
82
83 ; Clobber all except $f12, and $f13
84 ;
85 ; The intention is that if odd single precision registers are permitted, the
86 ; allocator will choose $f13/$w13 for the vector since that saves on moves.
87 ;
88 ; On the other hand, if odd single precision registers are not permitted, it
89 ; must move it to $f12/$w12.
Daniel Sandersf2b5bff2015-11-26 10:26:18 +000090 call void asm sideeffect "teqi $$zero, 1", "~{$f0},~{$f1},~{$f2},~{$f3},~{$f4},~{$f5},~{$f6},~{$f7},~{$f8},~{$f9},~{$f10},~{$f11},~{$f14},~{$f15},~{$f16},~{$f17},~{$f18},~{$f19},~{$f20},~{$f21},~{$f22},~{$f23},~{$f24},~{$f25},~{$f26},~{$f27},~{$f28},~{$f29},~{$f30},~{$f31}"()
Daniel Sandersafe27c72015-02-23 17:22:16 +000091
92 %2 = extractelement <4 x float> %1, i32 0
93 ret float %2
94}
95
96; ALL-LABEL: msa_extract_0:
97; ALL: lw $[[R0:[0-9]+]], %got(v4f32)(
98; ALL: ld.w $w12, 0($[[R0]])
99; ALL: move.v $w[[W0:13]], $w12
100; NOODDSPREG: move.v $w[[W0:12]], $w13
Daniel Sandersf2b5bff2015-11-26 10:26:18 +0000101; ALL: teqi $zero, 1
Daniel Sandersafe27c72015-02-23 17:22:16 +0000102; ALL-NOT: st.w
103; ALL-NOT: ld.w
104; ALL: mov.s $f0, $f[[W0]]
105
106define float @msa_extract_1() {
107entry:
David Blaikiea79ac142015-02-27 21:17:42 +0000108 %0 = load volatile <4 x float>, <4 x float>* @v4f32
Daniel Sandersafe27c72015-02-23 17:22:16 +0000109 %1 = call <4 x float> asm sideeffect "move.v $0, $1", "={$w13},{$w12}" (<4 x float> %0)
110
111 ; Clobber all except $f13
112 ;
113 ; The intention is that if odd single precision registers are permitted, the
114 ; allocator will choose $f13/$w13 for the vector since that saves on moves.
115 ;
116 ; On the other hand, if odd single precision registers are not permitted, it
117 ; must be spilled.
Daniel Sandersf2b5bff2015-11-26 10:26:18 +0000118 call void asm sideeffect "teqi $$zero, 1", "~{$f0},~{$f1},~{$f2},~{$f3},~{$f4},~{$f5},~{$f6},~{$f7},~{$f8},~{$f9},~{$f10},~{$f11},~{$f12},~{$f14},~{$f15},~{$f16},~{$f17},~{$f18},~{$f19},~{$f20},~{$f21},~{$f22},~{$f23},~{$f24},~{$f25},~{$f26},~{$f27},~{$f28},~{$f29},~{$f30},~{$f31}"()
Daniel Sandersafe27c72015-02-23 17:22:16 +0000119
120 %2 = extractelement <4 x float> %1, i32 1
121 ret float %2
122}
123
124; ALL-LABEL: msa_extract_1:
125; ALL: lw $[[R0:[0-9]+]], %got(v4f32)(
126; ALL: ld.w $w12, 0($[[R0]])
127; ALL: splati.w $w[[W0:[0-9]+]], $w13[1]
128; NOODDSPREG: st.w $w[[W0]], 0($sp)
129; ODDSPREG-NOT: st.w
130; ODDSPREG-NOT: ld.w
Daniel Sandersf2b5bff2015-11-26 10:26:18 +0000131; ALL: teqi $zero, 1
Daniel Sandersafe27c72015-02-23 17:22:16 +0000132; ODDSPREG-NOT: st.w
133; ODDSPREG-NOT: ld.w
134; NOODDSPREG: ld.w $w0, 0($sp)
135; ODDSPREG: mov.s $f0, $f[[W0]]