Skip to content

Commit 8b54dbe

Browse files
authored
[AArch64] Ensure the type of LDNP/STNP is always v2i64 (#150378)
I think this is OK, that we always use v2i64 for the type of a LDNP/STNP nodes. Bitcasting the type should be fine for little endian. This helps with #150125.
1 parent b8cc462 commit 8b54dbe

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6814,7 +6814,8 @@ SDValue AArch64TargetLowering::LowerSTORE(SDValue Op,
68146814
DAG.getConstant(EC.getKnownMinValue() / 2, Dl, MVT::i64));
68156815
SDValue Result = DAG.getMemIntrinsicNode(
68166816
AArch64ISD::STNP, Dl, DAG.getVTList(MVT::Other),
6817-
{StoreNode->getChain(), Lo, Hi, StoreNode->getBasePtr()},
6817+
{StoreNode->getChain(), DAG.getBitcast(MVT::v2i64, Lo),
6818+
DAG.getBitcast(MVT::v2i64, Hi), StoreNode->getBasePtr()},
68186819
StoreNode->getMemoryVT(), StoreNode->getMemOperand());
68196820
return Result;
68206821
}
@@ -27911,16 +27912,16 @@ void AArch64TargetLowering::ReplaceNodeResults(
2791127912
MemVT.getScalarSizeInBits() == 32u ||
2791227913
MemVT.getScalarSizeInBits() == 64u)) {
2791327914

27915+
EVT HalfVT = MemVT.getHalfNumVectorElementsVT(*DAG.getContext());
2791427916
SDValue Result = DAG.getMemIntrinsicNode(
2791527917
AArch64ISD::LDNP, SDLoc(N),
27916-
DAG.getVTList({MemVT.getHalfNumVectorElementsVT(*DAG.getContext()),
27917-
MemVT.getHalfNumVectorElementsVT(*DAG.getContext()),
27918-
MVT::Other}),
27918+
DAG.getVTList({MVT::v2i64, MVT::v2i64, MVT::Other}),
2791927919
{LoadNode->getChain(), LoadNode->getBasePtr()},
2792027920
LoadNode->getMemoryVT(), LoadNode->getMemOperand());
2792127921

2792227922
SDValue Pair = DAG.getNode(ISD::CONCAT_VECTORS, SDLoc(N), MemVT,
27923-
Result.getValue(0), Result.getValue(1));
27923+
DAG.getBitcast(HalfVT, Result.getValue(0)),
27924+
DAG.getBitcast(HalfVT, Result.getValue(1)));
2792427925
Results.append({Pair, Result.getValue(2) /* Chain */});
2792527926
return;
2792627927
}

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,10 @@ def SDT_AArch64uaddlp : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVec<1>]>;
519519

520520
def SDT_AArch64ldp : SDTypeProfile<2, 1, [SDTCisVT<0, i64>, SDTCisSameAs<0, 1>, SDTCisPtrTy<2>]>;
521521
def SDT_AArch64ldiapp : SDTypeProfile<2, 1, [SDTCisVT<0, i64>, SDTCisSameAs<0, 1>, SDTCisPtrTy<2>]>;
522-
def SDT_AArch64ldnp : SDTypeProfile<2, 1, [SDTCisVT<0, v4i32>, SDTCisSameAs<0, 1>, SDTCisPtrTy<2>]>;
522+
def SDT_AArch64ldnp : SDTypeProfile<2, 1, [SDTCisVT<0, v2i64>, SDTCisSameAs<0, 1>, SDTCisPtrTy<2>]>;
523523
def SDT_AArch64stp : SDTypeProfile<0, 3, [SDTCisVT<0, i64>, SDTCisSameAs<0, 1>, SDTCisPtrTy<2>]>;
524524
def SDT_AArch64stilp : SDTypeProfile<0, 3, [SDTCisVT<0, i64>, SDTCisSameAs<0, 1>, SDTCisPtrTy<2>]>;
525-
def SDT_AArch64stnp : SDTypeProfile<0, 3, [SDTCisVT<0, v4i32>, SDTCisSameAs<0, 1>, SDTCisPtrTy<2>]>;
525+
def SDT_AArch64stnp : SDTypeProfile<0, 3, [SDTCisVT<0, v2i64>, SDTCisSameAs<0, 1>, SDTCisPtrTy<2>]>;
526526

527527
// Generates the general dynamic sequences, i.e.
528528
// adrp x0, :tlsdesc:var

0 commit comments

Comments
 (0)