aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Transforms/Vectorize/LoopVectorize.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/Transforms/Vectorize/LoopVectorize.h')
-rw-r--r--include/llvm/Transforms/Vectorize/LoopVectorize.h58
1 files changed, 51 insertions, 7 deletions
diff --git a/include/llvm/Transforms/Vectorize/LoopVectorize.h b/include/llvm/Transforms/Vectorize/LoopVectorize.h
index d9c4f7b023c1..d1ec06afb02a 100644
--- a/include/llvm/Transforms/Vectorize/LoopVectorize.h
+++ b/include/llvm/Transforms/Vectorize/LoopVectorize.h
@@ -1,9 +1,8 @@
//===- LoopVectorize.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// 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
//
//===----------------------------------------------------------------------===//
//
@@ -72,19 +71,63 @@ class Loop;
class LoopAccessInfo;
class LoopInfo;
class OptimizationRemarkEmitter;
+class ProfileSummaryInfo;
class ScalarEvolution;
class TargetLibraryInfo;
class TargetTransformInfo;
+extern cl::opt<bool> EnableLoopInterleaving;
+extern cl::opt<bool> EnableLoopVectorization;
+
+struct LoopVectorizeOptions {
+ /// If false, consider all loops for interleaving.
+ /// If true, only loops that explicitly request interleaving are considered.
+ bool InterleaveOnlyWhenForced;
+
+ /// If false, consider all loops for vectorization.
+ /// If true, only loops that explicitly request vectorization are considered.
+ bool VectorizeOnlyWhenForced;
+
+ /// The current defaults when creating the pass with no arguments are:
+ /// EnableLoopInterleaving = true and EnableLoopVectorization = true. This
+ /// means that interleaving default is consistent with the cl::opt flag, while
+ /// vectorization is not.
+ /// FIXME: The default for EnableLoopVectorization in the cl::opt should be
+ /// set to true, and the corresponding change to account for this be made in
+ /// opt.cpp. The initializations below will become:
+ /// InterleaveOnlyWhenForced(!EnableLoopInterleaving)
+ /// VectorizeOnlyWhenForced(!EnableLoopVectorization).
+ LoopVectorizeOptions()
+ : InterleaveOnlyWhenForced(false), VectorizeOnlyWhenForced(false) {}
+ LoopVectorizeOptions(bool InterleaveOnlyWhenForced,
+ bool VectorizeOnlyWhenForced)
+ : InterleaveOnlyWhenForced(InterleaveOnlyWhenForced),
+ VectorizeOnlyWhenForced(VectorizeOnlyWhenForced) {}
+
+ LoopVectorizeOptions &setInterleaveOnlyWhenForced(bool Value) {
+ InterleaveOnlyWhenForced = Value;
+ return *this;
+ }
+
+ LoopVectorizeOptions &setVectorizeOnlyWhenForced(bool Value) {
+ VectorizeOnlyWhenForced = Value;
+ return *this;
+ }
+};
+
/// The LoopVectorize Pass.
struct LoopVectorizePass : public PassInfoMixin<LoopVectorizePass> {
/// If false, consider all loops for interleaving.
/// If true, only loops that explicitly request interleaving are considered.
- bool InterleaveOnlyWhenForced = false;
+ bool InterleaveOnlyWhenForced;
/// If false, consider all loops for vectorization.
/// If true, only loops that explicitly request vectorization are considered.
- bool VectorizeOnlyWhenForced = false;
+ bool VectorizeOnlyWhenForced;
+
+ LoopVectorizePass(LoopVectorizeOptions Opts = {})
+ : InterleaveOnlyWhenForced(Opts.InterleaveOnlyWhenForced),
+ VectorizeOnlyWhenForced(Opts.VectorizeOnlyWhenForced) {}
ScalarEvolution *SE;
LoopInfo *LI;
@@ -97,6 +140,7 @@ struct LoopVectorizePass : public PassInfoMixin<LoopVectorizePass> {
AssumptionCache *AC;
std::function<const LoopAccessInfo &(Loop &)> *GetLAA;
OptimizationRemarkEmitter *ORE;
+ ProfileSummaryInfo *PSI;
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
@@ -106,7 +150,7 @@ struct LoopVectorizePass : public PassInfoMixin<LoopVectorizePass> {
BlockFrequencyInfo &BFI_, TargetLibraryInfo *TLI_,
DemandedBits &DB_, AliasAnalysis &AA_, AssumptionCache &AC_,
std::function<const LoopAccessInfo &(Loop &)> &GetLAA_,
- OptimizationRemarkEmitter &ORE);
+ OptimizationRemarkEmitter &ORE_, ProfileSummaryInfo *PSI_);
bool processLoop(Loop *L);
};