Skip to content

Commit 64b4bde

Browse files
committed
Address comments and fix failing test
1 parent a109326 commit 64b4bde

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,7 @@ bool VectorCombine::foldShuffleOfCastops(Instruction &I) {
15521552
// of each lane. If we can simplify away the shuffles to identities then
15531553
// do so.
15541554
bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
1555-
FixedVectorType *Ty = dyn_cast<FixedVectorType>(I.getType());
1555+
auto *Ty = dyn_cast<FixedVectorType>(I.getType());
15561556
if (!Ty || !isa<Instruction>(I.getOperand(0)) ||
15571557
!isa<Instruction>(I.getOperand(1)))
15581558
return false;
@@ -1565,7 +1565,7 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
15651565
cast<FixedVectorType>(SV->getOperand(0)->getType())->getNumElements();
15661566
int M = SV->getMaskValue(Lane);
15671567
if (M < 0)
1568-
return {nullptr, -1};
1568+
return {nullptr, PoisonMaskElem};
15691569
else if (M < (int)NumElts) {
15701570
V = SV->getOperand(0);
15711571
Lane = M;
@@ -1578,12 +1578,12 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
15781578
};
15791579

15801580
auto GenerateInstLaneVectorFromOperand =
1581-
[&LookThroughShuffles](const SmallVector<InstLane> &Item, int Op) {
1581+
[&LookThroughShuffles](ArrayRef<InstLane> Item, int Op) {
15821582
SmallVector<InstLane> NItem;
15831583
for (InstLane V : Item) {
15841584
NItem.emplace_back(
15851585
!V.first
1586-
? InstLane{nullptr, -1}
1586+
? InstLane{nullptr, PoisonMaskElem}
15871587
: LookThroughShuffles(
15881588
cast<Instruction>(V.first)->getOperand(Op), V.second));
15891589
}
@@ -1631,8 +1631,7 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
16311631
if (!all_of(drop_begin(Item), [&](InstLane IL) {
16321632
if (!IL.first)
16331633
return true;
1634-
if (isa<Instruction>(IL.first) &&
1635-
!cast<Instruction>(IL.first)->hasOneUse())
1634+
if (auto *I = dyn_cast<Instruction>(IL.first); I && !I->hasOneUse())
16361635
return false;
16371636
return IL.first->getValueID() == Item[0].first->getValueID() &&
16381637
(!isa<IntrinsicInst>(IL.first) ||
@@ -1654,8 +1653,8 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
16541653

16551654
// If we got this far, we know the shuffles are superfluous and can be
16561655
// removed. Scan through again and generate the new tree of instructions.
1657-
std::function<Value *(const SmallVector<InstLane> &)> generate =
1658-
[&](const SmallVector<InstLane> &Item) -> Value * {
1656+
std::function<Value *(ArrayRef<InstLane>)> generate =
1657+
[&](ArrayRef<InstLane> Item) -> Value * {
16591658
if (IdentityLeafs.contains(Item[0].first) &&
16601659
all_of(drop_begin(enumerate(Item)), [&](const auto &E) {
16611660
return !E.value().first || (E.value().first == Item[0].first &&

0 commit comments

Comments
 (0)