LLVM 19.0.0git
ScalarEvolutionNormalization.h
Go to the documentation of this file.
1//===- llvm/Analysis/ScalarEvolutionNormalization.h - See below -*- 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 utilities for working with "normalized" ScalarEvolution
10// expressions.
11//
12// The following example illustrates post-increment uses and how normalized
13// expressions help.
14//
15// for (i=0; i!=n; ++i) {
16// ...
17// }
18// use(i);
19//
20// While the expression for most uses of i inside the loop is {0,+,1}<%L>, the
21// expression for the use of i outside the loop is {1,+,1}<%L>, since i is
22// incremented at the end of the loop body. This is inconveient, since it
23// suggests that we need two different induction variables, one that starts
24// at 0 and one that starts at 1. We'd prefer to be able to think of these as
25// the same induction variable, with uses inside the loop using the
26// "pre-incremented" value, and uses after the loop using the
27// "post-incremented" value.
28//
29// Expressions for post-incremented uses are represented as an expression
30// paired with a set of loops for which the expression is in "post-increment"
31// mode (there may be multiple loops).
32//
33//===----------------------------------------------------------------------===//
34
35#ifndef LLVM_ANALYSIS_SCALAREVOLUTIONNORMALIZATION_H
36#define LLVM_ANALYSIS_SCALAREVOLUTIONNORMALIZATION_H
37
40
41namespace llvm {
42
43class Loop;
44class ScalarEvolution;
45class SCEV;
46class SCEVAddRecExpr;
47
49
51
52/// Normalize \p S to be post-increment for all loops present in \p
53/// Loops. Returns nullptr if the result is not invertible and \p
54/// CheckInvertible is true.
57 bool CheckInvertible = true);
58
59/// Normalize \p S for all add recurrence sub-expressions for which \p
60/// Pred returns true.
62 ScalarEvolution &SE);
63
64/// Denormalize \p S to be post-increment for all loops present in \p
65/// Loops.
67 ScalarEvolution &SE);
68} // namespace llvm
69
70#endif
Hexagon Hardware Loops
This file defines the SmallPtrSet class.
This node represents a polynomial recurrence on the trip count of the specified loop.
This class represents an analyzed expression in the program.
The main scalar evolution driver.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:427
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
const SCEV * denormalizeForPostIncUse(const SCEV *S, const PostIncLoopSet &Loops, ScalarEvolution &SE)
Denormalize S to be post-increment for all loops present in Loops.
function_ref< bool(const SCEVAddRecExpr *)> NormalizePredTy
const SCEV * normalizeForPostIncUse(const SCEV *S, const PostIncLoopSet &Loops, ScalarEvolution &SE, bool CheckInvertible=true)
Normalize S to be post-increment for all loops present in Loops.
SmallPtrSet< const Loop *, 2 > PostIncLoopSet
const SCEV * normalizeForPostIncUseIf(const SCEV *S, NormalizePredTy Pred, ScalarEvolution &SE)
Normalize S for all add recurrence sub-expressions for which Pred returns true.