[llvm-branch-commits] [llvm] 5d24089 - [SLP] reduce code for propagating flags on reductions; NFC
Sanjay Patel via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jan 6 11:42:29 PST 2021
Author: Sanjay Patel
Date: 2021-01-06T14:37:44-05:00
New Revision: 5d24089a7001e9fb4c0e665e93312916d88aaef9
URL: https://github.com/llvm/llvm-project/commit/5d24089a7001e9fb4c0e665e93312916d88aaef9
DIFF: https://github.com/llvm/llvm-project/commit/5d24089a7001e9fb4c0e665e93312916d88aaef9.diff
LOG: [SLP] reduce code for propagating flags on reductions; NFC
If we add/change to match intrinsics, this might get more
wordy, but there's no need to list each kind currently.
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 75f881dc7d4b..c4278722418b 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6637,28 +6637,15 @@ class HorizontalReduction {
const ReductionOpsListType &ReductionOps) const {
assert(isVectorizable() &&
"Expected add|fadd or min/max reduction operation.");
- auto *Op = createOp(Builder, LHS, RHS, Name);
- switch (Kind) {
- case RecurKind::Add:
- case RecurKind::Mul:
- case RecurKind::Or:
- case RecurKind::And:
- case RecurKind::Xor:
- case RecurKind::FAdd:
- case RecurKind::FMul:
- propagateIRFlags(Op, ReductionOps[0]);
- return Op;
- case RecurKind::SMax:
- case RecurKind::SMin:
- case RecurKind::UMax:
- case RecurKind::UMin:
- if (auto *SI = dyn_cast<SelectInst>(Op))
- propagateIRFlags(SI->getCondition(), ReductionOps[0]);
+ Value *Op = createOp(Builder, LHS, RHS, Name);
+ if (RecurrenceDescriptor::isIntMinMaxRecurrenceKind(Kind)) {
+ if (auto *Sel = dyn_cast<SelectInst>(Op))
+ propagateIRFlags(Sel->getCondition(), ReductionOps[0]);
propagateIRFlags(Op, ReductionOps[1]);
return Op;
- default:
- llvm_unreachable("Unknown reduction operation.");
}
+ propagateIRFlags(Op, ReductionOps[0]);
+ return Op;
}
/// Creates reduction operation with the current opcode with the IR flags
/// from \p I.
@@ -6666,30 +6653,15 @@ class HorizontalReduction {
const Twine &Name, Instruction *I) const {
assert(isVectorizable() &&
"Expected add|fadd or min/max reduction operation.");
- auto *Op = createOp(Builder, LHS, RHS, Name);
- switch (Kind) {
- case RecurKind::Add:
- case RecurKind::Mul:
- case RecurKind::Or:
- case RecurKind::And:
- case RecurKind::Xor:
- case RecurKind::FAdd:
- case RecurKind::FMul:
- propagateIRFlags(Op, I);
- return Op;
- case RecurKind::SMax:
- case RecurKind::SMin:
- case RecurKind::UMax:
- case RecurKind::UMin:
- if (auto *SI = dyn_cast<SelectInst>(Op)) {
- propagateIRFlags(SI->getCondition(),
+ Value *Op = createOp(Builder, LHS, RHS, Name);
+ if (RecurrenceDescriptor::isIntMinMaxRecurrenceKind(Kind)) {
+ if (auto *Sel = dyn_cast<SelectInst>(Op)) {
+ propagateIRFlags(Sel->getCondition(),
cast<SelectInst>(I)->getCondition());
}
- propagateIRFlags(Op, I);
- return Op;
- default:
- llvm_unreachable("Unknown reduction operation.");
}
+ propagateIRFlags(Op, I);
+ return Op;
}
};
More information about the llvm-branch-commits
mailing list