Skip to content

Commit c7dc3c3

Browse files
Dinar TemirbulatovDinar Temirbulatov
authored andcommitted
Resolved comments.
1 parent 3cd68b4 commit c7dc3c3

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26815,7 +26815,7 @@ static SDValue GenerateFixedLengthSVETBL(SDValue Op, SDValue Op1, SDValue Op2,
2681526815
SmallVector<SDValue, 8> TBLMask;
2681626816
// If MinSVESize is not equal to MaxSVESize then we need to know which
2681726817
// TBL mask element needs adjustment.
26818-
SmallVector<SDValue, 8> MulByVLMask;
26818+
SmallVector<SDValue, 8> AddRuntimeVLMask;
2681926819

2682026820
// Bail out for 8-bits element types, because with 2048-bit SVE register
2682126821
// size 8 bits is only sufficient to index into the first source vector.
@@ -26826,22 +26826,19 @@ static SDValue GenerateFixedLengthSVETBL(SDValue Op, SDValue Op1, SDValue Op2,
2682626826
// Handling poison index value.
2682726827
if (Index < 0)
2682826828
Index = 0;
26829-
// If we refer to the second operand then we have to add elements
26830-
// number in hardware register minus number of elements in a type in
26831-
// case if MinSVESize equals to MaxSVESize, otherwise just add normalized
26832-
// value and record this element in MulByVLMask to be adjusted in the
26833-
// runtime.
26829+
// If the mask refers to elements in the second operand, then we have to
26830+
// offset the index by the number of elements in a vector. If this is number
26831+
// is not known at compile-time, we need to maintain a mask with 'VL' values
26832+
// to add at runtime.
2683426833
if ((unsigned)Index >= ElementsPerVectorReg) {
26835-
if (!MinMaxEqual) {
26836-
Index = Index - ElementsPerVectorReg;
26837-
MulByVLMask.push_back(DAG.getConstant(1, DL, MVT::i64));
26838-
} else {
26834+
if (MinMaxEqual) {
2683926835
Index += IndexLen - ElementsPerVectorReg;
26836+
} else {
26837+
Index = Index - ElementsPerVectorReg;
26838+
AddRuntimeVLMask.push_back(DAG.getConstant(1, DL, MVT::i64));
2684026839
}
26841-
} else {
26842-
if (!MinMaxEqual)
26843-
MulByVLMask.push_back(DAG.getConstant(0, DL, MVT::i64));
26844-
}
26840+
} else if (!MinMaxEqual)
26841+
AddRuntimeVLMask.push_back(DAG.getConstant(0, DL, MVT::i64));
2684526842
// For 8-bit elements and 1024-bit SVE registers and MaxOffset equals
2684626843
// to 255, this might point to the last element of in the second operand
2684726844
// of the shufflevector, thus we are rejecting this transform.
@@ -26857,7 +26854,7 @@ static SDValue GenerateFixedLengthSVETBL(SDValue Op, SDValue Op1, SDValue Op2,
2685726854
for (unsigned i = 0; i < IndexLen - ElementsPerVectorReg; ++i) {
2685826855
TBLMask.push_back(DAG.getConstant((int)MaxOffset, DL, MVT::i64));
2685926856
if (!MinMaxEqual)
26860-
MulByVLMask.push_back(DAG.getConstant(0, DL, MVT::i64));
26857+
AddRuntimeVLMask.push_back(DAG.getConstant(0, DL, MVT::i64));
2686126858
}
2686226859

2686326860
EVT MaskContainerVT = getContainerForFixedLengthVector(DAG, MaskType);
@@ -26873,17 +26870,17 @@ static SDValue GenerateFixedLengthSVETBL(SDValue Op, SDValue Op1, SDValue Op2,
2687326870
Op1, SVEMask);
2687426871
else if (Subtarget.hasSVE2()) {
2687526872
if (!MinMaxEqual) {
26876-
SDValue VScale =
26877-
(BitsPerElt == 64)
26878-
? DAG.getVScale(DL, MVT::i64, APInt(64, 128 / BitsPerElt))
26879-
: DAG.getVScale(DL, MVT::i32, APInt(32, 128 / BitsPerElt));
26873+
unsigned MinNumElts = AArch64::SVEBitsPerBlock / BitsPerElt;
26874+
SDValue VScale = (BitsPerElt == 64)
26875+
? DAG.getVScale(DL, MVT::i64, APInt(64, MinNumElts))
26876+
: DAG.getVScale(DL, MVT::i32, APInt(32, MinNumElts));
2688026877
SDValue VecMask =
2688126878
DAG.getBuildVector(MaskType, DL, ArrayRef(TBLMask.data(), IndexLen));
2688226879
SDValue MulByMask = DAG.getNode(
2688326880
ISD::MUL, DL, MaskType,
2688426881
DAG.getNode(ISD::SPLAT_VECTOR, DL, MaskType, VScale),
2688526882
DAG.getBuildVector(MaskType, DL,
26886-
ArrayRef(MulByVLMask.data(), IndexLen)));
26883+
ArrayRef(AddRuntimeVLMask.data(), IndexLen)));
2688726884
SDValue UpdatedVecMask =
2688826885
DAG.getNode(ISD::ADD, DL, MaskType, VecMask, MulByMask);
2688926886
SVEMask = convertToScalableVector(

0 commit comments

Comments
 (0)