@@ -1672,7 +1672,7 @@ bool VectorCombine::foldShuffleOfShuffles(Instruction &I) {
16721672// of each lane. If we can simplify away the shuffles to identities then
16731673// do so.
16741674bool VectorCombine::foldShuffleToIdentity (Instruction &I) {
1675- FixedVectorType *Ty = dyn_cast<FixedVectorType>(I.getType ());
1675+ auto *Ty = dyn_cast<FixedVectorType>(I.getType ());
16761676 if (!Ty || !isa<Instruction>(I.getOperand (0 )) ||
16771677 !isa<Instruction>(I.getOperand (1 )))
16781678 return false ;
@@ -1685,7 +1685,7 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
16851685 cast<FixedVectorType>(SV->getOperand (0 )->getType ())->getNumElements ();
16861686 int M = SV->getMaskValue (Lane);
16871687 if (M < 0 )
1688- return {nullptr , - 1 };
1688+ return {nullptr , PoisonMaskElem };
16891689 else if (M < (int )NumElts) {
16901690 V = SV->getOperand (0 );
16911691 Lane = M;
@@ -1698,12 +1698,12 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
16981698 };
16991699
17001700 auto GenerateInstLaneVectorFromOperand =
1701- [&LookThroughShuffles](const SmallVector <InstLane> & Item, int Op) {
1701+ [&LookThroughShuffles](ArrayRef <InstLane> Item, int Op) {
17021702 SmallVector<InstLane> NItem;
17031703 for (InstLane V : Item) {
17041704 NItem.emplace_back (
17051705 !V.first
1706- ? InstLane{nullptr , - 1 }
1706+ ? InstLane{nullptr , PoisonMaskElem }
17071707 : LookThroughShuffles (
17081708 cast<Instruction>(V.first )->getOperand (Op), V.second ));
17091709 }
@@ -1751,8 +1751,7 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
17511751 if (!all_of (drop_begin (Item), [&](InstLane IL) {
17521752 if (!IL.first )
17531753 return true ;
1754- if (isa<Instruction>(IL.first ) &&
1755- !cast<Instruction>(IL.first )->hasOneUse ())
1754+ if (auto *I = dyn_cast<Instruction>(IL.first ); I && !I->hasOneUse ())
17561755 return false ;
17571756 return IL.first ->getValueID () == Item[0 ].first ->getValueID () &&
17581757 (!isa<IntrinsicInst>(IL.first ) ||
@@ -1774,8 +1773,8 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
17741773
17751774 // If we got this far, we know the shuffles are superfluous and can be
17761775 // removed. Scan through again and generate the new tree of instructions.
1777- std::function<Value *(const SmallVector <InstLane> & )> generate =
1778- [&](const SmallVector <InstLane> & Item) -> Value * {
1776+ std::function<Value *(ArrayRef <InstLane>)> generate =
1777+ [&](ArrayRef <InstLane> Item) -> Value * {
17791778 if (IdentityLeafs.contains (Item[0 ].first ) &&
17801779 all_of (drop_begin (enumerate(Item)), [&](const auto &E) {
17811780 return !E.value ().first || (E.value ().first == Item[0 ].first &&
0 commit comments