28
28
#include " llvm/IR/Dominators.h"
29
29
#include " llvm/IR/Function.h"
30
30
#include " llvm/IR/IRBuilder.h"
31
+ #include " llvm/IR/Instructions.h"
31
32
#include " llvm/IR/PatternMatch.h"
32
33
#include " llvm/Support/CommandLine.h"
33
34
#include " llvm/Transforms/Utils/Local.h"
@@ -3506,7 +3507,7 @@ bool VectorCombine::shrinkLoadForShuffles(Instruction &I) {
3506
3507
using IndexRange = std::pair<int , int >;
3507
3508
auto GetIndexRangeInShuffles = [&]() -> std::optional<IndexRange> {
3508
3509
IndexRange OutputRange = IndexRange (OldNumElements, -1 );
3509
- for (auto &Use : I.uses ()) {
3510
+ for (llvm::Use &Use : I.uses ()) {
3510
3511
// Ensure all uses match the required pattern.
3511
3512
User *Shuffle = Use.getUser ();
3512
3513
ArrayRef<int > Mask;
@@ -3535,13 +3536,13 @@ bool VectorCombine::shrinkLoadForShuffles(Instruction &I) {
3535
3536
};
3536
3537
3537
3538
// Get the range of vector elements used by shufflevector instructions.
3538
- if (auto Indices = GetIndexRangeInShuffles ()) {
3539
+ if (std::optional<IndexRange> Indices = GetIndexRangeInShuffles ()) {
3539
3540
unsigned const NewNumElements = Indices->second + 1u ;
3540
3541
3541
3542
// If the range of vector elements is smaller than the full load, attempt
3542
3543
// to create a smaller load.
3543
3544
if (NewNumElements < OldNumElements) {
3544
- auto Builder = IRBuilder (&I);
3545
+ IRBuilder Builder (&I);
3545
3546
Builder.SetCurrentDebugLocation (I.getDebugLoc ());
3546
3547
3547
3548
// Calculate costs of old and new ops.
@@ -3557,17 +3558,17 @@ bool VectorCombine::shrinkLoadForShuffles(Instruction &I) {
3557
3558
OldLoad->getPointerAddressSpace (), CostKind);
3558
3559
3559
3560
using UseEntry = std::pair<ShuffleVectorInst *, std::vector<int >>;
3560
- auto NewUses = SmallVector<UseEntry, 4u >() ;
3561
- auto SizeDiff = OldNumElements - NewNumElements;
3561
+ SmallVector<UseEntry, 4u > NewUses ;
3562
+ unsigned const SizeDiff = OldNumElements - NewNumElements;
3562
3563
3563
- for (auto &Use : I.uses ()) {
3564
+ for (llvm::Use &Use : I.uses ()) {
3564
3565
auto *Shuffle = cast<ShuffleVectorInst>(Use.getUser ());
3565
- auto OldMask = Shuffle->getShuffleMask ();
3566
+ ArrayRef< int > OldMask = Shuffle->getShuffleMask ();
3566
3567
3567
3568
// Create entry for new use.
3568
3569
NewUses.push_back ({Shuffle, {}});
3569
- auto &NewMask = NewUses.back ().second ;
3570
- for (auto Index : OldMask)
3570
+ std::vector< int > &NewMask = NewUses.back ().second ;
3571
+ for (int Index : OldMask)
3571
3572
NewMask.push_back (Index >= static_cast <int >(OldNumElements)
3572
3573
? Index - SizeDiff
3573
3574
: Index);
@@ -3588,13 +3589,13 @@ bool VectorCombine::shrinkLoadForShuffles(Instruction &I) {
3588
3589
NewLoad->copyMetadata (I);
3589
3590
3590
3591
// Replace all uses.
3591
- for (auto &Use : NewUses) {
3592
- auto *Shuffle = Use.first ;
3593
- auto &NewMask = Use.second ;
3592
+ for (UseEntry &Use : NewUses) {
3593
+ ShuffleVectorInst *Shuffle = Use.first ;
3594
+ std::vector< int > &NewMask = Use.second ;
3594
3595
3595
3596
Builder.SetInsertPoint (Shuffle);
3596
3597
Builder.SetCurrentDebugLocation (Shuffle->getDebugLoc ());
3597
- auto *NewShuffle = Builder.CreateShuffleVector (
3598
+ Value *NewShuffle = Builder.CreateShuffleVector (
3598
3599
NewLoad, PoisonValue::get (NewLoadTy), NewMask);
3599
3600
3600
3601
replaceValue (*Shuffle, *NewShuffle);
0 commit comments