@@ -6653,22 +6653,19 @@ class HorizontalReduction {
6653
6653
6654
6654
// / Attempt to vectorize the tree found by
6655
6655
// / matchAssociativeReduction.
6656
- bool tryToReduce (BoUpSLP &V, TargetTransformInfo *TTI, bool Try2WayRdx ) {
6656
+ bool tryToReduce (BoUpSLP &V, TargetTransformInfo *TTI) {
6657
6657
if (ReducedVals.empty ())
6658
6658
return false ;
6659
6659
6660
6660
// If there is a sufficient number of reduction values, reduce
6661
6661
// to a nearby power-of-2. Can safely generate oversized
6662
6662
// vectors and rely on the backend to split them to legal sizes.
6663
6663
unsigned NumReducedVals = ReducedVals.size ();
6664
- if (Try2WayRdx && NumReducedVals != 2 )
6665
- return false ;
6666
- unsigned MinRdxVals = Try2WayRdx ? 2 : 4 ;
6667
- if (NumReducedVals < MinRdxVals)
6664
+ if (NumReducedVals < 4 )
6668
6665
return false ;
6669
6666
6670
6667
unsigned ReduxWidth = PowerOf2Floor (NumReducedVals);
6671
- unsigned MinRdxWidth = Log2_32 (MinRdxVals);
6668
+
6672
6669
Value *VectorizedTree = nullptr ;
6673
6670
6674
6671
// FIXME: Fast-math-flags should be set based on the instructions in the
@@ -6704,7 +6701,7 @@ class HorizontalReduction {
6704
6701
SmallVector<Value *, 16 > IgnoreList;
6705
6702
for (auto &V : ReductionOps)
6706
6703
IgnoreList.append (V.begin (), V.end ());
6707
- while (i < NumReducedVals - ReduxWidth + 1 && ReduxWidth > MinRdxWidth ) {
6704
+ while (i < NumReducedVals - ReduxWidth + 1 && ReduxWidth > 2 ) {
6708
6705
auto VL = makeArrayRef (&ReducedVals[i], ReduxWidth);
6709
6706
V.buildTree (VL, ExternallyUsedValues, IgnoreList);
6710
6707
Optional<ArrayRef<unsigned >> Order = V.bestOrder ();
@@ -7048,7 +7045,7 @@ static Value *getReductionValue(const DominatorTree *DT, PHINode *P,
7048
7045
// / performed.
7049
7046
static bool tryToVectorizeHorReductionOrInstOperands (
7050
7047
PHINode *P, Instruction *Root, BasicBlock *BB, BoUpSLP &R,
7051
- TargetTransformInfo *TTI, bool Try2WayRdx,
7048
+ TargetTransformInfo *TTI,
7052
7049
const function_ref<bool (Instruction *, BoUpSLP &)> Vectorize) {
7053
7050
if (!ShouldVectorizeHor)
7054
7051
return false ;
@@ -7079,7 +7076,7 @@ static bool tryToVectorizeHorReductionOrInstOperands(
7079
7076
if (BI || SI) {
7080
7077
HorizontalReduction HorRdx;
7081
7078
if (HorRdx.matchAssociativeReduction (P, Inst)) {
7082
- if (HorRdx.tryToReduce (R, TTI, Try2WayRdx )) {
7079
+ if (HorRdx.tryToReduce (R, TTI)) {
7083
7080
Res = true ;
7084
7081
// Set P to nullptr to avoid re-analysis of phi node in
7085
7082
// matchAssociativeReduction function unless this is the root node.
@@ -7122,8 +7119,7 @@ static bool tryToVectorizeHorReductionOrInstOperands(
7122
7119
7123
7120
bool SLPVectorizerPass::vectorizeRootInstruction (PHINode *P, Value *V,
7124
7121
BasicBlock *BB, BoUpSLP &R,
7125
- TargetTransformInfo *TTI,
7126
- bool Try2WayRdx) {
7122
+ TargetTransformInfo *TTI) {
7127
7123
if (!V)
7128
7124
return false ;
7129
7125
auto *I = dyn_cast<Instruction>(V);
@@ -7136,7 +7132,7 @@ bool SLPVectorizerPass::vectorizeRootInstruction(PHINode *P, Value *V,
7136
7132
auto &&ExtraVectorization = [this ](Instruction *I, BoUpSLP &R) -> bool {
7137
7133
return tryToVectorize (I, R);
7138
7134
};
7139
- return tryToVectorizeHorReductionOrInstOperands (P, I, BB, R, TTI, Try2WayRdx,
7135
+ return tryToVectorizeHorReductionOrInstOperands (P, I, BB, R, TTI,
7140
7136
ExtraVectorization);
7141
7137
}
7142
7138
@@ -7332,23 +7328,6 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
7332
7328
PostProcessInstructions.push_back (&*it);
7333
7329
}
7334
7330
7335
- // Make a final attempt to match a 2-way reduction if nothing else worked.
7336
- // We do not try this above because it may interfere with other vectorization
7337
- // attempts.
7338
- // TODO: The constraints are copied from the above call to
7339
- // vectorizeRootInstruction(), but that might be too restrictive?
7340
- BasicBlock::iterator LastInst = --BB->end ();
7341
- if (!Changed && LastInst->use_empty () &&
7342
- (LastInst->getType ()->isVoidTy () || isa<CallInst>(LastInst) ||
7343
- isa<InvokeInst>(LastInst))) {
7344
- if (ShouldStartVectorizeHorAtStore || !isa<StoreInst>(LastInst)) {
7345
- for (auto *V : LastInst->operand_values ()) {
7346
- Changed |= vectorizeRootInstruction (nullptr , V, BB, R, TTI,
7347
- /* Try2WayRdx */ true );
7348
- }
7349
- }
7350
- }
7351
-
7352
7331
return Changed;
7353
7332
}
7354
7333
0 commit comments