Skip to content

Commit

Permalink
[LV] Add a getRecurrenceBinOp and make use of it. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
davemgreen committed Oct 15, 2020
1 parent 17dcf85 commit 13ec3dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion llvm/include/llvm/Analysis/IVDescriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ class RecurrenceDescriptor {

RecurrenceKind getRecurrenceKind() const { return Kind; }

unsigned getRecurrenceBinOp() const {
return getRecurrenceBinOp(getRecurrenceKind());
}

MinMaxRecurrenceKind getMinMaxRecurrenceKind() const { return MinMaxKind; }

FastMathFlags getFastMathFlags() const { return FMF; }
Expand Down Expand Up @@ -219,7 +223,7 @@ class RecurrenceDescriptor {
const SmallPtrSet<Instruction *, 8> &getCastInsts() const { return CastInsts; }

/// Returns true if all source operands of the recurrence are SExtInsts.
bool isSigned() const{ return IsSigned; }
bool isSigned() const { return IsSigned; }

/// Attempts to find a chain of operations from Phi to LoopExitInst that can
/// be treated as a set of reductions instructions for in-loop reductions.
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4019,8 +4019,8 @@ void InnerLoopVectorizer::fixReduction(PHINode *Phi) {
RecurrenceDescriptor RdxDesc = Legal->getReductionVars()[Phi];
if (PreferPredicatedReductionSelect ||
TTI->preferPredicatedReductionSelect(
RdxDesc.getRecurrenceBinOp(RdxDesc.getRecurrenceKind()),
Phi->getType(), TargetTransformInfo::ReductionFlags())) {
RdxDesc.getRecurrenceBinOp(), Phi->getType(),
TargetTransformInfo::ReductionFlags())) {
auto *VecRdxPhi = cast<PHINode>(getOrCreateVectorValue(Phi, Part));
VecRdxPhi->setIncomingValueForBlock(
LI->getLoopFor(LoopVectorBody)->getLoopLatch(), Sel);
Expand Down Expand Up @@ -6901,7 +6901,7 @@ void LoopVectorizationCostModel::collectInLoopReductions() {

// If the target would prefer this reduction to happen "in-loop", then we
// want to record it as such.
unsigned Opcode = RdxDesc.getRecurrenceBinOp(RdxDesc.getRecurrenceKind());
unsigned Opcode = RdxDesc.getRecurrenceBinOp();
if (!PreferInLoopReductions &&
!TTI.preferInLoopReduction(Opcode, Phi->getType(),
TargetTransformInfo::ReductionFlags()))
Expand Down

0 comments on commit 13ec3dd

Please sign in to comment.