Skip to content

Commit 0783f5d

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 ddf1249 commit 0783f5d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4632,19 +4632,27 @@ 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

46384638
if (!IsXOROperand) {
46394639
SDValue Zero = CurDAG->getTargetConstant(0, DL, MVT::i64);
46404640
SDNode *MOV = CurDAG->getMachineNode(AArch64::MOVIv2d_ns, DL, VT, Zero);
46414641
SDValue MOVIV = SDValue(MOV, 0);
4642-
R1 = N1->getOperand(0);
4642+
4643+
SDValue Undef = SDValue(CurDAG->getMachineNode(TargetOpcode::IMPLICIT_DEF, DL, VT), 0);
4644+
R1 = CurDAG->getTargetInsertSubreg(AArch64::zsub, DL, VT, Undef, N1->getOperand(0));
4645+
4646+
// R1 = N1->getOperand(0);
46434647
R2 = MOVIV;
46444648
}
46454649

46464650
SDValue Ops[] = {R1, R2, Imm};
4647-
CurDAG->SelectNodeTo(N, AArch64::XAR, N0.getValueType(), Ops);
4651+
SDValue Xar = SDValue(CurDAG->SelectNodeTo(N, AArch64::XAR, N0.getValueType(), Ops), 0);
4652+
4653+
SDValue ExtractSubReg =
4654+
CurDAG->getTargetExtractSubreg(AArch64::zsub, DL, VT, Xar);
4655+
ReplaceUses(N1, ExtractSubReg);
46484656

46494657
return true;
46504658
}

0 commit comments

Comments
 (0)