Polly 19.0.0git
SCEVValidator.h
Go to the documentation of this file.
1//===--- SCEVValidator.h - Detect Scops -------------------------*- 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// Checks if a SCEV expression represents a valid affine expression.
9//===----------------------------------------------------------------------===//
10
11#ifndef POLLY_SCEV_VALIDATOR_H
12#define POLLY_SCEV_VALIDATOR_H
13
15
16namespace llvm {
17class SCEVConstant;
18} // namespace llvm
19
20namespace polly {
21class ScopDetection;
22
23/// Find the loops referenced from a SCEV expression.
24///
25/// @param Expr The SCEV expression to scan for loops.
26/// @param Loops A vector into which the found loops are inserted.
27void findLoops(const llvm::SCEV *Expr,
28 llvm::SetVector<const llvm::Loop *> &Loops);
29
30/// Find the values referenced by SCEVUnknowns in a given SCEV
31/// expression.
32///
33/// @param Expr The SCEV expression to scan for SCEVUnknowns.
34/// @param SE The ScalarEvolution analysis for this function.
35/// @param Values A vector into which the found values are inserted.
36void findValues(const llvm::SCEV *Expr, llvm::ScalarEvolution &SE,
37 llvm::SetVector<llvm::Value *> &Values);
38
39/// Returns true when the SCEV contains references to instructions within the
40/// region.
41///
42/// @param Expr The SCEV to analyze.
43/// @param R The region in which we look for dependences.
44/// @param Scope Location where the value is needed.
45/// @param AllowLoops Whether loop recurrences outside the loop that are in the
46/// region count as dependence.
47bool hasScalarDepsInsideRegion(const llvm::SCEV *Expr, const llvm::Region *R,
48 llvm::Loop *Scope, bool AllowLoops,
49 const InvariantLoadsSetTy &ILS);
50bool isAffineExpr(const llvm::Region *R, llvm::Loop *Scope,
51 const llvm::SCEV *Expression, llvm::ScalarEvolution &SE,
52 InvariantLoadsSetTy *ILS = nullptr);
53
54/// Check if @p V describes an affine constraint in @p R.
55bool isAffineConstraint(llvm::Value *V, const llvm::Region *R,
56 llvm::Loop *Scope, llvm::ScalarEvolution &SE,
57 ParameterSetTy &Params, bool OrExpr = false);
58
59ParameterSetTy getParamsInAffineExpr(const llvm::Region *R, llvm::Loop *Scope,
60 const llvm::SCEV *Expression,
61 llvm::ScalarEvolution &SE);
62
63/// Extract the constant factors from the multiplication @p M.
64///
65/// @param M A potential SCEV multiplication.
66/// @param SE The ScalarEvolution analysis to create new SCEVs.
67///
68/// @returns The constant factor in @p M and the rest of @p M.
69std::pair<const llvm::SCEVConstant *, const llvm::SCEV *>
70extractConstantFactor(const llvm::SCEV *M, llvm::ScalarEvolution &SE);
71
72/// Try to look through PHI nodes, where some incoming edges come from error
73/// blocks.
74///
75/// In case a PHI node follows an error block we can assume that the incoming
76/// value can only come from the node that is not an error block. As a result,
77/// conditions that seemed non-affine before are now in fact affine.
78const llvm::SCEV *tryForwardThroughPHI(const llvm::SCEV *Expr, llvm::Region &R,
79 llvm::ScalarEvolution &SE,
80 ScopDetection *SD);
81
82/// Return a unique non-error block incoming value for @p PHI if available.
83///
84/// @param R The region to run our code on.
85/// @param SD The ScopDetection
86llvm::Value *getUniqueNonErrorValue(llvm::PHINode *PHI, llvm::Region *R,
87 ScopDetection *SD);
88} // namespace polly
89
90#endif
static RegisterPass< ScopPrinterWrapperPass > M("dot-scops", "Polly - Print Scops of function")
Pass to detect the maximal static control parts (Scops) of a function.
This file contains the declaration of the PolyhedralInfo class, which will provide an interface to ex...
bool isAffineConstraint(llvm::Value *V, const llvm::Region *R, llvm::Loop *Scope, llvm::ScalarEvolution &SE, ParameterSetTy &Params, bool OrExpr=false)
Check if V describes an affine constraint in R.
void findValues(const llvm::SCEV *Expr, llvm::ScalarEvolution &SE, llvm::SetVector< llvm::Value * > &Values)
Find the values referenced by SCEVUnknowns in a given SCEV expression.
void findLoops(const llvm::SCEV *Expr, llvm::SetVector< const llvm::Loop * > &Loops)
Find the loops referenced from a SCEV expression.
bool isAffineExpr(const llvm::Region *R, llvm::Loop *Scope, const llvm::SCEV *Expression, llvm::ScalarEvolution &SE, InvariantLoadsSetTy *ILS=nullptr)
@ PHI
MemoryKind::PHI: Models PHI nodes within the SCoP.
const llvm::SCEV * tryForwardThroughPHI(const llvm::SCEV *Expr, llvm::Region &R, llvm::ScalarEvolution &SE, ScopDetection *SD)
Try to look through PHI nodes, where some incoming edges come from error blocks.
llvm::SetVector< llvm::AssertingVH< llvm::LoadInst > > InvariantLoadsSetTy
Type for a set of invariant loads.
Definition: ScopHelper.h:106
std::pair< const llvm::SCEVConstant *, const llvm::SCEV * > extractConstantFactor(const llvm::SCEV *M, llvm::ScalarEvolution &SE)
Extract the constant factors from the multiplication M.
llvm::SetVector< const llvm::SCEV * > ParameterSetTy
Set type for parameters.
Definition: ScopHelper.h:109
ParameterSetTy getParamsInAffineExpr(const llvm::Region *R, llvm::Loop *Scope, const llvm::SCEV *Expression, llvm::ScalarEvolution &SE)
bool hasScalarDepsInsideRegion(const llvm::SCEV *Expr, const llvm::Region *R, llvm::Loop *Scope, bool AllowLoops, const InvariantLoadsSetTy &ILS)
Returns true when the SCEV contains references to instructions within the region.
llvm::Value * getUniqueNonErrorValue(llvm::PHINode *PHI, llvm::Region *R, ScopDetection *SD)
Return a unique non-error block incoming value for PHI if available.