LLVM 24.0.0git
SLPReductionUtils.h
Go to the documentation of this file.
1//===- SLPReductionUtils.h - SLP reduction match helpers -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Internal header used by SLPVectorizer.cpp. It declares free reduction
10// pattern-match helpers that do not depend on BoUpSLP or any other SLP-private
11// type.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPREDUCTIONUTILS_H
16#define LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPREDUCTIONUTILS_H
17
19
20namespace llvm {
21class FastMathFlags;
22class IRBuilderBase;
23class Instruction;
24class PHINode;
25class Type;
26class Value;
27enum class RecurKind;
28} // namespace llvm
29
30namespace llvm::slpvectorizer {
31
32/// \returns the wide leaf type if the logical and/or reduction \p RdxKind
33/// with the i1 root type \p RootTy and the leaf type \p LeafTy is a
34/// booleanized reduction (performed in the wide leaf type, bit 0 of the
35/// result is the final value), nullptr otherwise.
36Type *getBoolReduxWideTy(RecurKind RdxKind, Type *RootTy, Type *LeafTy);
37
38/// \returns the first operand of \p I that does not match \p Phi. If
39/// the operand is not an instruction, returns nullptr.
40Instruction *getNonPhiOperand(Instruction *I, PHINode *Phi);
41
42/// \returns true if \p I is a candidate instruction for reduction
43/// vectorization.
44bool isReductionCandidate(Instruction *I);
45
46/// Emits the booleanized logical and/or reduction of \p Vec with the i1 root
47/// \p Root as trunc+bitcast+cmp (all-ones comparison for And, zero for Or) if
48/// it is cheaper than the wide reduction plus the result trunc. \returns the
49/// i1 result or nullptr if the wide reduction form is cheaper.
50Value *tryEmitBoolReduxBitcastCmp(IRBuilderBase &Builder,
51 const TargetTransformInfo &TTI,
52 RecurKind RdxKind, Value *Vec,
53 const Value *Root, FastMathFlags FMF,
55
56} // namespace llvm::slpvectorizer
57
58#endif // LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPREDUCTIONUTILS_H
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
#define I(x, y, z)
Definition MD5.cpp:57
This pass exposes codegen information to IR-level passes.
Convenience struct for specifying and reasoning about fast-math flags.
Definition FMF.h:23
Common base class shared among various IRBuilders.
Definition IRBuilder.h:114
TargetCostKind
The kind of cost model.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
LLVM Value Representation.
Definition Value.h:75
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
A private "module" namespace for types and utilities used by this pass.
Type * getBoolReduxWideTy(RecurKind RdxKind, Type *RootTy, Type *LeafTy)
Value * tryEmitBoolReduxBitcastCmp(IRBuilderBase &Builder, const TargetTransformInfo &TTI, RecurKind RdxKind, Value *Vec, const Value *Root, FastMathFlags FMF, const TTI::TargetCostKind CostKind)
Emits the booleanized logical and/or reduction of Vec with the i1 root Root as trunc+bitcast+cmp (all...
Instruction * getNonPhiOperand(Instruction *I, PHINode *Phi)
bool isReductionCandidate(Instruction *I)
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
TargetTransformInfo TTI
RecurKind
These are the kinds of recurrences that we support.