Skip to content

Commit ef88a52

Browse files
nilanjana87fhahn
authored andcommitted
[AArch64] Minor changes and sanity checks in relation to https://reviews.llvm.org/D135229
(cherry picked from commit 7958682)
1 parent 14e9fe7 commit ef88a52

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13752,8 +13752,12 @@ static void createTblForTrunc(TruncInst *TI, bool IsLittleEndian) {
1375213752
"Unsupported destination vector element type");
1375313753
unsigned SrcElemTySz =
1375413754
cast<IntegerType>(SrcTy->getElementType())->getBitWidth();
13755-
unsigned TruncFactor =
13756-
SrcElemTySz / cast<IntegerType>(DstTy->getElementType())->getBitWidth();
13755+
unsigned DstElemTySz =
13756+
cast<IntegerType>(DstTy->getElementType())->getBitWidth();
13757+
assert((SrcElemTySz % DstElemTySz == 0) &&
13758+
"Cannot lower truncate to tbl instructions for a source element size "
13759+
"that is not divisible by the destination element size");
13760+
unsigned TruncFactor = SrcElemTySz / DstElemTySz;
1375713761
assert((SrcElemTySz == 16 || SrcElemTySz == 32 || SrcElemTySz == 64) &&
1375813762
"Unsupported source vector element type size");
1375913763
Type *VecTy = FixedVectorType::get(Builder.getInt8Ty(), 16);
@@ -13765,12 +13769,11 @@ static void createTblForTrunc(TruncInst *TI, bool IsLittleEndian) {
1376513769
SmallVector<Constant *, 16> MaskConst;
1376613770
for (int Itr = 0; Itr < 16; Itr++) {
1376713771
if (Itr < NumElements)
13768-
MaskConst.push_back(ConstantInt::get(
13769-
Builder.getInt8Ty(), IsLittleEndian
13770-
? Itr * TruncFactor
13771-
: Itr * TruncFactor + (TruncFactor - 1)));
13772+
MaskConst.push_back(Builder.getInt8(
13773+
IsLittleEndian ? Itr * TruncFactor
13774+
: Itr * TruncFactor + (TruncFactor - 1)));
1377213775
else
13773-
MaskConst.push_back(ConstantInt::get(Builder.getInt8Ty(), 255));
13776+
MaskConst.push_back(Builder.getInt8(255));
1377413777
}
1377513778

1377613779
int MaxTblSz = 128 * 4;
@@ -13793,7 +13796,7 @@ static void createTblForTrunc(TruncInst *TI, bool IsLittleEndian) {
1379313796
Parts.push_back(Builder.CreateBitCast(
1379413797
Builder.CreateShuffleVector(TI->getOperand(0), ShuffleLanes), VecTy));
1379513798

13796-
if (Parts.size() >= 4) {
13799+
if (Parts.size() == 4) {
1379713800
auto *F = Intrinsic::getDeclaration(TI->getModule(),
1379813801
Intrinsic::aarch64_neon_tbl4, VecTy);
1379913802
Parts.push_back(ConstantVector::get(MaskConst));

0 commit comments

Comments
 (0)