2012-02-01 04:51:43 +01:00
|
|
|
//===-- Vectorize.h - Vectorization Transformations -------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-02-01 04:51:43 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This header file defines prototypes for accessor functions that expose passes
|
|
|
|
// in the Vectorize transformations library.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TRANSFORMS_VECTORIZE_H
|
|
|
|
#define LLVM_TRANSFORMS_VECTORIZE_H
|
|
|
|
|
|
|
|
namespace llvm {
|
2012-04-05 10:05:16 +02:00
|
|
|
class BasicBlock;
|
2012-12-03 17:50:05 +01:00
|
|
|
class Pass;
|
2012-02-01 04:51:43 +01:00
|
|
|
|
2012-04-05 17:46:55 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Vectorize configuration.
|
2012-04-05 17:46:55 +02:00
|
|
|
struct VectorizeConfig {
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Target architecture related parameters
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// The size of the native vector registers.
|
2012-04-05 17:46:55 +02:00
|
|
|
unsigned VectorBits;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Vectorize boolean values.
|
2012-06-24 15:28:01 +02:00
|
|
|
bool VectorizeBools;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Vectorize integer values.
|
2012-04-07 05:56:23 +02:00
|
|
|
bool VectorizeInts;
|
2012-04-05 17:46:55 +02:00
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Vectorize floating-point values.
|
2012-04-07 05:56:23 +02:00
|
|
|
bool VectorizeFloats;
|
2012-04-05 17:46:55 +02:00
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Vectorize pointer values.
|
2012-04-14 09:32:43 +02:00
|
|
|
bool VectorizePointers;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Vectorize casting (conversion) operations.
|
2012-04-07 05:56:23 +02:00
|
|
|
bool VectorizeCasts;
|
2012-04-05 17:46:55 +02:00
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Vectorize floating-point math intrinsics.
|
2012-04-07 05:56:23 +02:00
|
|
|
bool VectorizeMath;
|
2012-04-05 17:46:55 +02:00
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Vectorize bit intrinsics.
|
2014-04-25 05:33:48 +02:00
|
|
|
bool VectorizeBitManipulations;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Vectorize the fused-multiply-add intrinsic.
|
2012-04-07 05:56:23 +02:00
|
|
|
bool VectorizeFMA;
|
2012-04-05 17:46:55 +02:00
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Vectorize select instructions.
|
2012-04-13 22:45:45 +02:00
|
|
|
bool VectorizeSelect;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Vectorize comparison instructions.
|
2012-06-23 23:52:50 +02:00
|
|
|
bool VectorizeCmp;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Vectorize getelementptr instructions.
|
2012-04-14 09:32:43 +02:00
|
|
|
bool VectorizeGEP;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Vectorize loads and stores.
|
2012-04-07 05:56:23 +02:00
|
|
|
bool VectorizeMemOps;
|
2012-04-05 17:46:55 +02:00
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Only generate aligned loads and stores.
|
2012-04-05 17:46:55 +02:00
|
|
|
bool AlignedOnly;
|
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Misc parameters
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// The required chain depth for vectorization.
|
2012-04-05 17:46:55 +02:00
|
|
|
unsigned ReqChainDepth;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// The maximum search distance for instruction pairs.
|
2012-04-05 17:46:55 +02:00
|
|
|
unsigned SearchLimit;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// The maximum number of candidate pairs with which to use a full
|
2012-04-05 17:46:55 +02:00
|
|
|
/// cycle check.
|
|
|
|
unsigned MaxCandPairsForCycleCheck;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Replicating one element to a pair breaks the chain.
|
2012-04-05 17:46:55 +02:00
|
|
|
bool SplatBreaksChain;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// The maximum number of pairable instructions per group.
|
2012-04-05 17:46:55 +02:00
|
|
|
unsigned MaxInsts;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// The maximum number of candidate instruction pairs per group.
|
BBVectorize: Cap the number of candidate pairs in each instruction group
For some basic blocks, it is possible to generate many candidate pairs for
relatively few pairable instructions. When many (tens of thousands) of these pairs
are generated for a single instruction group, the time taken to generate and
rank the different vectorization plans can become quite large. As a result, we now
cap the number of candidate pairs within each instruction group. This is done by
closing out the group once the threshold is reached (set now at 3000 pairs).
Although this will limit the overall compile-time impact, this may not be the best
way to achieve this result. It might be better, for example, to prune excessive
candidate pairs after the fact the prevent the generation of short, but highly-connected
groups. We can experiment with this in the future.
This change reduces the overall compile-time slowdown of the csa.ll test case in
PR15222 to ~5x. If 5x is still considered too large, a lower limit can be
used as the default.
This represents a functionality change, but only for very large inputs
(thus, there is no regression test).
llvm-svn: 175251
2013-02-15 05:28:42 +01:00
|
|
|
unsigned MaxPairs;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// The maximum number of pairing iterations.
|
2012-04-05 17:46:55 +02:00
|
|
|
unsigned MaxIter;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Don't try to form odd-length vectors.
|
2012-06-28 07:42:42 +02:00
|
|
|
bool Pow2LenOnly;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Don't boost the chain-depth contribution of loads and stores.
|
2012-04-05 17:46:55 +02:00
|
|
|
bool NoMemOpBoost;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Use a fast instruction dependency analysis.
|
2012-04-05 17:46:55 +02:00
|
|
|
bool FastDep;
|
|
|
|
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Initialize the VectorizeConfig from command line options.
|
2012-04-05 17:46:55 +02:00
|
|
|
VectorizeConfig();
|
|
|
|
};
|
|
|
|
|
2012-10-17 20:25:06 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// LoopVectorize - Create a loop vectorization pass.
|
|
|
|
//
|
2019-04-19 18:11:59 +02:00
|
|
|
Pass *createLoopVectorizePass();
|
|
|
|
Pass *createLoopVectorizePass(bool InterleaveOnlyWhenForced,
|
|
|
|
bool VectorizeOnlyWhenForced);
|
2012-10-17 20:25:06 +02:00
|
|
|
|
2013-04-09 21:44:35 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// SLPVectorizer - Create a bottom-up SLP vectorizer pass.
|
|
|
|
//
|
|
|
|
Pass *createSLPVectorizerPass();
|
|
|
|
|
2012-04-05 10:05:16 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2018-05-01 18:10:38 +02:00
|
|
|
/// Vectorize the BasicBlock.
|
2012-04-05 10:05:16 +02:00
|
|
|
///
|
|
|
|
/// @param BB The BasicBlock to be vectorized
|
|
|
|
/// @param P The current running pass, should require AliasAnalysis and
|
|
|
|
/// ScalarEvolution. After the vectorization, AliasAnalysis,
|
|
|
|
/// ScalarEvolution and CFG are preserved.
|
|
|
|
///
|
|
|
|
/// @return True if the BB is changed, false otherwise.
|
|
|
|
///
|
2012-04-05 17:46:55 +02:00
|
|
|
bool vectorizeBasicBlock(Pass *P, BasicBlock &BB,
|
|
|
|
const VectorizeConfig &C = VectorizeConfig());
|
2012-04-05 10:05:16 +02:00
|
|
|
|
2016-07-01 01:11:38 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// LoadStoreVectorizer - Create vector loads and stores, but leave scalar
|
|
|
|
// operations.
|
|
|
|
//
|
2016-07-01 04:07:22 +02:00
|
|
|
Pass *createLoadStoreVectorizerPass();
|
2016-07-01 01:11:38 +02:00
|
|
|
|
[VectorCombine] new IR transform pass for partial vector ops
We have several bug reports that could be characterized as "reducing scalarization",
and this topic was also raised on llvm-dev recently:
http://lists.llvm.org/pipermail/llvm-dev/2020-January/138157.html
...so I'm proposing that we deal with these patterns in a new, lightweight IR vector
pass that runs before/after other vectorization passes.
There are 4 alternate options that I can think of to deal with this kind of problem
(and we've seen various attempts at all of these), but they all have flaws:
InstCombine - can't happen without TTI, but we don't want target-specific
folds there.
SDAG - too late to assist other vectorization passes; TLI is not equipped
for these kind of cost queries; limited to a single basic block.
CGP - too late to assist other vectorization passes; would need to re-implement
basic cleanups like CSE/instcombine.
SLP - doesn't fit with existing transforms; limited to a single basic block.
This initial patch/transform is based on existing code in AggressiveInstCombine:
we walk backwards through the function looking for a pattern match. But we diverge
from that cost-independent IR canonicalization pass by using TTI to decide if the
vector alternative is profitable.
We probably have at least 10 similar bug reports/patterns (binops, constants,
inserts, cheap shuffles, etc) that would fit in this pass as follow-up enhancements.
It's possible that we could iterate on a worklist to fix-point like InstCombine does,
but it's safer to start with a most basic case and evolve from there, so I didn't
try to do anything fancy with this initial implementation.
Differential Revision: https://reviews.llvm.org/D73480
2020-02-09 16:04:41 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Optimize partial vector operations using target cost models.
|
|
|
|
//
|
|
|
|
Pass *createVectorCombinePass();
|
|
|
|
|
2015-06-23 11:49:53 +02:00
|
|
|
} // End llvm namespace
|
2012-02-01 04:51:43 +01:00
|
|
|
|
|
|
|
#endif
|