LLVM  7.0.0svn
Macros | Functions
LoopUtils.cpp File Reference
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/BasicAliasAnalysis.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
#include "llvm/Analysis/ScalarEvolutionExpander.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
Include dependency graph for LoopUtils.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "loop-utils"
 

Functions

static bool getCastsForInductionPHI (PredicatedScalarEvolution &PSE, const SCEVUnknown *PhiScev, const SCEVAddRecExpr *AR, SmallVectorImpl< Instruction *> &CastInsts)
 This function is called when we suspect that the update-chain of a phi node (whose symbolic SCEV expression sin PhiScev) contains redundant casts, that can be ignored. More...
 
static ValueaddFastMathFlag (Value *V)
 Adds a 'fast' flag to floating point operations. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "loop-utils"

Definition at line 38 of file LoopUtils.cpp.

Function Documentation

◆ addFastMathFlag()

static Value* addFastMathFlag ( Value V)
static

Adds a 'fast' flag to floating point operations.

Definition at line 1488 of file LoopUtils.cpp.

References llvm::FastMathFlags::setFast().

Referenced by llvm::getShuffleReduction().

◆ getCastsForInductionPHI()

static bool getCastsForInductionPHI ( PredicatedScalarEvolution PSE,
const SCEVUnknown PhiScev,
const SCEVAddRecExpr AR,
SmallVectorImpl< Instruction *> &  CastInsts 
)
static

This function is called when we suspect that the update-chain of a phi node (whose symbolic SCEV expression sin PhiScev) contains redundant casts, that can be ignored.

(This can happen when the PSCEV rewriter adds a runtime predicate P under which the SCEV expression for the phi can be the AddRecurrence AR; See createAddRecFromPHIWithCast). We want to find the cast instructions that are involved in the update-chain of this induction. A caller that adds the required runtime predicate can be free to drop these cast instructions, and compute the phi using AR (instead of some scev expression with casts).

For example, without a predicate the scev expression can take the following form: (Ext ix (Trunc iy ( Start + i*Step ) to ix) to iy)

It corresponds to the following IR sequence: for.body: x = phi i64 [ 0, ph ], [ add, for.body ] casted_phi = "ExtTrunc i64 %x" add = add i64 casted_phi, step

where x is given in PN, PSE.getSCEV(x) is equal to PSE.getSCEV(casted_phi) under a predicate, and the IR sequence that "ExtTrunc i64 %x" represents can take one of several forms, for example, such as: ExtTrunc1: casted_phi = and x, 2^n-1 or: ExtTrunc2: t = shl x, m casted_phi = ashr t, m

If we are able to find such sequence, we return the instructions we found, namely casted_phi and the instructions on its use-def chain up to the phi (not including the phi).

Definition at line 883 of file LoopUtils.cpp.

References llvm::PredicatedScalarEvolution::areAddRecsEqualWithPreds(), assert(), llvm::tgtok::Def, llvm::dyn_cast(), llvm::SmallVectorBase::empty(), getDef(), llvm::SCEVAddRecExpr::getLoop(), llvm::User::getOperand(), llvm::PredicatedScalarEvolution::getSCEV(), llvm::SCEVUnknown::getValue(), and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().

Referenced by llvm::InductionDescriptor::isInductionPHI().