Skip to content
Open
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
16 changes: 14 additions & 2 deletions llvm/include/llvm/Passes/CodeGenPassBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,16 @@
#include "llvm/Target/CGPassBuilderOption.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/CFGuard.h"
#include "llvm/Transforms/ObjCARC.h"
#include "llvm/Transforms/Scalar/ConstantHoisting.h"
#include "llvm/Transforms/Scalar/LoopPassManager.h"
#include "llvm/Transforms/Scalar/LoopStrengthReduce.h"
#include "llvm/Transforms/Scalar/LoopTermFold.h"
#include "llvm/Transforms/Scalar/LowerConstantIntrinsics.h"
#include "llvm/Transforms/Scalar/MergeICmps.h"
#include "llvm/Transforms/Scalar/PartiallyInlineLibCalls.h"
#include "llvm/Transforms/Scalar/ScalarizeMaskedMemIntrin.h"
#include "llvm/Transforms/Utils/CanonicalizeFreezeInLoops.h"
#include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
#include "llvm/Transforms/Utils/LowerInvoke.h"
#include <cassert>
Expand Down Expand Up @@ -691,7 +694,12 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addIRPasses(

// Run loop strength reduction before anything else.
if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableLSR) {
addPass(createFunctionToLoopPassAdaptor(LoopStrengthReducePass(),
LoopPassManager LPM;
LPM.addPass(CanonicalizeFreezeInLoopsPass());
LPM.addPass(LoopStrengthReducePass());
if (Opt.EnableLoopTermFold)
LPM.addPass(LoopTermFoldPass());
addPass(createFunctionToLoopPassAdaptor(std::move(LPM),
/*UseMemorySSA=*/true));
}

Expand Down Expand Up @@ -736,7 +744,8 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addIRPasses(
addPass(ScalarizeMaskedMemIntrinPass());

// Expand reduction intrinsics into shuffle sequences if the target wants to.
addPass(ExpandReductionsPass());
if (!Opt.DisableExpandReductions)
addPass(ExpandReductionsPass());

// Convert conditional moves to conditional jumps when profitable.
if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize)
Expand Down Expand Up @@ -811,6 +820,9 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addISelPrepare(
AddIRPass &addPass) const {
derived().addPreISel(addPass);

if (getOptLevel() != CodeGenOptLevel::None)
addPass(ObjCARCContractPass());

addPass(CallBrPreparePass());
// Add both the safe stack and the stack protection passes: each of them will
// only protect functions that have corresponding attributes.
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Target/CGPassBuilderOption.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ struct CGPassBuilderOption {
bool EnableMachineFunctionSplitter = false;
bool EnableSinkAndFold = false;
bool EnableTailMerge = true;
/// Enable LoopTermFold immediately after LSR
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terminate the comment with a period.

bool EnableLoopTermFold = false;
bool MISchedPostRA = false;
bool EarlyLiveIntervals = false;
bool GCEmptyBlocks = false;
Expand Down
9 changes: 8 additions & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@
#include "llvm/Transforms/Scalar/FlattenCFG.h"
#include "llvm/Transforms/Scalar/GVN.h"
#include "llvm/Transforms/Scalar/InferAddressSpaces.h"
#include "llvm/Transforms/Scalar/LICM.h"
#include "llvm/Transforms/Scalar/LoopDataPrefetch.h"
#include "llvm/Transforms/Scalar/LoopPassManager.h"
#include "llvm/Transforms/Scalar/NaryReassociate.h"
#include "llvm/Transforms/Scalar/SeparateConstOffsetFromGEP.h"
#include "llvm/Transforms/Scalar/Sink.h"
Expand Down Expand Up @@ -2021,7 +2023,12 @@ void AMDGPUCodeGenPassBuilder::addIRPasses(AddIRPass &addPass) const {
// TODO: May want to move later or split into an early and late one.
addPass(AMDGPUCodeGenPreparePass(TM));

// TODO: LICM
// Try to hoist loop invariant parts of divisions AMDGPUCodeGenPrepare may
// have expanded.
if (TM.getOptLevel() > CodeGenOptLevel::Less) {
addPass(createFunctionToLoopPassAdaptor(LICMPass(LICMOptions()),
/*UseMemorySSA=*/true));
}
}

Base::addIRPasses(addPass);
Expand Down