30
30
#include " llvm/IR/Dominators.h"
31
31
#include " llvm/IR/Function.h"
32
32
#include " llvm/IR/IRBuilder.h"
33
+ #include " llvm/IR/Instructions.h"
33
34
#include " llvm/IR/PatternMatch.h"
34
35
#include " llvm/Support/CommandLine.h"
35
36
#include " llvm/Transforms/Utils/Local.h"
@@ -3714,7 +3715,7 @@ bool VectorCombine::shrinkLoadForShuffles(Instruction &I) {
3714
3715
using IndexRange = std::pair<int , int >;
3715
3716
auto GetIndexRangeInShuffles = [&]() -> std::optional<IndexRange> {
3716
3717
IndexRange OutputRange = IndexRange (OldNumElements, -1 );
3717
- for (auto &Use : I.uses ()) {
3718
+ for (llvm::Use &Use : I.uses ()) {
3718
3719
// Ensure all uses match the required pattern.
3719
3720
User *Shuffle = Use.getUser ();
3720
3721
ArrayRef<int > Mask;
@@ -3743,13 +3744,13 @@ bool VectorCombine::shrinkLoadForShuffles(Instruction &I) {
3743
3744
};
3744
3745
3745
3746
// Get the range of vector elements used by shufflevector instructions.
3746
- if (auto Indices = GetIndexRangeInShuffles ()) {
3747
+ if (std::optional<IndexRange> Indices = GetIndexRangeInShuffles ()) {
3747
3748
unsigned const NewNumElements = Indices->second + 1u ;
3748
3749
3749
3750
// If the range of vector elements is smaller than the full load, attempt
3750
3751
// to create a smaller load.
3751
3752
if (NewNumElements < OldNumElements) {
3752
- auto Builder = IRBuilder (&I);
3753
+ IRBuilder Builder (&I);
3753
3754
Builder.SetCurrentDebugLocation (I.getDebugLoc ());
3754
3755
3755
3756
// Calculate costs of old and new ops.
@@ -3765,17 +3766,17 @@ bool VectorCombine::shrinkLoadForShuffles(Instruction &I) {
3765
3766
OldLoad->getPointerAddressSpace (), CostKind);
3766
3767
3767
3768
using UseEntry = std::pair<ShuffleVectorInst *, std::vector<int >>;
3768
- auto NewUses = SmallVector<UseEntry, 4u >() ;
3769
- auto SizeDiff = OldNumElements - NewNumElements;
3769
+ SmallVector<UseEntry, 4u > NewUses ;
3770
+ unsigned const SizeDiff = OldNumElements - NewNumElements;
3770
3771
3771
- for (auto &Use : I.uses ()) {
3772
+ for (llvm::Use &Use : I.uses ()) {
3772
3773
auto *Shuffle = cast<ShuffleVectorInst>(Use.getUser ());
3773
- auto OldMask = Shuffle->getShuffleMask ();
3774
+ ArrayRef< int > OldMask = Shuffle->getShuffleMask ();
3774
3775
3775
3776
// Create entry for new use.
3776
3777
NewUses.push_back ({Shuffle, {}});
3777
- auto &NewMask = NewUses.back ().second ;
3778
- for (auto Index : OldMask)
3778
+ std::vector< int > &NewMask = NewUses.back ().second ;
3779
+ for (int Index : OldMask)
3779
3780
NewMask.push_back (Index >= static_cast <int >(OldNumElements)
3780
3781
? Index - SizeDiff
3781
3782
: Index);
@@ -3796,13 +3797,13 @@ bool VectorCombine::shrinkLoadForShuffles(Instruction &I) {
3796
3797
NewLoad->copyMetadata (I);
3797
3798
3798
3799
// Replace all uses.
3799
- for (auto &Use : NewUses) {
3800
- auto *Shuffle = Use.first ;
3801
- auto &NewMask = Use.second ;
3800
+ for (UseEntry &Use : NewUses) {
3801
+ ShuffleVectorInst *Shuffle = Use.first ;
3802
+ std::vector< int > &NewMask = Use.second ;
3802
3803
3803
3804
Builder.SetInsertPoint (Shuffle);
3804
3805
Builder.SetCurrentDebugLocation (Shuffle->getDebugLoc ());
3805
- auto *NewShuffle = Builder.CreateShuffleVector (
3806
+ Value *NewShuffle = Builder.CreateShuffleVector (
3806
3807
NewLoad, PoisonValue::get (NewLoadTy), NewMask);
3807
3808
3808
3809
replaceValue (*Shuffle, *NewShuffle);
0 commit comments