1 //===- llvm/Analysis/ScalarEvolutionNormalization.h - See below -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines utilities for working with "normalized" ScalarEvolution
13 // The following example illustrates post-increment uses and how normalized
16 // for (i=0; i!=n; ++i) {
21 // While the expression for most uses of i inside the loop is {0,+,1}<%L>, the
22 // expression for the use of i outside the loop is {1,+,1}<%L>, since i is
23 // incremented at the end of the loop body. This is inconveient, since it
24 // suggests that we need two different induction variables, one that starts
25 // at 0 and one that starts at 1. We'd prefer to be able to think of these as
26 // the same induction variable, with uses inside the loop using the
27 // "pre-incremented" value, and uses after the loop using the
28 // "post-incremented" value.
30 // Expressions for post-incremented uses are represented as an expression
31 // paired with a set of loops for which the expression is in "post-increment"
32 // mode (there may be multiple loops).
34 //===----------------------------------------------------------------------===//
36 #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONNORMALIZATION_H
37 #define LLVM_ANALYSIS_SCALAREVOLUTIONNORMALIZATION_H
39 #include "llvm/ADT/SmallPtrSet.h"
46 class ScalarEvolution;
50 /// TransformKind - Different types of transformations that
51 /// TransformForPostIncUse can do.
53 /// Normalize - Normalize according to the given loops.
55 /// NormalizeAutodetect - Detect post-inc opportunities on new expressions,
56 /// update the given loop set, and normalize.
58 /// Denormalize - Perform the inverse transform on the expression with the
63 /// PostIncLoopSet - A set of loops.
64 typedef SmallPtrSet<const Loop *, 2> PostIncLoopSet;
66 /// TransformForPostIncUse - Transform the given expression according to the
67 /// given transformation kind.
68 const SCEV *TransformForPostIncUse(TransformKind Kind,
71 Value *OperandValToReplace,
72 PostIncLoopSet &Loops,