@@ -134,8 +134,12 @@ void RISCVDAGToDAGISel::selectVLSEG(SDNode *Node, bool IsMasked,
134
134
MVT XLenVT = Subtarget->getXLenVT ();
135
135
RISCVVLMUL LMUL = RISCVTargetLowering::getLMUL (VT);
136
136
SDValue SEW = CurDAG->getTargetConstant (ScalarSize, DL, XLenVT);
137
+
138
+ SDValue Chain = Node->getOperand (0 );
139
+ SDValue Glue;
140
+
137
141
unsigned CurOp = 2 ;
138
- SmallVector<SDValue, 7 > Operands;
142
+ SmallVector<SDValue, 8 > Operands;
139
143
if (IsMasked) {
140
144
SmallVector<SDValue, 8 > Regs (Node->op_begin () + CurOp,
141
145
Node->op_begin () + CurOp + NF);
@@ -148,13 +152,20 @@ void RISCVDAGToDAGISel::selectVLSEG(SDNode *Node, bool IsMasked,
148
152
Operands.push_back (Base); // Base pointer.
149
153
if (IsStrided)
150
154
Operands.push_back (Node->getOperand (CurOp++)); // Stride.
151
- if (IsMasked)
152
- Operands.push_back (Node->getOperand (CurOp++)); // Mask.
155
+ if (IsMasked) {
156
+ // Mask needs to be copied to V0.
157
+ SDValue Mask = Node->getOperand (CurOp++);
158
+ Chain = CurDAG->getCopyToReg (Chain, DL, RISCV::V0, Mask, SDValue ());
159
+ Glue = Chain.getValue (1 );
160
+ Operands.push_back (CurDAG->getRegister (RISCV::V0, Mask.getValueType ()));
161
+ }
153
162
SDValue VL;
154
163
selectVLOp (Node->getOperand (CurOp++), VL);
155
164
Operands.push_back (VL);
156
165
Operands.push_back (SEW);
157
- Operands.push_back (Node->getOperand (0 )); // Chain.
166
+ Operands.push_back (Chain); // Chain.
167
+ if (Glue)
168
+ Operands.push_back (Glue);
158
169
const RISCV::VLSEGPseudo *P =
159
170
RISCV::getVLSEGPseudo (NF, IsMasked, IsStrided, /* FF*/ false , ScalarSize,
160
171
static_cast <unsigned >(LMUL));
@@ -184,6 +195,9 @@ void RISCVDAGToDAGISel::selectVLSEGFF(SDNode *Node, bool IsMasked) {
184
195
RISCVVLMUL LMUL = RISCVTargetLowering::getLMUL (VT);
185
196
SDValue SEW = CurDAG->getTargetConstant (ScalarSize, DL, XLenVT);
186
197
198
+ SDValue Chain = Node->getOperand (0 );
199
+ SDValue Glue;
200
+
187
201
unsigned CurOp = 2 ;
188
202
SmallVector<SDValue, 7 > Operands;
189
203
if (IsMasked) {
@@ -196,13 +210,20 @@ void RISCVDAGToDAGISel::selectVLSEGFF(SDNode *Node, bool IsMasked) {
196
210
SDValue Base;
197
211
SelectBaseAddr (Node->getOperand (CurOp++), Base);
198
212
Operands.push_back (Base); // Base pointer.
199
- if (IsMasked)
200
- Operands.push_back (Node->getOperand (CurOp++)); // Mask.
213
+ if (IsMasked) {
214
+ // Mask needs to be copied to V0.
215
+ SDValue Mask = Node->getOperand (CurOp++);
216
+ Chain = CurDAG->getCopyToReg (Chain, DL, RISCV::V0, Mask, SDValue ());
217
+ Glue = Chain.getValue (1 );
218
+ Operands.push_back (CurDAG->getRegister (RISCV::V0, Mask.getValueType ()));
219
+ }
201
220
SDValue VL;
202
221
selectVLOp (Node->getOperand (CurOp++), VL);
203
222
Operands.push_back (VL);
204
223
Operands.push_back (SEW);
205
- Operands.push_back (Node->getOperand (0 )); // Chain.
224
+ Operands.push_back (Chain); // Chain.
225
+ if (Glue)
226
+ Operands.push_back (Glue);
206
227
const RISCV::VLSEGPseudo *P =
207
228
RISCV::getVLSEGPseudo (NF, IsMasked, /* Strided*/ false , /* FF*/ true ,
208
229
ScalarSize, static_cast <unsigned >(LMUL));
@@ -235,8 +256,12 @@ void RISCVDAGToDAGISel::selectVLXSEG(SDNode *Node, bool IsMasked,
235
256
MVT XLenVT = Subtarget->getXLenVT ();
236
257
RISCVVLMUL LMUL = RISCVTargetLowering::getLMUL (VT);
237
258
SDValue SEW = CurDAG->getTargetConstant (ScalarSize, DL, XLenVT);
259
+
260
+ SDValue Chain = Node->getOperand (0 );
261
+ SDValue Glue;
262
+
238
263
unsigned CurOp = 2 ;
239
- SmallVector<SDValue, 7 > Operands;
264
+ SmallVector<SDValue, 8 > Operands;
240
265
if (IsMasked) {
241
266
SmallVector<SDValue, 8 > Regs (Node->op_begin () + CurOp,
242
267
Node->op_begin () + CurOp + NF);
@@ -249,13 +274,20 @@ void RISCVDAGToDAGISel::selectVLXSEG(SDNode *Node, bool IsMasked,
249
274
Operands.push_back (Base); // Base pointer.
250
275
Operands.push_back (Node->getOperand (CurOp++)); // Index.
251
276
MVT IndexVT = Operands.back ()->getSimpleValueType (0 );
252
- if (IsMasked)
253
- Operands.push_back (Node->getOperand (CurOp++)); // Mask.
277
+ if (IsMasked) {
278
+ // Mask needs to be copied to V0.
279
+ SDValue Mask = Node->getOperand (CurOp++);
280
+ Chain = CurDAG->getCopyToReg (Chain, DL, RISCV::V0, Mask, SDValue ());
281
+ Glue = Chain.getValue (1 );
282
+ Operands.push_back (CurDAG->getRegister (RISCV::V0, Mask.getValueType ()));
283
+ }
254
284
SDValue VL;
255
285
selectVLOp (Node->getOperand (CurOp++), VL);
256
286
Operands.push_back (VL);
257
287
Operands.push_back (SEW);
258
- Operands.push_back (Node->getOperand (0 )); // Chain.
288
+ Operands.push_back (Chain); // Chain.
289
+ if (Glue)
290
+ Operands.push_back (Glue);
259
291
260
292
assert (VT.getVectorElementCount () == IndexVT.getVectorElementCount () &&
261
293
" Element count mismatch" );
@@ -297,21 +329,32 @@ void RISCVDAGToDAGISel::selectVSSEG(SDNode *Node, bool IsMasked,
297
329
SDValue SEW = CurDAG->getTargetConstant (ScalarSize, DL, XLenVT);
298
330
SmallVector<SDValue, 8 > Regs (Node->op_begin () + 2 , Node->op_begin () + 2 + NF);
299
331
SDValue StoreVal = createTuple (*CurDAG, Regs, NF, LMUL);
300
- SmallVector<SDValue, 7 > Operands;
332
+
333
+ SDValue Chain = Node->getOperand (0 );
334
+ SDValue Glue;
335
+
336
+ SmallVector<SDValue, 8 > Operands;
301
337
Operands.push_back (StoreVal);
302
338
unsigned CurOp = 2 + NF;
303
339
SDValue Base;
304
340
SelectBaseAddr (Node->getOperand (CurOp++), Base);
305
341
Operands.push_back (Base); // Base pointer.
306
342
if (IsStrided)
307
343
Operands.push_back (Node->getOperand (CurOp++)); // Stride.
308
- if (IsMasked)
309
- Operands.push_back (Node->getOperand (CurOp++)); // Mask.
344
+ if (IsMasked) {
345
+ // Mask needs to be copied to V0.
346
+ SDValue Mask = Node->getOperand (CurOp++);
347
+ Chain = CurDAG->getCopyToReg (Chain, DL, RISCV::V0, Mask, SDValue ());
348
+ Glue = Chain.getValue (1 );
349
+ Operands.push_back (CurDAG->getRegister (RISCV::V0, Mask.getValueType ()));
350
+ }
310
351
SDValue VL;
311
352
selectVLOp (Node->getOperand (CurOp++), VL);
312
353
Operands.push_back (VL);
313
354
Operands.push_back (SEW);
314
- Operands.push_back (Node->getOperand (0 )); // Chain.
355
+ Operands.push_back (Chain); // Chain.
356
+ if (Glue)
357
+ Operands.push_back (Glue);
315
358
const RISCV::VSSEGPseudo *P = RISCV::getVSSEGPseudo (
316
359
NF, IsMasked, IsStrided, ScalarSize, static_cast <unsigned >(LMUL));
317
360
MachineSDNode *Store =
@@ -334,23 +377,34 @@ void RISCVDAGToDAGISel::selectVSXSEG(SDNode *Node, bool IsMasked,
334
377
MVT XLenVT = Subtarget->getXLenVT ();
335
378
RISCVVLMUL LMUL = RISCVTargetLowering::getLMUL (VT);
336
379
SDValue SEW = CurDAG->getTargetConstant (ScalarSize, DL, XLenVT);
337
- SmallVector<SDValue, 7 > Operands;
338
380
SmallVector<SDValue, 8 > Regs (Node->op_begin () + 2 , Node->op_begin () + 2 + NF);
339
381
SDValue StoreVal = createTuple (*CurDAG, Regs, NF, LMUL);
382
+
383
+ SDValue Chain = Node->getOperand (0 );
384
+ SDValue Glue;
385
+
386
+ SmallVector<SDValue, 8 > Operands;
340
387
Operands.push_back (StoreVal);
341
388
unsigned CurOp = 2 + NF;
342
389
SDValue Base;
343
390
SelectBaseAddr (Node->getOperand (CurOp++), Base);
344
391
Operands.push_back (Base); // Base pointer.
345
392
Operands.push_back (Node->getOperand (CurOp++)); // Index.
346
393
MVT IndexVT = Operands.back ()->getSimpleValueType (0 );
347
- if (IsMasked)
348
- Operands.push_back (Node->getOperand (CurOp++)); // Mask.
394
+ if (IsMasked) {
395
+ // Mask needs to be copied to V0.
396
+ SDValue Mask = Node->getOperand (CurOp++);
397
+ Chain = CurDAG->getCopyToReg (Chain, DL, RISCV::V0, Mask, SDValue ());
398
+ Glue = Chain.getValue (1 );
399
+ Operands.push_back (CurDAG->getRegister (RISCV::V0, Mask.getValueType ()));
400
+ }
349
401
SDValue VL;
350
402
selectVLOp (Node->getOperand (CurOp++), VL);
351
403
Operands.push_back (VL);
352
404
Operands.push_back (SEW);
353
- Operands.push_back (Node->getOperand (0 )); // Chain.
405
+ Operands.push_back (Chain); // Chain.
406
+ if (Glue)
407
+ Operands.push_back (Glue);
354
408
355
409
assert (VT.getVectorElementCount () == IndexVT.getVectorElementCount () &&
356
410
" Element count mismatch" );
@@ -620,22 +674,32 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
620
674
MVT XLenVT = Subtarget->getXLenVT ();
621
675
SDValue SEW = CurDAG->getTargetConstant (ScalarSize, DL, XLenVT);
622
676
677
+ SDValue Chain = Node->getOperand (0 );
678
+ SDValue Glue;
679
+
623
680
unsigned CurOp = 2 ;
624
- SmallVector<SDValue, 7 > Operands;
681
+ SmallVector<SDValue, 8 > Operands;
625
682
if (IsMasked)
626
683
Operands.push_back (Node->getOperand (CurOp++));
627
684
SDValue Base;
628
685
SelectBaseAddr (Node->getOperand (CurOp++), Base);
629
686
Operands.push_back (Base); // Base pointer.
630
687
Operands.push_back (Node->getOperand (CurOp++)); // Index.
631
688
MVT IndexVT = Operands.back ()->getSimpleValueType (0 );
632
- if (IsMasked)
633
- Operands.push_back (Node->getOperand (CurOp++)); // Mask.
689
+ if (IsMasked) {
690
+ // Mask needs to be copied to V0.
691
+ SDValue Mask = Node->getOperand (CurOp++);
692
+ Chain = CurDAG->getCopyToReg (Chain, DL, RISCV::V0, Mask, SDValue ());
693
+ Glue = Chain.getValue (1 );
694
+ Operands.push_back (CurDAG->getRegister (RISCV::V0, Mask.getValueType ()));
695
+ }
634
696
SDValue VL;
635
697
selectVLOp (Node->getOperand (CurOp++), VL);
636
698
Operands.push_back (VL);
637
699
Operands.push_back (SEW);
638
- Operands.push_back (Node->getOperand (0 )); // Chain.
700
+ Operands.push_back (Chain); // Chain.
701
+ if (Glue)
702
+ Operands.push_back (Glue);
639
703
640
704
assert (VT.getVectorElementCount () == IndexVT.getVectorElementCount () &&
641
705
" Element count mismatch" );
@@ -672,22 +736,32 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
672
736
unsigned SEWImm = (IntNo == Intrinsic::riscv_vle1) ? 8 : ScalarSize;
673
737
SDValue SEW = CurDAG->getTargetConstant (SEWImm, DL, XLenVT);
674
738
739
+ SDValue Chain = Node->getOperand (0 );
740
+ SDValue Glue;
741
+
675
742
unsigned CurOp = 2 ;
676
- SmallVector<SDValue, 7 > Operands;
743
+ SmallVector<SDValue, 8 > Operands;
677
744
if (IsMasked)
678
745
Operands.push_back (Node->getOperand (CurOp++));
679
746
SDValue Base;
680
747
SelectBaseAddr (Node->getOperand (CurOp++), Base);
681
748
Operands.push_back (Base); // Base pointer.
682
749
if (IsStrided)
683
750
Operands.push_back (Node->getOperand (CurOp++)); // Stride.
684
- if (IsMasked)
685
- Operands.push_back (Node->getOperand (CurOp++)); // Mask.
751
+ if (IsMasked) {
752
+ // Mask needs to be copied to V0.
753
+ SDValue Mask = Node->getOperand (CurOp++);
754
+ Chain = CurDAG->getCopyToReg (Chain, DL, RISCV::V0, Mask, SDValue ());
755
+ Glue = Chain.getValue (1 );
756
+ Operands.push_back (CurDAG->getRegister (RISCV::V0, Mask.getValueType ()));
757
+ }
686
758
SDValue VL;
687
759
selectVLOp (Node->getOperand (CurOp++), VL);
688
760
Operands.push_back (VL);
689
761
Operands.push_back (SEW);
690
- Operands.push_back (Node->getOperand (0 )); // Chain.
762
+ Operands.push_back (Chain); // Chain.
763
+ if (Glue)
764
+ Operands.push_back (Glue);
691
765
692
766
RISCVVLMUL LMUL = RISCVTargetLowering::getLMUL (VT);
693
767
const RISCV::VLEPseudo *P =
@@ -711,20 +785,30 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
711
785
MVT XLenVT = Subtarget->getXLenVT ();
712
786
SDValue SEW = CurDAG->getTargetConstant (ScalarSize, DL, XLenVT);
713
787
788
+ SDValue Chain = Node->getOperand (0 );
789
+ SDValue Glue;
790
+
714
791
unsigned CurOp = 2 ;
715
792
SmallVector<SDValue, 7 > Operands;
716
793
if (IsMasked)
717
794
Operands.push_back (Node->getOperand (CurOp++));
718
795
SDValue Base;
719
796
SelectBaseAddr (Node->getOperand (CurOp++), Base);
720
797
Operands.push_back (Base); // Base pointer.
721
- if (IsMasked)
722
- Operands.push_back (Node->getOperand (CurOp++)); // Mask.
798
+ if (IsMasked) {
799
+ // Mask needs to be copied to V0.
800
+ SDValue Mask = Node->getOperand (CurOp++);
801
+ Chain = CurDAG->getCopyToReg (Chain, DL, RISCV::V0, Mask, SDValue ());
802
+ Glue = Chain.getValue (1 );
803
+ Operands.push_back (CurDAG->getRegister (RISCV::V0, Mask.getValueType ()));
804
+ }
723
805
SDValue VL;
724
806
selectVLOp (Node->getOperand (CurOp++), VL);
725
807
Operands.push_back (VL);
726
808
Operands.push_back (SEW);
727
- Operands.push_back (Node->getOperand (0 )); // Chain.
809
+ Operands.push_back (Chain); // Chain.
810
+ if (Glue)
811
+ Operands.push_back (Glue);
728
812
729
813
RISCVVLMUL LMUL = RISCVTargetLowering::getLMUL (VT);
730
814
const RISCV::VLEPseudo *P =
@@ -842,7 +926,7 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
842
926
SDValue SEW = CurDAG->getTargetConstant (ScalarSize, DL, XLenVT);
843
927
844
928
unsigned CurOp = 2 ;
845
- SmallVector<SDValue, 6 > Operands;
929
+ SmallVector<SDValue, 7 > Operands;
846
930
Operands.push_back (Node->getOperand (CurOp++)); // Store value.
847
931
SDValue Base;
848
932
SelectBaseAddr (Node->getOperand (CurOp++), Base);
@@ -893,7 +977,7 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
893
977
SDValue SEW = CurDAG->getTargetConstant (SEWImm, DL, XLenVT);
894
978
895
979
unsigned CurOp = 2 ;
896
- SmallVector<SDValue, 6 > Operands;
980
+ SmallVector<SDValue, 7 > Operands;
897
981
Operands.push_back (Node->getOperand (CurOp++)); // Store value.
898
982
SDValue Base;
899
983
SelectBaseAddr (Node->getOperand (CurOp++), Base);
0 commit comments