Skip to content

Commit 5f458a2

Browse files
committed
[AArch64] Extend usage of XAR instruction for fixed-length operations
Resolves #139229 In #137162, support for `v2i64` was implemented for vector rotate transformation, although types like `v4i32`, `v8i16` and `v16i8` do not have Neon SHA3, we can use SVE operations if sve2-sha3 is available.
1 parent f9f2bf8 commit 5f458a2

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4632,18 +4632,38 @@ bool AArch64DAGToDAGISel::trySelectXAR(SDNode *N) {
46324632
SDValue Imm = CurDAG->getTargetConstant(
46334633
ShAmt, DL, N0.getOperand(1).getValueType(), false);
46344634

4635-
if (ShAmt + HsAmt != 64)
4635+
if (ShAmt + HsAmt != VT.getScalarSizeInBits())
46364636
return false;
46374637

4638+
bool UseSVE2Instr = false;
46384639
if (!IsXOROperand) {
4640+
if (VT.getVectorElementType() != MVT::i64 && Subtarget->hasSVE2())
4641+
UseSVE2Instr = true;
4642+
46394643
SDValue Zero = CurDAG->getTargetConstant(0, DL, MVT::i64);
46404644
SDNode *MOV = CurDAG->getMachineNode(AArch64::MOVIv2d_ns, DL, VT, Zero);
46414645
SDValue MOVIV = SDValue(MOV, 0);
4646+
46424647
R1 = N1->getOperand(0);
4643-
R2 = MOVIV;
4648+
if (UseSVE2Instr) {
4649+
SDValue ZSub = CurDAG->getTargetConstant(AArch64::zsub, DL, MVT::i32);
4650+
SDNode *SubRegToReg = CurDAG->getMachineNode(AArch64::SUBREG_TO_REG, DL,
4651+
VT, Zero, MOVIV, ZSub);
4652+
R2 = SDValue(SubRegToReg, 0);
4653+
} else {
4654+
R2 = MOVIV;
4655+
}
46444656
}
46454657

46464658
SDValue Ops[] = {R1, R2, Imm};
4659+
if (UseSVE2Instr) {
4660+
if (auto Opc = SelectOpcodeFromVT<SelectTypeKind::Int>(
4661+
VT, {AArch64::XAR_ZZZI_B, AArch64::XAR_ZZZI_H, AArch64::XAR_ZZZI_S,
4662+
AArch64::XAR_ZZZI_D})) {
4663+
CurDAG->SelectNodeTo(N, Opc, VT, Ops);
4664+
return true;
4665+
}
4666+
}
46474667
CurDAG->SelectNodeTo(N, AArch64::XAR, N0.getValueType(), Ops);
46484668

46494669
return true;

0 commit comments

Comments
 (0)