Go to the documentation of this file.
31 case Intrinsic::vector_reduce_fadd:
32 return Instruction::FAdd;
33 case Intrinsic::vector_reduce_fmul:
34 return Instruction::FMul;
35 case Intrinsic::vector_reduce_add:
37 case Intrinsic::vector_reduce_mul:
39 case Intrinsic::vector_reduce_and:
40 return Instruction::And;
41 case Intrinsic::vector_reduce_or:
42 return Instruction::Or;
43 case Intrinsic::vector_reduce_xor:
44 return Instruction::Xor;
45 case Intrinsic::vector_reduce_smax:
46 case Intrinsic::vector_reduce_smin:
47 case Intrinsic::vector_reduce_umax:
48 case Intrinsic::vector_reduce_umin:
49 return Instruction::ICmp;
50 case Intrinsic::vector_reduce_fmax:
51 case Intrinsic::vector_reduce_fmin:
52 return Instruction::FCmp;
60 case Intrinsic::vector_reduce_smax:
62 case Intrinsic::vector_reduce_smin:
64 case Intrinsic::vector_reduce_umax:
66 case Intrinsic::vector_reduce_umin:
68 case Intrinsic::vector_reduce_fmax:
70 case Intrinsic::vector_reduce_fmin:
81 if (
auto *II = dyn_cast<IntrinsicInst>(&
I)) {
82 switch (II->getIntrinsicID()) {
84 case Intrinsic::vector_reduce_fadd:
85 case Intrinsic::vector_reduce_fmul:
86 case Intrinsic::vector_reduce_add:
87 case Intrinsic::vector_reduce_mul:
88 case Intrinsic::vector_reduce_and:
89 case Intrinsic::vector_reduce_or:
90 case Intrinsic::vector_reduce_xor:
91 case Intrinsic::vector_reduce_smax:
92 case Intrinsic::vector_reduce_smin:
93 case Intrinsic::vector_reduce_umax:
94 case Intrinsic::vector_reduce_umin:
95 case Intrinsic::vector_reduce_fmax:
96 case Intrinsic::vector_reduce_fmin:
98 Worklist.push_back(II);
105 for (
auto *II : Worklist) {
107 isa<FPMathOperator>(II) ? II->getFastMathFlags() :
FastMathFlags{};
111 Value *Rdx =
nullptr;
117 case Intrinsic::vector_reduce_fadd:
118 case Intrinsic::vector_reduce_fmul: {
121 Value *Acc = II->getArgOperand(0);
122 Value *Vec = II->getArgOperand(1);
127 cast<FixedVectorType>(Vec->
getType())->getNumElements()))
132 Acc, Rdx,
"bin.rdx");
136 case Intrinsic::vector_reduce_add:
137 case Intrinsic::vector_reduce_mul:
138 case Intrinsic::vector_reduce_and:
139 case Intrinsic::vector_reduce_or:
140 case Intrinsic::vector_reduce_xor:
141 case Intrinsic::vector_reduce_smax:
142 case Intrinsic::vector_reduce_smin:
143 case Intrinsic::vector_reduce_umax:
144 case Intrinsic::vector_reduce_umin: {
145 Value *Vec = II->getArgOperand(0);
147 cast<FixedVectorType>(Vec->
getType())->getNumElements()))
153 case Intrinsic::vector_reduce_fmax:
154 case Intrinsic::vector_reduce_fmin: {
157 Value *Vec = II->getArgOperand(0);
159 cast<FixedVectorType>(Vec->
getType())->getNumElements()) ||
167 II->replaceAllUsesWith(Rdx);
168 II->eraseFromParent();
182 const auto *
TTI =&getAnalysis<TargetTransformInfoWrapperPass>().getTTI(
F);
183 return expandReductions(
F,
TTI);
195 "Expand reduction intrinsics",
false,
false)
201 return new ExpandReductions();
207 if (!expandReductions(
F, &
TTI))
A set of analyses that are preserved following a run of a transformation pass.
Analysis pass providing the TargetTransformInfo.
This is an optimization pass for GlobalISel generic memory operations.
Value * getShuffleReduction(IRBuilderBase &Builder, Value *Src, unsigned Op, RecurKind MinMaxKind=RecurKind::None)
Generates a vector reduction using shufflevectors to reduce the value.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Convenience struct for specifying and reasoning about fast-math flags.
@ SMin
Signed integer min implemented in terms of select(cmp()).
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
RecurKind
These are the kinds of recurrences that we support.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Value * getOrderedReduction(IRBuilderBase &Builder, Value *Acc, Value *Src, unsigned Op, RecurKind MinMaxKind=RecurKind::None)
Generates an ordered vector reduction using extracts to reduce the value.
Represent the analysis usage information of a pass.
static Optional< unsigned > getOpcode(ArrayRef< VPValue * > Values)
Returns the opcode of Values or ~0 if they do not all agree.
bool allowReassoc() const
Flag queries.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
@ UMin
Unisgned integer min implemented in terms of select(cmp()).
void initializeExpandReductionsPass(PassRegistry &)
inst_range instructions(Function *F)
static Expected< BitVector > expand(StringRef S, StringRef Original)
expand Expand reduction intrinsics
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
FunctionPass * createExpandReductionsPass()
This pass expands the experimental reduction intrinsics into sequences of shuffles.
Straight line strength reduction
@ UMax
Unsigned integer max implemented in terms of select(cmp()).
void setPreservesCFG()
This function should be called by the pass, iff they do not:
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type * getType() const
All values are typed, get the type of this value.
Represents analyses that only rely on functions' control flow.
@ FMax
FP max implemented in terms of select(cmp()).
INITIALIZE_PASS_BEGIN(ExpandReductions, "expand-reductions", "Expand reduction intrinsics", false, false) INITIALIZE_PASS_END(ExpandReductions
static bool runOnFunction(Function &F, bool PostInlining)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void preserveSet()
Mark an analysis set as preserved.
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
@ FMin
FP min implemented in terms of select(cmp()).
AnalysisUsage & addRequired()
@ SMax
Signed integer max implemented in terms of select(cmp()).
LLVM Value Representation.