@@ -779,15 +779,22 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
779
779
// Splice
780
780
setOperationAction(ISD::VECTOR_SPLICE, VT, Custom);
781
781
782
+ if (Subtarget.hasStdExtZvkb()) {
783
+ setOperationAction(ISD::BSWAP, VT, Legal);
784
+ setOperationAction(ISD::VP_BSWAP, VT, Custom);
785
+ } else {
786
+ setOperationAction({ISD::BSWAP, ISD::VP_BSWAP}, VT, Expand);
787
+ setOperationAction({ISD::ROTL, ISD::ROTR}, VT, Expand);
788
+ }
789
+
782
790
if (Subtarget.hasStdExtZvbb()) {
783
- setOperationAction({ ISD::BITREVERSE, ISD::BSWAP} , VT, Legal);
784
- setOperationAction({ ISD::VP_BITREVERSE, ISD::VP_BSWAP} , VT, Custom);
791
+ setOperationAction(ISD::BITREVERSE, VT, Legal);
792
+ setOperationAction(ISD::VP_BITREVERSE, VT, Custom);
785
793
setOperationAction({ISD::VP_CTLZ, ISD::VP_CTLZ_ZERO_UNDEF, ISD::VP_CTTZ,
786
794
ISD::VP_CTTZ_ZERO_UNDEF, ISD::VP_CTPOP},
787
795
VT, Custom);
788
796
} else {
789
- setOperationAction({ISD::BITREVERSE, ISD::BSWAP}, VT, Expand);
790
- setOperationAction({ISD::VP_BITREVERSE, ISD::VP_BSWAP}, VT, Expand);
797
+ setOperationAction({ISD::BITREVERSE, ISD::VP_BITREVERSE}, VT, Expand);
791
798
setOperationAction({ISD::CTLZ, ISD::CTTZ, ISD::CTPOP}, VT, Expand);
792
799
setOperationAction({ISD::VP_CTLZ, ISD::VP_CTLZ_ZERO_UNDEF, ISD::VP_CTTZ,
793
800
ISD::VP_CTTZ_ZERO_UNDEF, ISD::VP_CTPOP},
@@ -802,8 +809,6 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
802
809
ISD::VP_CTLZ_ZERO_UNDEF, ISD::VP_CTTZ_ZERO_UNDEF},
803
810
VT, Custom);
804
811
}
805
-
806
- setOperationAction({ISD::ROTL, ISD::ROTR}, VT, Expand);
807
812
}
808
813
}
809
814
@@ -1109,11 +1114,12 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
1109
1114
1110
1115
setOperationAction(IntegerVPOps, VT, Custom);
1111
1116
1117
+ if (Subtarget.hasStdExtZvkb())
1118
+ setOperationAction({ISD::BSWAP, ISD::ROTL, ISD::ROTR}, VT, Custom);
1119
+
1112
1120
if (Subtarget.hasStdExtZvbb()) {
1113
- setOperationAction({ISD::BITREVERSE, ISD::BSWAP, ISD::CTLZ,
1114
- ISD::CTLZ_ZERO_UNDEF, ISD::CTTZ,
1115
- ISD::CTTZ_ZERO_UNDEF, ISD::CTPOP, ISD::ROTL,
1116
- ISD::ROTR},
1121
+ setOperationAction({ISD::BITREVERSE, ISD::CTLZ, ISD::CTLZ_ZERO_UNDEF,
1122
+ ISD::CTTZ, ISD::CTTZ_ZERO_UNDEF, ISD::CTPOP},
1117
1123
VT, Custom);
1118
1124
} else {
1119
1125
// Lower CTLZ_ZERO_UNDEF and CTTZ_ZERO_UNDEF if element of VT in the
@@ -4376,7 +4382,7 @@ static SDValue lowerBitreverseShuffle(ShuffleVectorSDNode *SVN,
4376
4382
4377
4383
// Given a shuffle mask like <3, 0, 1, 2, 7, 4, 5, 6> for v8i8, we can
4378
4384
// reinterpret it as a v2i32 and rotate it right by 8 instead. We can lower this
4379
- // as a vror.vi if we have zvbb , or otherwise as a vsll, vsrl and vor.
4385
+ // as a vror.vi if we have Zvkb , or otherwise as a vsll, vsrl and vor.
4380
4386
static SDValue lowerVECTOR_SHUFFLEAsRotate(ShuffleVectorSDNode *SVN,
4381
4387
SelectionDAG &DAG,
4382
4388
const RISCVSubtarget &Subtarget) {
@@ -4527,9 +4533,9 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
4527
4533
lowerVECTOR_SHUFFLEAsVSlidedown(DL, VT, V1, V2, Mask, Subtarget, DAG))
4528
4534
return V;
4529
4535
4530
- // A bitrotate will be one instruction on zvbb , so try to lower to it first if
4536
+ // A bitrotate will be one instruction on Zvkb , so try to lower to it first if
4531
4537
// available.
4532
- if (Subtarget.hasStdExtZvbb ())
4538
+ if (Subtarget.hasStdExtZvkb ())
4533
4539
if (SDValue V = lowerVECTOR_SHUFFLEAsRotate(SVN, DAG, Subtarget))
4534
4540
return V;
4535
4541
@@ -4660,7 +4666,7 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
4660
4666
return DAG.getNode(ISD::VSELECT, DL, VT, SelectMask, V1, V2);
4661
4667
4662
4668
// We might be able to express the shuffle as a bitrotate. But even if we
4663
- // don't have zvbb and have to expand, the expanded sequence of approx. 2
4669
+ // don't have Zvkb and have to expand, the expanded sequence of approx. 2
4664
4670
// shifts and a vor will have a higher throughput than a vrgather.
4665
4671
if (SDValue V = lowerVECTOR_SHUFFLEAsRotate(SVN, DAG, Subtarget))
4666
4672
return V;
@@ -5482,7 +5488,7 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
5482
5488
case ISD::ROTL:
5483
5489
case ISD::ROTR:
5484
5490
if (Op.getValueType().isFixedLengthVector()) {
5485
- assert(Subtarget.hasStdExtZvbb ());
5491
+ assert(Subtarget.hasStdExtZvkb ());
5486
5492
return lowerToScalableOp(Op, DAG);
5487
5493
}
5488
5494
assert(Subtarget.hasVendorXTHeadBb() &&
0 commit comments