Skip to content

Commit efff215

Browse files
committed
updates uses in VectorCombine
- use defined TTI
1 parent e00d02f commit efff215

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,7 +1950,7 @@ bool VectorCombine::foldShuffleOfIntrinsics(Instruction &I) {
19501950
return false;
19511951

19521952
for (unsigned I = 0, E = II0->arg_size(); I != E; ++I)
1953-
if (isVectorIntrinsicWithScalarOpAtArg(IID, I) &&
1953+
if (isVectorIntrinsicWithScalarOpAtArg(IID, I, &TTI) &&
19541954
II0->getArgOperand(I) != II1->getArgOperand(I))
19551955
return false;
19561956

@@ -1963,7 +1963,7 @@ bool VectorCombine::foldShuffleOfIntrinsics(Instruction &I) {
19631963
SmallVector<Type *> NewArgsTy;
19641964
InstructionCost NewCost = 0;
19651965
for (unsigned I = 0, E = II0->arg_size(); I != E; ++I)
1966-
if (isVectorIntrinsicWithScalarOpAtArg(IID, I)) {
1966+
if (isVectorIntrinsicWithScalarOpAtArg(IID, I, &TTI)) {
19671967
NewArgsTy.push_back(II0->getArgOperand(I)->getType());
19681968
} else {
19691969
auto *VecTy = cast<FixedVectorType>(II0->getArgOperand(I)->getType());
@@ -1984,7 +1984,7 @@ bool VectorCombine::foldShuffleOfIntrinsics(Instruction &I) {
19841984

19851985
SmallVector<Value *> NewArgs;
19861986
for (unsigned I = 0, E = II0->arg_size(); I != E; ++I)
1987-
if (isVectorIntrinsicWithScalarOpAtArg(IID, I)) {
1987+
if (isVectorIntrinsicWithScalarOpAtArg(IID, I, &TTI)) {
19881988
NewArgs.push_back(II0->getArgOperand(I));
19891989
} else {
19901990
Value *Shuf = Builder.CreateShuffleVector(II0->getArgOperand(I),
@@ -2075,7 +2075,8 @@ static Value *generateNewInstTree(ArrayRef<InstLane> Item, FixedVectorType *Ty,
20752075
const SmallPtrSet<Use *, 4> &IdentityLeafs,
20762076
const SmallPtrSet<Use *, 4> &SplatLeafs,
20772077
const SmallPtrSet<Use *, 4> &ConcatLeafs,
2078-
IRBuilder<> &Builder) {
2078+
IRBuilder<> &Builder,
2079+
const TargetTransformInfo *TTI) {
20792080
auto [FrontU, FrontLane] = Item.front();
20802081

20812082
if (IdentityLeafs.contains(FrontU)) {
@@ -2110,13 +2111,14 @@ static Value *generateNewInstTree(ArrayRef<InstLane> Item, FixedVectorType *Ty,
21102111
unsigned NumOps = I->getNumOperands() - (II ? 1 : 0);
21112112
SmallVector<Value *> Ops(NumOps);
21122113
for (unsigned Idx = 0; Idx < NumOps; Idx++) {
2113-
if (II && isVectorIntrinsicWithScalarOpAtArg(II->getIntrinsicID(), Idx)) {
2114+
if (II &&
2115+
isVectorIntrinsicWithScalarOpAtArg(II->getIntrinsicID(), Idx, TTI)) {
21142116
Ops[Idx] = II->getOperand(Idx);
21152117
continue;
21162118
}
2117-
Ops[Idx] =
2118-
generateNewInstTree(generateInstLaneVectorFromOperand(Item, Idx), Ty,
2119-
IdentityLeafs, SplatLeafs, ConcatLeafs, Builder);
2119+
Ops[Idx] = generateNewInstTree(generateInstLaneVectorFromOperand(Item, Idx),
2120+
Ty, IdentityLeafs, SplatLeafs, ConcatLeafs,
2121+
Builder, TTI);
21202122
}
21212123

21222124
SmallVector<Value *, 8> ValueList;
@@ -2288,7 +2290,8 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
22882290
II && isTriviallyVectorizable(II->getIntrinsicID()) &&
22892291
!II->hasOperandBundles()) {
22902292
for (unsigned Op = 0, E = II->getNumOperands() - 1; Op < E; Op++) {
2291-
if (isVectorIntrinsicWithScalarOpAtArg(II->getIntrinsicID(), Op)) {
2293+
if (isVectorIntrinsicWithScalarOpAtArg(II->getIntrinsicID(), Op,
2294+
&TTI)) {
22922295
if (!all_of(drop_begin(Item), [Item, Op](InstLane &IL) {
22932296
Value *FrontV = Item.front().first->get();
22942297
Use *U = IL.first;
@@ -2319,7 +2322,7 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
23192322
// removed. Scan through again and generate the new tree of instructions.
23202323
Builder.SetInsertPoint(&I);
23212324
Value *V = generateNewInstTree(Start, Ty, IdentityLeafs, SplatLeafs,
2322-
ConcatLeafs, Builder);
2325+
ConcatLeafs, Builder, &TTI);
23232326
replaceValue(I, *V);
23242327
return true;
23252328
}

0 commit comments

Comments
 (0)