@@ -1557,7 +1557,7 @@ bool VectorCombine::foldShuffleOfCastops(Instruction &I) {
15571557// of each lane. If we can simplify away the shuffles to identities then
15581558// do so.
15591559bool VectorCombine::foldShuffleToIdentity (Instruction &I) {
1560- FixedVectorType *Ty = dyn_cast<FixedVectorType>(I.getType ());
1560+ auto *Ty = dyn_cast<FixedVectorType>(I.getType ());
15611561 if (!Ty || !isa<Instruction>(I.getOperand (0 )) ||
15621562 !isa<Instruction>(I.getOperand (1 )))
15631563 return false ;
@@ -1570,7 +1570,7 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
15701570 cast<FixedVectorType>(SV->getOperand (0 )->getType ())->getNumElements ();
15711571 int M = SV->getMaskValue (Lane);
15721572 if (M < 0 )
1573- return {nullptr , - 1 };
1573+ return {nullptr , PoisonMaskElem };
15741574 else if (M < (int )NumElts) {
15751575 V = SV->getOperand (0 );
15761576 Lane = M;
@@ -1583,12 +1583,12 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
15831583 };
15841584
15851585 auto GenerateInstLaneVectorFromOperand =
1586- [&LookThroughShuffles](const SmallVector <InstLane> & Item, int Op) {
1586+ [&LookThroughShuffles](ArrayRef <InstLane> Item, int Op) {
15871587 SmallVector<InstLane> NItem;
15881588 for (InstLane V : Item) {
15891589 NItem.emplace_back (
15901590 !V.first
1591- ? InstLane{nullptr , - 1 }
1591+ ? InstLane{nullptr , PoisonMaskElem }
15921592 : LookThroughShuffles (
15931593 cast<Instruction>(V.first )->getOperand (Op), V.second ));
15941594 }
@@ -1636,8 +1636,7 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
16361636 if (!all_of (drop_begin (Item), [&](InstLane IL) {
16371637 if (!IL.first )
16381638 return true ;
1639- if (isa<Instruction>(IL.first ) &&
1640- !cast<Instruction>(IL.first )->hasOneUse ())
1639+ if (auto *I = dyn_cast<Instruction>(IL.first ); I && !I->hasOneUse ())
16411640 return false ;
16421641 return IL.first ->getValueID () == Item[0 ].first ->getValueID () &&
16431642 (!isa<IntrinsicInst>(IL.first ) ||
@@ -1659,8 +1658,8 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
16591658
16601659 // If we got this far, we know the shuffles are superfluous and can be
16611660 // removed. Scan through again and generate the new tree of instructions.
1662- std::function<Value *(const SmallVector <InstLane> & )> generate =
1663- [&](const SmallVector <InstLane> & Item) -> Value * {
1661+ std::function<Value *(ArrayRef <InstLane>)> generate =
1662+ [&](ArrayRef <InstLane> Item) -> Value * {
16641663 if (IdentityLeafs.contains (Item[0 ].first ) &&
16651664 all_of (drop_begin (enumerate(Item)), [&](const auto &E) {
16661665 return !E.value ().first || (E.value ().first == Item[0 ].first &&
0 commit comments