LLVM 22.0.0git
LoopPeel.h
Go to the documentation of this file.
1//===- llvm/Transforms/Utils/LoopPeel.h ----- Peeling utilities -*- C++ -*-===//
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// This file defines some loop peeling utilities. It does not define any
10// actual pass or policy.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_TRANSFORMS_UTILS_LOOPPEEL_H
15#define LLVM_TRANSFORMS_UTILS_LOOPPEEL_H
16
19
20namespace llvm {
21
22bool canPeel(const Loop *L);
23
24/// Returns true if the last iteration of \p L can be peeled off. It makes sure
25/// the loop exit condition can be adjusted when peeling and that the loop
26/// executes at least 2 iterations.
27bool canPeelLastIteration(const Loop &L, ScalarEvolution &SE);
28
29/// VMap is the value-map that maps instructions from the original loop to
30/// instructions in the last peeled-off iteration. If \p PeelLast is true, peel
31/// off the last \p PeelCount iterations from \p L (canPeelLastIteration must be
32/// true for \p L), otherwise peel off the first \p PeelCount iterations.
33bool peelLoop(Loop *L, unsigned PeelCount, bool PeelLast, LoopInfo *LI,
34 ScalarEvolution *SE, DominatorTree &DT, AssumptionCache *AC,
35 bool PreserveLCSSA, ValueToValueMapTy &VMap);
36
37TargetTransformInfo::PeelingPreferences
38gatherPeelingPreferences(Loop *L, ScalarEvolution &SE,
39 const TargetTransformInfo &TTI,
40 std::optional<bool> UserAllowPeeling,
41 std::optional<bool> UserAllowProfileBasedPeeling,
42 bool UnrollingSpecficValues = false);
43
44void computePeelCount(Loop *L, unsigned LoopSize,
45 TargetTransformInfo::PeelingPreferences &PP,
46 unsigned TripCount, DominatorTree &DT,
47 ScalarEvolution &SE, const TargetTransformInfo &TTI,
48 AssumptionCache *AC = nullptr,
49 unsigned Threshold = UINT_MAX);
50
51} // end namespace llvm
52
53#endif // LLVM_TRANSFORMS_UTILS_LOOPPEEL_H
This pass exposes codegen information to IR-level passes.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool canPeel(const Loop *L)
Definition: LoopPeel.cpp:91
bool canPeelLastIteration(const Loop &L, ScalarEvolution &SE)
Returns true if the last iteration of L can be peeled off.
Definition: LoopPeel.cpp:472
TargetTransformInfo::PeelingPreferences gatherPeelingPreferences(Loop *L, ScalarEvolution &SE, const TargetTransformInfo &TTI, std::optional< bool > UserAllowPeeling, std::optional< bool > UserAllowProfileBasedPeeling, bool UnrollingSpecficValues=false)
Definition: LoopPeel.cpp:1128
void computePeelCount(Loop *L, unsigned LoopSize, TargetTransformInfo::PeelingPreferences &PP, unsigned TripCount, DominatorTree &DT, ScalarEvolution &SE, const TargetTransformInfo &TTI, AssumptionCache *AC=nullptr, unsigned Threshold=UINT_MAX)
Definition: LoopPeel.cpp:744
TargetTransformInfo TTI
ValueMap< const Value *, WeakTrackingVH > ValueToValueMapTy
bool peelLoop(Loop *L, unsigned PeelCount, bool PeelLast, LoopInfo *LI, ScalarEvolution *SE, DominatorTree &DT, AssumptionCache *AC, bool PreserveLCSSA, ValueToValueMapTy &VMap)
VMap is the value-map that maps instructions from the original loop to instructions in the last peele...
Definition: LoopPeel.cpp:1173