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
24namespace llvm {
25
26class Function;
27class FunctionPass;
28
30 /// Instruct the scalarizer pass to attempt to keep values of a minimum number
31 /// of bits.
32
33 /// Split vectors larger than this size into fragments, where each fragment is
34 /// either a vector no larger than this size or a scalar.
35 ///
36 /// Instructions with operands or results of different sizes that would be
37 /// split into a different number of fragments are currently left as-is.
38 unsigned ScalarizeMinBits = 0;
39
40 /// Allow the scalarizer pass to scalarize insertelement/extractelement with
41 /// variable index.
43
44 /// Allow the scalarizer pass to scalarize loads and store
45 ///
46 /// This is disabled by default because having separate loads and stores makes
47 /// it more likely that the -combiner-alias-analysis limits will be reached.
48 bool ScalarizeLoadStore = false;
49};
50
51class ScalarizerPass : public PassInfoMixin<ScalarizerPass> {
53
54public:
55 ScalarizerPass() = default;
56 ScalarizerPass(const ScalarizerPassOptions &Options) : Options(Options) {}
57
59
61 Options.ScalarizeVariableInsertExtract = Value;
62 }
63 void setScalarizeLoadStore(bool Value) { Options.ScalarizeLoadStore = Value; }
64 void setScalarizeMinBits(unsigned Value) { Options.ScalarizeMinBits = Value; }
65};
66
67/// Create a legacy pass manager instance of the Scalarizer pass
68LLVM_ABI FunctionPass *createScalarizerPass(
69 const ScalarizerPassOptions &Options = ScalarizerPassOptions());
70}
71
72#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:54
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:56
ScalarizerPass()=default
void setScalarizeLoadStore(bool Value)
Definition Scalarizer.h:63
void setScalarizeVariableInsertExtract(bool Value)
Definition Scalarizer.h:60
void setScalarizeMinBits(unsigned Value)
Definition Scalarizer.h:64
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:69
bool ScalarizeLoadStore
Allow the scalarizer pass to scalarize loads and store.
Definition Scalarizer.h:48
unsigned ScalarizeMinBits
Instruct the scalarizer pass to attempt to keep values of a minimum number of bits.
Definition Scalarizer.h:38
bool ScalarizeVariableInsertExtract
Allow the scalarizer pass to scalarize insertelement/extractelement with variable index.
Definition Scalarizer.h:42