@@ -608,31 +608,42 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
608
608
default :
609
609
break ;
610
610
611
- case Intrinsic::riscv_vsetvli: {
611
+ case Intrinsic::riscv_vsetvli:
612
+ case Intrinsic::riscv_vsetvlimax: {
612
613
if (!Subtarget->hasStdExtV ())
613
614
break ;
614
615
615
- assert (Node->getNumOperands () == 5 );
616
+ bool VLMax = IntNo == Intrinsic::riscv_vsetvlimax;
617
+ unsigned Offset = VLMax ? 2 : 3 ;
618
+
619
+ assert (Node->getNumOperands () == Offset + 2 &&
620
+ " Unexpected number of operands" );
616
621
617
622
RISCVVSEW VSEW =
618
- static_cast <RISCVVSEW>(Node->getConstantOperandVal (3 ) & 0x7 );
619
- RISCVVLMUL VLMul =
620
- static_cast <RISCVVLMUL>( Node->getConstantOperandVal (4 ) & 0x7 );
623
+ static_cast <RISCVVSEW>(Node->getConstantOperandVal (Offset ) & 0x7 );
624
+ RISCVVLMUL VLMul = static_cast <RISCVVLMUL>(
625
+ Node->getConstantOperandVal (Offset + 1 ) & 0x7 );
621
626
622
627
unsigned VTypeI = RISCVVType::encodeVTYPE (
623
628
VLMul, VSEW, /* TailAgnostic*/ true , /* MaskAgnostic*/ false );
624
629
SDValue VTypeIOp = CurDAG->getTargetConstant (VTypeI, DL, XLenVT);
625
630
626
- SDValue VLOperand = Node->getOperand (2 );
627
- if (auto *C = dyn_cast<ConstantSDNode>(VLOperand)) {
628
- uint64_t AVL = C->getZExtValue ();
629
- if (isUInt<5 >(AVL)) {
630
- SDValue VLImm = CurDAG->getTargetConstant (AVL, DL, XLenVT);
631
- ReplaceNode (Node,
632
- CurDAG->getMachineNode (RISCV::PseudoVSETIVLI, DL, XLenVT,
631
+ SDValue VLOperand;
632
+ if (VLMax) {
633
+ VLOperand = CurDAG->getRegister (RISCV::X0, XLenVT);
634
+ } else {
635
+ VLOperand = Node->getOperand (2 );
636
+
637
+ if (auto *C = dyn_cast<ConstantSDNode>(VLOperand)) {
638
+ uint64_t AVL = C->getZExtValue ();
639
+ if (isUInt<5 >(AVL)) {
640
+ SDValue VLImm = CurDAG->getTargetConstant (AVL, DL, XLenVT);
641
+ ReplaceNode (
642
+ Node, CurDAG->getMachineNode (RISCV::PseudoVSETIVLI, DL, XLenVT,
633
643
MVT::Other, VLImm, VTypeIOp,
634
644
/* Chain */ Node->getOperand (0 )));
635
- return ;
645
+ return ;
646
+ }
636
647
}
637
648
}
638
649
@@ -642,28 +653,6 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
642
653
/* Chain */ Node->getOperand (0 )));
643
654
return ;
644
655
}
645
- case Intrinsic::riscv_vsetvlimax: {
646
- if (!Subtarget->hasStdExtV ())
647
- break ;
648
-
649
- assert (Node->getNumOperands () == 4 );
650
-
651
- RISCVVSEW VSEW =
652
- static_cast <RISCVVSEW>(Node->getConstantOperandVal (2 ) & 0x7 );
653
- RISCVVLMUL VLMul =
654
- static_cast <RISCVVLMUL>(Node->getConstantOperandVal (3 ) & 0x7 );
655
-
656
- unsigned VTypeI = RISCVVType::encodeVTYPE (
657
- VLMul, VSEW, /* TailAgnostic*/ true , /* MaskAgnostic*/ false );
658
- SDValue VTypeIOp = CurDAG->getTargetConstant (VTypeI, DL, XLenVT);
659
-
660
- SDValue VLOperand = CurDAG->getRegister (RISCV::X0, XLenVT);
661
- ReplaceNode (Node,
662
- CurDAG->getMachineNode (RISCV::PseudoVSETVLI, DL, XLenVT,
663
- MVT::Other, VLOperand, VTypeIOp,
664
- /* Chain */ Node->getOperand (0 )));
665
- return ;
666
- }
667
656
case Intrinsic::riscv_vlseg2:
668
657
case Intrinsic::riscv_vlseg3:
669
658
case Intrinsic::riscv_vlseg4:
0 commit comments