Skip to content

Commit

Permalink
[recurrence] Delete dead flag/fmf handling [NFC]
Browse files Browse the repository at this point in the history
The recurrence lowering code has handling which claims to be about flag intersection, but all the callers pass empty arrays to the arguments.  The sole exception is a caller of a method which has the argument, but no implementation.

I don't know what the intent was here, but it certaintly doesn't actually do anything today.
  • Loading branch information
preames committed Dec 9, 2021
1 parent d71775c commit b24db85
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
9 changes: 3 additions & 6 deletions llvm/include/llvm/Transforms/Utils/LoopUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,12 @@ Value *createMinMaxOp(IRBuilderBase &Builder, RecurKind RK, Value *Left,

/// Generates an ordered vector reduction using extracts to reduce the value.
Value *getOrderedReduction(IRBuilderBase &Builder, Value *Acc, Value *Src,
unsigned Op, RecurKind MinMaxKind = RecurKind::None,
ArrayRef<Value *> RedOps = None);
unsigned Op, RecurKind MinMaxKind = RecurKind::None);

/// Generates a vector reduction using shufflevectors to reduce the value.
/// Fast-math-flags are propagated using the IRBuilder's setting.
Value *getShuffleReduction(IRBuilderBase &Builder, Value *Src, unsigned Op,
RecurKind MinMaxKind = RecurKind::None,
ArrayRef<Value *> RedOps = None);
RecurKind MinMaxKind = RecurKind::None);

/// Create a target reduction of the given vector. The reduction operation
/// is described by the \p Opcode parameter. min/max reductions require
Expand All @@ -384,8 +382,7 @@ Value *getShuffleReduction(IRBuilderBase &Builder, Value *Src, unsigned Op,
/// Fast-math-flags are propagated using the IRBuilder's setting.
Value *createSimpleTargetReduction(IRBuilderBase &B,
const TargetTransformInfo *TTI, Value *Src,
RecurKind RdxKind,
ArrayRef<Value *> RedOps = None);
RecurKind RdxKind);

/// Create a target reduction of the given vector \p Src for a reduction of the
/// kind RecurKind::SelectICmp or RecurKind::SelectFCmp. The reduction operation
Expand Down
14 changes: 3 additions & 11 deletions llvm/lib/Transforms/Utils/LoopUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,7 @@ Value *llvm::createMinMaxOp(IRBuilderBase &Builder, RecurKind RK, Value *Left,

// Helper to generate an ordered reduction.
Value *llvm::getOrderedReduction(IRBuilderBase &Builder, Value *Acc, Value *Src,
unsigned Op, RecurKind RdxKind,
ArrayRef<Value *> RedOps) {
unsigned Op, RecurKind RdxKind) {
unsigned VF = cast<FixedVectorType>(Src->getType())->getNumElements();

// Extract and apply reduction ops in ascending order:
Expand All @@ -938,18 +937,14 @@ Value *llvm::getOrderedReduction(IRBuilderBase &Builder, Value *Acc, Value *Src,
"Invalid min/max");
Result = createMinMaxOp(Builder, RdxKind, Result, Ext);
}

if (!RedOps.empty())
propagateIRFlags(Result, RedOps);
}

return Result;
}

// Helper to generate a log2 shuffle reduction.
Value *llvm::getShuffleReduction(IRBuilderBase &Builder, Value *Src,
unsigned Op, RecurKind RdxKind,
ArrayRef<Value *> RedOps) {
unsigned Op, RecurKind RdxKind) {
unsigned VF = cast<FixedVectorType>(Src->getType())->getNumElements();
// VF is a power of 2 so we can emit the reduction using log2(VF) shuffles
// and vector ops, reducing the set of values being computed by half each
Expand Down Expand Up @@ -977,8 +972,6 @@ Value *llvm::getShuffleReduction(IRBuilderBase &Builder, Value *Src,
"Invalid min/max");
TmpVec = createMinMaxOp(Builder, RdxKind, TmpVec, Shuf);
}
if (!RedOps.empty())
propagateIRFlags(TmpVec, RedOps);

// We may compute the reassociated scalar ops in a way that does not
// preserve nsw/nuw etc. Conservatively, drop those flags.
Expand Down Expand Up @@ -1031,8 +1024,7 @@ Value *llvm::createSelectCmpTargetReduction(IRBuilderBase &Builder,

Value *llvm::createSimpleTargetReduction(IRBuilderBase &Builder,
const TargetTransformInfo *TTI,
Value *Src, RecurKind RdxKind,
ArrayRef<Value *> RedOps) {
Value *Src, RecurKind RdxKind) {
auto *SrcVecEltTy = cast<VectorType>(Src->getType())->getElementType();
switch (RdxKind) {
case RecurKind::Add:
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9072,8 +9072,7 @@ class HorizontalReduction {
"A call to the llvm.fmuladd intrinsic is not handled yet");

++NumVectorInstructions;
return createSimpleTargetReduction(Builder, TTI, VectorizedValue, RdxKind,
ReductionOps.back());
return createSimpleTargetReduction(Builder, TTI, VectorizedValue, RdxKind);
}
};

Expand Down

0 comments on commit b24db85

Please sign in to comment.