Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions llvm/include/llvm/Transforms/Scalar/PrecomputeLoopExpressions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//===-------------------- PrecomputeLoopExpressions.h ---------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_TRANSFORMS_SCALAR_PRECOMPUTE_LOOP_EXPRESSIONS_H
#define LLVM_TRANSFORMS_SCALAR_PRECOMPUTE_LOOP_EXPRESSIONS_H

#include "llvm/IR/PassManager.h"

namespace llvm {
class PrecomputeLoopExpressionsPass
: public PassInfoMixin<PrecomputeLoopExpressionsPass> {
unsigned TotalInitSize;

public:
PrecomputeLoopExpressionsPass(unsigned TotalInitSize = 0)
: TotalInitSize(TotalInitSize) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};

} // end namespace llvm

#endif // LLVM_TRANSFORMS_SCALAR_PRECOMPUTE_LOOP_EXPRESSIONS_H
7 changes: 7 additions & 0 deletions llvm/lib/Passes/PassBuilderPipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
#include "llvm/Transforms/Scalar/MemCpyOptimizer.h"
#include "llvm/Transforms/Scalar/MergedLoadStoreMotion.h"
#include "llvm/Transforms/Scalar/NewGVN.h"
#include "llvm/Transforms/Scalar/PrecomputeLoopExpressions.h"
#include "llvm/Transforms/Scalar/Reassociate.h"
#include "llvm/Transforms/Scalar/SCCP.h"
#include "llvm/Transforms/Scalar/SROA.h"
Expand Down Expand Up @@ -302,6 +303,8 @@ namespace llvm {
extern cl::opt<bool> EnableMemProfContextDisambiguation;

extern cl::opt<bool> EnableInferAlignmentPass;

extern cl::opt<bool> DisablePCLE;
} // namespace llvm

PipelineTuningOptions::PipelineTuningOptions() {
Expand Down Expand Up @@ -681,6 +684,10 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM1),
/*UseMemorySSA=*/true,
/*UseBlockFrequencyInfo=*/true));

if (!DisablePCLE)
FPM.addPass(PrecomputeLoopExpressionsPass());

FPM.addPass(
SimplifyCFGPass(SimplifyCFGOptions().convertSwitchRangeToICmp(true)));
FPM.addPass(InstCombinePass());
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Transforms/Scalar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ add_llvm_component_library(LLVMScalarOpts
NewGVN.cpp
PartiallyInlineLibCalls.cpp
PlaceSafepoints.cpp
PrecomputeLoop.cpp
Reassociate.cpp
Reg2Mem.cpp
RewriteStatepointsForGC.cpp
Expand Down
Loading