LLVM  4.0.0
PPCLoopPreIncPrep.cpp
Go to the documentation of this file.
1 //===------ PPCLoopPreIncPrep.cpp - Loop Pre-Inc. AM Prep. Pass -----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements a pass to prepare loops for pre-increment addressing
11 // modes. Additional PHIs are created for loop induction variables used by
12 // load/store instructions so that the pre-increment forms can be used.
13 // Generically, this means transforming loops like this:
14 // for (int i = 0; i < n; ++i)
15 // array[i] = c;
16 // to look like this:
17 // T *p = array[-1];
18 // for (int i = 0; i < n; ++i)
19 // *++p = c;
20 //===----------------------------------------------------------------------===//
21 
22 #define DEBUG_TYPE "ppc-loop-preinc-prep"
23 
24 #include "PPC.h"
25 #include "PPCSubtarget.h"
26 #include "PPCTargetMachine.h"
28 #include "llvm/ADT/SmallPtrSet.h"
29 #include "llvm/ADT/SmallSet.h"
30 #include "llvm/ADT/SmallVector.h"
31 #include "llvm/Analysis/LoopInfo.h"
35 #include "llvm/IR/BasicBlock.h"
36 #include "llvm/IR/CFG.h"
37 #include "llvm/IR/Dominators.h"
38 #include "llvm/IR/Instruction.h"
39 #include "llvm/IR/Instructions.h"
40 #include "llvm/IR/IntrinsicInst.h"
41 #include "llvm/IR/Module.h"
42 #include "llvm/IR/Value.h"
43 #include "llvm/Pass.h"
44 #include "llvm/Support/Casting.h"
46 #include "llvm/Support/Debug.h"
47 #include "llvm/Transforms/Scalar.h"
51 #include <cassert>
52 #include <iterator>
53 #include <utility>
54 
55 using namespace llvm;
56 
57 // By default, we limit this to creating 16 PHIs (which is a little over half
58 // of the allocatable register set).
59 static cl::opt<unsigned> MaxVars("ppc-preinc-prep-max-vars",
60  cl::Hidden, cl::init(16),
61  cl::desc("Potential PHI threshold for PPC preinc loop prep"));
62 
63 namespace llvm {
64 
66 
67 } // end namespace llvm
68 
69 namespace {
70 
71  class PPCLoopPreIncPrep : public FunctionPass {
72  public:
73  static char ID; // Pass ID, replacement for typeid
74 
75  PPCLoopPreIncPrep() : FunctionPass(ID), TM(nullptr) {
77  }
78  PPCLoopPreIncPrep(PPCTargetMachine &TM) : FunctionPass(ID), TM(&TM) {
80  }
81 
82  void getAnalysisUsage(AnalysisUsage &AU) const override {
87  }
88 
89  bool runOnFunction(Function &F) override;
90 
91  bool runOnLoop(Loop *L);
92  void simplifyLoopLatch(Loop *L);
93  bool rotateLoop(Loop *L);
94 
95  private:
97  DominatorTree *DT;
98  LoopInfo *LI;
99  ScalarEvolution *SE;
100  bool PreserveLCSSA;
101  };
102 
103 } // end anonymous namespace
104 
105 char PPCLoopPreIncPrep::ID = 0;
106 static const char *name = "Prepare loop for pre-inc. addressing modes";
107 INITIALIZE_PASS_BEGIN(PPCLoopPreIncPrep, DEBUG_TYPE, name, false, false)
110 INITIALIZE_PASS_END(PPCLoopPreIncPrep, DEBUG_TYPE, name, false, false)
111 
113  return new PPCLoopPreIncPrep(TM);
114 }
115 
116 namespace {
117 
118  struct BucketElement {
119  BucketElement(const SCEVConstant *O, Instruction *I) : Offset(O), Instr(I) {}
120  BucketElement(Instruction *I) : Offset(nullptr), Instr(I) {}
121 
122  const SCEVConstant *Offset;
123  Instruction *Instr;
124  };
125 
126  struct Bucket {
127  Bucket(const SCEV *B, Instruction *I) : BaseSCEV(B),
128  Elements(1, BucketElement(I)) {}
129 
130  const SCEV *BaseSCEV;
132  };
133 
134 } // end anonymous namespace
135 
136 static bool IsPtrInBounds(Value *BasePtr) {
137  Value *StrippedBasePtr = BasePtr;
138  while (BitCastInst *BC = dyn_cast<BitCastInst>(StrippedBasePtr))
139  StrippedBasePtr = BC->getOperand(0);
140  if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(StrippedBasePtr))
141  return GEP->isInBounds();
142 
143  return false;
144 }
145 
146 static Value *GetPointerOperand(Value *MemI) {
147  if (LoadInst *LMemI = dyn_cast<LoadInst>(MemI)) {
148  return LMemI->getPointerOperand();
149  } else if (StoreInst *SMemI = dyn_cast<StoreInst>(MemI)) {
150  return SMemI->getPointerOperand();
151  } else if (IntrinsicInst *IMemI = dyn_cast<IntrinsicInst>(MemI)) {
152  if (IMemI->getIntrinsicID() == Intrinsic::prefetch)
153  return IMemI->getArgOperand(0);
154  }
155 
156  return nullptr;
157 }
158 
159 bool PPCLoopPreIncPrep::runOnFunction(Function &F) {
160  if (skipFunction(F))
161  return false;
162 
163  LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
164  SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
165  auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>();
166  DT = DTWP ? &DTWP->getDomTree() : nullptr;
167  PreserveLCSSA = mustPreserveAnalysisID(LCSSAID);
168 
169  bool MadeChange = false;
170 
171  for (auto I = LI->begin(), IE = LI->end(); I != IE; ++I)
172  for (auto L = df_begin(*I), LE = df_end(*I); L != LE; ++L)
173  MadeChange |= runOnLoop(*L);
174 
175  return MadeChange;
176 }
177 
178 bool PPCLoopPreIncPrep::runOnLoop(Loop *L) {
179  bool MadeChange = false;
180 
181  // Only prep. the inner-most loop
182  if (!L->empty())
183  return MadeChange;
184 
185  DEBUG(dbgs() << "PIP: Examining: " << *L << "\n");
186 
187  BasicBlock *Header = L->getHeader();
188 
189  const PPCSubtarget *ST =
190  TM ? TM->getSubtargetImpl(*Header->getParent()) : nullptr;
191 
192  unsigned HeaderLoopPredCount =
193  std::distance(pred_begin(Header), pred_end(Header));
194 
195  // Collect buckets of comparable addresses used by loads and stores.
196  SmallVector<Bucket, 16> Buckets;
197  for (Loop::block_iterator I = L->block_begin(), IE = L->block_end();
198  I != IE; ++I) {
199  for (BasicBlock::iterator J = (*I)->begin(), JE = (*I)->end();
200  J != JE; ++J) {
201  Value *PtrValue;
202  Instruction *MemI;
203 
204  if (LoadInst *LMemI = dyn_cast<LoadInst>(J)) {
205  MemI = LMemI;
206  PtrValue = LMemI->getPointerOperand();
207  } else if (StoreInst *SMemI = dyn_cast<StoreInst>(J)) {
208  MemI = SMemI;
209  PtrValue = SMemI->getPointerOperand();
210  } else if (IntrinsicInst *IMemI = dyn_cast<IntrinsicInst>(J)) {
211  if (IMemI->getIntrinsicID() == Intrinsic::prefetch) {
212  MemI = IMemI;
213  PtrValue = IMemI->getArgOperand(0);
214  } else continue;
215  } else continue;
216 
217  unsigned PtrAddrSpace = PtrValue->getType()->getPointerAddressSpace();
218  if (PtrAddrSpace)
219  continue;
220 
221  // There are no update forms for Altivec vector load/stores.
222  if (ST && ST->hasAltivec() &&
223  PtrValue->getType()->getPointerElementType()->isVectorTy())
224  continue;
225 
226  if (L->isLoopInvariant(PtrValue))
227  continue;
228 
229  const SCEV *LSCEV = SE->getSCEVAtScope(PtrValue, L);
230  if (const SCEVAddRecExpr *LARSCEV = dyn_cast<SCEVAddRecExpr>(LSCEV)) {
231  if (LARSCEV->getLoop() != L)
232  continue;
233  } else {
234  continue;
235  }
236 
237  bool FoundBucket = false;
238  for (auto &B : Buckets) {
239  const SCEV *Diff = SE->getMinusSCEV(LSCEV, B.BaseSCEV);
240  if (const auto *CDiff = dyn_cast<SCEVConstant>(Diff)) {
241  B.Elements.push_back(BucketElement(CDiff, MemI));
242  FoundBucket = true;
243  break;
244  }
245  }
246 
247  if (!FoundBucket) {
248  if (Buckets.size() == MaxVars)
249  return MadeChange;
250  Buckets.push_back(Bucket(LSCEV, MemI));
251  }
252  }
253  }
254 
255  if (Buckets.empty())
256  return MadeChange;
257 
258  BasicBlock *LoopPredecessor = L->getLoopPredecessor();
259  // If there is no loop predecessor, or the loop predecessor's terminator
260  // returns a value (which might contribute to determining the loop's
261  // iteration space), insert a new preheader for the loop.
262  if (!LoopPredecessor ||
263  !LoopPredecessor->getTerminator()->getType()->isVoidTy()) {
264  LoopPredecessor = InsertPreheaderForLoop(L, DT, LI, PreserveLCSSA);
265  if (LoopPredecessor)
266  MadeChange = true;
267  }
268  if (!LoopPredecessor)
269  return MadeChange;
270 
271  DEBUG(dbgs() << "PIP: Found " << Buckets.size() << " buckets\n");
272 
273  SmallSet<BasicBlock *, 16> BBChanged;
274  for (unsigned i = 0, e = Buckets.size(); i != e; ++i) {
275  // The base address of each bucket is transformed into a phi and the others
276  // are rewritten as offsets of that variable.
277 
278  // We have a choice now of which instruction's memory operand we use as the
279  // base for the generated PHI. Always picking the first instruction in each
280  // bucket does not work well, specifically because that instruction might
281  // be a prefetch (and there are no pre-increment dcbt variants). Otherwise,
282  // the choice is somewhat arbitrary, because the backend will happily
283  // generate direct offsets from both the pre-incremented and
284  // post-incremented pointer values. Thus, we'll pick the first non-prefetch
285  // instruction in each bucket, and adjust the recurrence and other offsets
286  // accordingly.
287  for (int j = 0, je = Buckets[i].Elements.size(); j != je; ++j) {
288  if (auto *II = dyn_cast<IntrinsicInst>(Buckets[i].Elements[j].Instr))
289  if (II->getIntrinsicID() == Intrinsic::prefetch)
290  continue;
291 
292  // If we'd otherwise pick the first element anyway, there's nothing to do.
293  if (j == 0)
294  break;
295 
296  // If our chosen element has no offset from the base pointer, there's
297  // nothing to do.
298  if (!Buckets[i].Elements[j].Offset ||
299  Buckets[i].Elements[j].Offset->isZero())
300  break;
301 
302  const SCEV *Offset = Buckets[i].Elements[j].Offset;
303  Buckets[i].BaseSCEV = SE->getAddExpr(Buckets[i].BaseSCEV, Offset);
304  for (auto &E : Buckets[i].Elements) {
305  if (E.Offset)
306  E.Offset = cast<SCEVConstant>(SE->getMinusSCEV(E.Offset, Offset));
307  else
308  E.Offset = cast<SCEVConstant>(SE->getNegativeSCEV(Offset));
309  }
310 
311  std::swap(Buckets[i].Elements[j], Buckets[i].Elements[0]);
312  break;
313  }
314 
315  const SCEVAddRecExpr *BasePtrSCEV =
316  cast<SCEVAddRecExpr>(Buckets[i].BaseSCEV);
317  if (!BasePtrSCEV->isAffine())
318  continue;
319 
320  DEBUG(dbgs() << "PIP: Transforming: " << *BasePtrSCEV << "\n");
321  assert(BasePtrSCEV->getLoop() == L &&
322  "AddRec for the wrong loop?");
323 
324  // The instruction corresponding to the Bucket's BaseSCEV must be the first
325  // in the vector of elements.
326  Instruction *MemI = Buckets[i].Elements.begin()->Instr;
327  Value *BasePtr = GetPointerOperand(MemI);
328  assert(BasePtr && "No pointer operand");
329 
330  Type *I8Ty = Type::getInt8Ty(MemI->getParent()->getContext());
331  Type *I8PtrTy = Type::getInt8PtrTy(MemI->getParent()->getContext(),
332  BasePtr->getType()->getPointerAddressSpace());
333 
334  const SCEV *BasePtrStartSCEV = BasePtrSCEV->getStart();
335  if (!SE->isLoopInvariant(BasePtrStartSCEV, L))
336  continue;
337 
338  const SCEVConstant *BasePtrIncSCEV =
339  dyn_cast<SCEVConstant>(BasePtrSCEV->getStepRecurrence(*SE));
340  if (!BasePtrIncSCEV)
341  continue;
342  BasePtrStartSCEV = SE->getMinusSCEV(BasePtrStartSCEV, BasePtrIncSCEV);
343  if (!isSafeToExpand(BasePtrStartSCEV, *SE))
344  continue;
345 
346  DEBUG(dbgs() << "PIP: New start is: " << *BasePtrStartSCEV << "\n");
347 
348  PHINode *NewPHI = PHINode::Create(I8PtrTy, HeaderLoopPredCount,
349  MemI->hasName() ? MemI->getName() + ".phi" : "",
350  Header->getFirstNonPHI());
351 
352  SCEVExpander SCEVE(*SE, Header->getModule()->getDataLayout(), "pistart");
353  Value *BasePtrStart = SCEVE.expandCodeFor(BasePtrStartSCEV, I8PtrTy,
354  LoopPredecessor->getTerminator());
355 
356  // Note that LoopPredecessor might occur in the predecessor list multiple
357  // times, and we need to add it the right number of times.
358  for (pred_iterator PI = pred_begin(Header), PE = pred_end(Header);
359  PI != PE; ++PI) {
360  if (*PI != LoopPredecessor)
361  continue;
362 
363  NewPHI->addIncoming(BasePtrStart, LoopPredecessor);
364  }
365 
366  Instruction *InsPoint = &*Header->getFirstInsertionPt();
368  I8Ty, NewPHI, BasePtrIncSCEV->getValue(),
369  MemI->hasName() ? MemI->getName() + ".inc" : "", InsPoint);
370  PtrInc->setIsInBounds(IsPtrInBounds(BasePtr));
371  for (pred_iterator PI = pred_begin(Header), PE = pred_end(Header);
372  PI != PE; ++PI) {
373  if (*PI == LoopPredecessor)
374  continue;
375 
376  NewPHI->addIncoming(PtrInc, *PI);
377  }
378 
379  Instruction *NewBasePtr;
380  if (PtrInc->getType() != BasePtr->getType())
381  NewBasePtr = new BitCastInst(PtrInc, BasePtr->getType(),
382  PtrInc->hasName() ? PtrInc->getName() + ".cast" : "", InsPoint);
383  else
384  NewBasePtr = PtrInc;
385 
386  if (Instruction *IDel = dyn_cast<Instruction>(BasePtr))
387  BBChanged.insert(IDel->getParent());
388  BasePtr->replaceAllUsesWith(NewBasePtr);
390 
391  // Keep track of the replacement pointer values we've inserted so that we
392  // don't generate more pointer values than necessary.
393  SmallPtrSet<Value *, 16> NewPtrs;
394  NewPtrs.insert( NewBasePtr);
395 
396  for (auto I = std::next(Buckets[i].Elements.begin()),
397  IE = Buckets[i].Elements.end(); I != IE; ++I) {
398  Value *Ptr = GetPointerOperand(I->Instr);
399  assert(Ptr && "No pointer operand");
400  if (NewPtrs.count(Ptr))
401  continue;
402 
403  Instruction *RealNewPtr;
404  if (!I->Offset || I->Offset->getValue()->isZero()) {
405  RealNewPtr = NewBasePtr;
406  } else {
407  Instruction *PtrIP = dyn_cast<Instruction>(Ptr);
408  if (PtrIP && isa<Instruction>(NewBasePtr) &&
409  cast<Instruction>(NewBasePtr)->getParent() == PtrIP->getParent())
410  PtrIP = nullptr;
411  else if (isa<PHINode>(PtrIP))
412  PtrIP = &*PtrIP->getParent()->getFirstInsertionPt();
413  else if (!PtrIP)
414  PtrIP = I->Instr;
415 
417  I8Ty, PtrInc, I->Offset->getValue(),
418  I->Instr->hasName() ? I->Instr->getName() + ".off" : "", PtrIP);
419  if (!PtrIP)
420  NewPtr->insertAfter(cast<Instruction>(PtrInc));
421  NewPtr->setIsInBounds(IsPtrInBounds(Ptr));
422  RealNewPtr = NewPtr;
423  }
424 
425  if (Instruction *IDel = dyn_cast<Instruction>(Ptr))
426  BBChanged.insert(IDel->getParent());
427 
428  Instruction *ReplNewPtr;
429  if (Ptr->getType() != RealNewPtr->getType()) {
430  ReplNewPtr = new BitCastInst(RealNewPtr, Ptr->getType(),
431  Ptr->hasName() ? Ptr->getName() + ".cast" : "");
432  ReplNewPtr->insertAfter(RealNewPtr);
433  } else
434  ReplNewPtr = RealNewPtr;
435 
436  Ptr->replaceAllUsesWith(ReplNewPtr);
438 
439  NewPtrs.insert(RealNewPtr);
440  }
441 
442  MadeChange = true;
443  }
444 
445  for (Loop::block_iterator I = L->block_begin(), IE = L->block_end();
446  I != IE; ++I) {
447  if (BBChanged.count(*I))
448  DeleteDeadPHIs(*I);
449  }
450 
451  return MadeChange;
452 }
MachineLoop * L
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
bool hasName() const
Definition: Value.h:236
size_t i
The main scalar evolution driver.
size_type count(PtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Definition: SmallPtrSet.h:380
BasicBlock * InsertPreheaderForLoop(Loop *L, DominatorTree *DT, LoopInfo *LI, bool PreserveLCSSA)
InsertPreheaderForLoop - Once we discover that a loop doesn't have a preheader, this method is called...
const SCEV * getStepRecurrence(ScalarEvolution &SE) const
Constructs and returns the recurrence indicating how much this expression steps by.
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:100
An instruction for reading from memory.
Definition: Instructions.h:164
Hexagon Common GEP
loop data prefetch
bool hasAltivec() const
Definition: PPCSubtarget.h:239
BlockT * getHeader() const
Definition: LoopInfo.h:102
Type * getPointerElementType() const
Definition: Type.h:358
const SCEV * getStart() const
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:191
static Value * GetPointerOperand(Value *MemI)
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:53
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr it the function does no...
Definition: BasicBlock.cpp:116
void setIsInBounds(bool b=true)
Set or clear the inbounds flag on this GEP instruction.
Instruction * getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
Definition: BasicBlock.cpp:180
bool isLoopInvariant(const Value *V) const
Return true if the specified value is loop invariant.
Definition: LoopInfo.cpp:55
#define DEBUG_TYPE
#define F(x, y, z)
Definition: MD5.cpp:51
void initializePPCLoopPreIncPrepPass(PassRegistry &)
This node represents a polynomial recurrence on the trip count of the specified loop.
Function Alias Analysis false
bool DeleteDeadPHIs(BasicBlock *BB, const TargetLibraryInfo *TLI=nullptr)
Examine each PHI in the given block and delete it if it is dead.
This class represents a no-op cast from one type to another.
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
An instruction for storing to memory.
Definition: Instructions.h:300
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:401
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:96
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
Definition: Instructions.h:830
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:395
bool isAffine() const
Return true if this represents an expression A + B*x where A and B are loop invariant values...
LLVM Basic Block Representation.
Definition: BasicBlock.h:51
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
bool isVectorTy() const
True if this is an instance of VectorType.
Definition: Type.h:219
df_iterator< T > df_end(const T &G)
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:36
char & LCSSAID
Definition: LCSSA.cpp:379
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:368
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
Definition: Interval.h:116
Represent the analysis usage information of a pass.
uint32_t Offset
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298
Interval::pred_iterator pred_end(Interval *I)
Definition: Interval.h:119
Common code between 32-bit and 64-bit PowerPC targets.
bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=nullptr)
If the specified value is a trivially dead instruction, delete it.
Definition: Local.cpp:355
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
Definition: Type.cpp:213
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Definition: Instructions.h:857
Iterator for intrusive lists based on ilist_node.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:843
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:230
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:50
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
ConstantInt * getValue() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:586
df_iterator< T > df_begin(const T &G)
This class uses information about analyze scalars to rewrite expressions in canonical form...
std::vector< BlockT * >::const_iterator block_iterator
Definition: LoopInfo.h:140
block_iterator block_end() const
Definition: LoopInfo.h:142
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:384
This class represents an analyzed expression in the program.
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:368
void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction...
Definition: Instruction.cpp:88
#define I(x, y, z)
Definition: MD5.cpp:54
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Definition: BasicBlock.cpp:124
BlockT * getLoopPredecessor() const
If the given loop's header has exactly one unique predecessor outside the loop, return it...
Definition: LoopInfoImpl.h:131
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:287
const Loop * getLoop() const
static bool IsPtrInBounds(Value *BasePtr)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
FunctionPass * createPPCLoopPreIncPrepPass(PPCTargetMachine &TM)
LLVM Value Representation.
Definition: Value.h:71
static const char * name
static const Function * getParent(const Value *V)
bool empty() const
Definition: LoopInfo.h:136
#define DEBUG(X)
Definition: Debug.h:100
block_iterator block_begin() const
Definition: LoopInfo.h:141
static cl::opt< unsigned > MaxVars("ppc-preinc-prep-max-vars", cl::Hidden, cl::init(16), cl::desc("Potential PHI threshold for PPC preinc loop prep"))
The legacy pass manager's analysis pass to compute loop information.
Definition: LoopInfo.h:831
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:40
Legacy analysis pass which computes a DominatorTree.
Definition: Dominators.h:217
iterator getFirstInsertionPt()
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
Definition: BasicBlock.cpp:209
int * Ptr
bool isSafeToExpand(const SCEV *S, ScalarEvolution &SE)
Return true if the given expression is safe to expand in the sense that all materialized values are s...
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Definition: DerivedTypes.h:479
static IntegerType * getInt8Ty(LLVMContext &C)
Definition: Type.cpp:167
const BasicBlock * getParent() const
Definition: Instruction.h:62
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:44
bool isVoidTy() const
Return true if this is 'void'.
Definition: Type.h:139
This class represents a constant integer value.