LLVM 22.0.0git
Scalarizer.h
Go to the documentation of this file.
1//===- Scalarizer.h --- Scalarize vector operations -----------------------===//
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/// \file
10/// This pass converts vector operations into scalar operations (or, optionally,
11/// operations on smaller vector widths), in order to expose optimization
12/// opportunities on the individual scalar operations.
13/// It is mainly intended for targets that do not have vector units, but it
14/// may also be useful for revectorizing code to different vector widths.
15//
16//===----------------------------------------------------------------------===//
17
18#ifndef LLVM_TRANSFORMS_SCALAR_SCALARIZER_H
19#define LLVM_TRANSFORMS_SCALAR_SCALARIZER_H
20
21#include "llvm/IR/PassManager.h"
23#include <optional>
24
25namespace llvm {
26
27class Function;
28class FunctionPass;
29
31 /// Instruct the scalarizer pass to attempt to keep values of a minimum number
32 /// of bits.
33
34 /// Split vectors larger than this size into fragments, where each fragment is
35 /// either a vector no larger than this size or a scalar.
36 ///
37 /// Instructions with operands or results of different sizes that would be
38 /// split into a different number of fragments are currently left as-is.
39 unsigned ScalarizeMinBits = 0;
40
41 /// Allow the scalarizer pass to scalarize insertelement/extractelement with
42 /// variable index.
44
45 /// Allow the scalarizer pass to scalarize loads and store
46 ///
47 /// This is disabled by default because having separate loads and stores makes
48 /// it more likely that the -combiner-alias-analysis limits will be reached.
49 bool ScalarizeLoadStore = false;
50};
51
52class ScalarizerPass : public PassInfoMixin<ScalarizerPass> {
54
55public:
56 ScalarizerPass() = default;
57 ScalarizerPass(const ScalarizerPassOptions &Options) : Options(Options) {}
58
60
62 Options.ScalarizeVariableInsertExtract = Value;
63 }
64 void setScalarizeLoadStore(bool Value) { Options.ScalarizeLoadStore = Value; }
65 void setScalarizeMinBits(unsigned Value) { Options.ScalarizeMinBits = Value; }
66};
67
68/// Create a legacy pass manager instance of the Scalarizer pass
69LLVM_ABI FunctionPass *createScalarizerPass(
70 const ScalarizerPassOptions &Options = ScalarizerPassOptions());
71}
72
73#endif /* LLVM_TRANSFORMS_SCALAR_SCALARIZER_H */
#define LLVM_ABI
Definition Compiler.h:213
This header defines various interfaces for pass management in LLVM.
static LVOptions Options
Definition LVOptions.cpp:25
#define F(x, y, z)
Definition MD5.cpp:55
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
ScalarizerPass(const ScalarizerPassOptions &Options)
Definition Scalarizer.h:57
ScalarizerPass()=default
void setScalarizeLoadStore(bool Value)
Definition Scalarizer.h:64
void setScalarizeVariableInsertExtract(bool Value)
Definition Scalarizer.h:61
void setScalarizeMinBits(unsigned Value)
Definition Scalarizer.h:65
LLVM Value Representation.
Definition Value.h:75
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI FunctionPass * createScalarizerPass(const ScalarizerPassOptions &Options=ScalarizerPassOptions())
Create a legacy pass manager instance of the Scalarizer pass.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition PassManager.h:70
bool ScalarizeLoadStore
Allow the scalarizer pass to scalarize loads and store.
Definition Scalarizer.h:49
unsigned ScalarizeMinBits
Instruct the scalarizer pass to attempt to keep values of a minimum number of bits.
Definition Scalarizer.h:39
bool ScalarizeVariableInsertExtract
Allow the scalarizer pass to scalarize insertelement/extractelement with variable index.
Definition Scalarizer.h:43