LLVM  15.0.0git
PHITransAddr.cpp
Go to the documentation of this file.
1 //===- PHITransAddr.cpp - PHI Translation for Addresses -------------------===//
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 implements the PHITransAddr class.
10 //
11 //===----------------------------------------------------------------------===//
12 
16 #include "llvm/Config/llvm-config.h"
17 #include "llvm/IR/Constants.h"
18 #include "llvm/IR/Dominators.h"
19 #include "llvm/IR/Instructions.h"
22 using namespace llvm;
23 
24 static bool CanPHITrans(Instruction *Inst) {
25  if (isa<PHINode>(Inst) ||
26  isa<GetElementPtrInst>(Inst))
27  return true;
28 
29  if (isa<CastInst>(Inst) &&
31  return true;
32 
33  if (Inst->getOpcode() == Instruction::Add &&
34  isa<ConstantInt>(Inst->getOperand(1)))
35  return true;
36 
37  // cerr << "MEMDEP: Could not PHI translate: " << *Pointer;
38  // if (isa<BitCastInst>(PtrInst) || isa<GetElementPtrInst>(PtrInst))
39  // cerr << "OP:\t\t\t\t" << *PtrInst->getOperand(0);
40  return false;
41 }
42 
43 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
45  if (!Addr) {
46  dbgs() << "PHITransAddr: null\n";
47  return;
48  }
49  dbgs() << "PHITransAddr: " << *Addr << "\n";
50  for (unsigned i = 0, e = InstInputs.size(); i != e; ++i)
51  dbgs() << " Input #" << i << " is " << *InstInputs[i] << "\n";
52 }
53 #endif
54 
55 
56 static bool VerifySubExpr(Value *Expr,
57  SmallVectorImpl<Instruction*> &InstInputs) {
58  // If this is a non-instruction value, there is nothing to do.
59  Instruction *I = dyn_cast<Instruction>(Expr);
60  if (!I) return true;
61 
62  // If it's an instruction, it is either in Tmp or its operands recursively
63  // are.
64  SmallVectorImpl<Instruction *>::iterator Entry = find(InstInputs, I);
65  if (Entry != InstInputs.end()) {
66  InstInputs.erase(Entry);
67  return true;
68  }
69 
70  // If it isn't in the InstInputs list it is a subexpr incorporated into the
71  // address. Validate that it is phi translatable.
72  if (!CanPHITrans(I)) {
73  errs() << "Instruction in PHITransAddr is not phi-translatable:\n";
74  errs() << *I << '\n';
75  llvm_unreachable("Either something is missing from InstInputs or "
76  "CanPHITrans is wrong.");
77  }
78 
79  // Validate the operands of the instruction.
80  for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
81  if (!VerifySubExpr(I->getOperand(i), InstInputs))
82  return false;
83 
84  return true;
85 }
86 
87 /// Verify - Check internal consistency of this data structure. If the
88 /// structure is valid, it returns true. If invalid, it prints errors and
89 /// returns false.
90 bool PHITransAddr::Verify() const {
91  if (!Addr) return true;
92 
93  SmallVector<Instruction*, 8> Tmp(InstInputs.begin(), InstInputs.end());
94 
95  if (!VerifySubExpr(Addr, Tmp))
96  return false;
97 
98  if (!Tmp.empty()) {
99  errs() << "PHITransAddr contains extra instructions:\n";
100  for (unsigned i = 0, e = InstInputs.size(); i != e; ++i)
101  errs() << " InstInput #" << i << " is " << *InstInputs[i] << "\n";
102  llvm_unreachable("This is unexpected.");
103  }
104 
105  // a-ok.
106  return true;
107 }
108 
109 
110 /// IsPotentiallyPHITranslatable - If this needs PHI translation, return true
111 /// if we have some hope of doing it. This should be used as a filter to
112 /// avoid calling PHITranslateValue in hopeless situations.
114  // If the input value is not an instruction, or if it is not defined in CurBB,
115  // then we don't need to phi translate it.
116  Instruction *Inst = dyn_cast<Instruction>(Addr);
117  return !Inst || CanPHITrans(Inst);
118 }
119 
120 
121 static void RemoveInstInputs(Value *V,
122  SmallVectorImpl<Instruction*> &InstInputs) {
123  Instruction *I = dyn_cast<Instruction>(V);
124  if (!I) return;
125 
126  // If the instruction is in the InstInputs list, remove it.
127  SmallVectorImpl<Instruction *>::iterator Entry = find(InstInputs, I);
128  if (Entry != InstInputs.end()) {
129  InstInputs.erase(Entry);
130  return;
131  }
132 
133  assert(!isa<PHINode>(I) && "Error, removing something that isn't an input");
134 
135  // Otherwise, it must have instruction inputs itself. Zap them recursively.
136  for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) {
137  if (Instruction *Op = dyn_cast<Instruction>(I->getOperand(i)))
138  RemoveInstInputs(Op, InstInputs);
139  }
140 }
141 
142 Value *PHITransAddr::PHITranslateSubExpr(Value *V, BasicBlock *CurBB,
143  BasicBlock *PredBB,
144  const DominatorTree *DT) {
145  // If this is a non-instruction value, it can't require PHI translation.
146  Instruction *Inst = dyn_cast<Instruction>(V);
147  if (!Inst) return V;
148 
149  // Determine whether 'Inst' is an input to our PHI translatable expression.
150  bool isInput = is_contained(InstInputs, Inst);
151 
152  // Handle inputs instructions if needed.
153  if (isInput) {
154  if (Inst->getParent() != CurBB) {
155  // If it is an input defined in a different block, then it remains an
156  // input.
157  return Inst;
158  }
159 
160  // If 'Inst' is defined in this block and is an input that needs to be phi
161  // translated, we need to incorporate the value into the expression or fail.
162 
163  // In either case, the instruction itself isn't an input any longer.
164  InstInputs.erase(find(InstInputs, Inst));
165 
166  // If this is a PHI, go ahead and translate it.
167  if (PHINode *PN = dyn_cast<PHINode>(Inst))
168  return AddAsInput(PN->getIncomingValueForBlock(PredBB));
169 
170  // If this is a non-phi value, and it is analyzable, we can incorporate it
171  // into the expression by making all instruction operands be inputs.
172  if (!CanPHITrans(Inst))
173  return nullptr;
174 
175  // All instruction operands are now inputs (and of course, they may also be
176  // defined in this block, so they may need to be phi translated themselves.
177  for (unsigned i = 0, e = Inst->getNumOperands(); i != e; ++i)
178  if (Instruction *Op = dyn_cast<Instruction>(Inst->getOperand(i)))
179  InstInputs.push_back(Op);
180  }
181 
182  // Ok, it must be an intermediate result (either because it started that way
183  // or because we just incorporated it into the expression). See if its
184  // operands need to be phi translated, and if so, reconstruct it.
185 
186  if (CastInst *Cast = dyn_cast<CastInst>(Inst)) {
187  if (!isSafeToSpeculativelyExecute(Cast)) return nullptr;
188  Value *PHIIn = PHITranslateSubExpr(Cast->getOperand(0), CurBB, PredBB, DT);
189  if (!PHIIn) return nullptr;
190  if (PHIIn == Cast->getOperand(0))
191  return Cast;
192 
193  // Find an available version of this cast.
194 
195  // Constants are trivial to find.
196  if (Constant *C = dyn_cast<Constant>(PHIIn))
197  return AddAsInput(ConstantExpr::getCast(Cast->getOpcode(),
198  C, Cast->getType()));
199 
200  // Otherwise we have to see if a casted version of the incoming pointer
201  // is available. If so, we can use it, otherwise we have to fail.
202  for (User *U : PHIIn->users()) {
203  if (CastInst *CastI = dyn_cast<CastInst>(U))
204  if (CastI->getOpcode() == Cast->getOpcode() &&
205  CastI->getType() == Cast->getType() &&
206  (!DT || DT->dominates(CastI->getParent(), PredBB)))
207  return CastI;
208  }
209  return nullptr;
210  }
211 
212  // Handle getelementptr with at least one PHI translatable operand.
213  if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Inst)) {
214  SmallVector<Value*, 8> GEPOps;
215  bool AnyChanged = false;
216  for (unsigned i = 0, e = GEP->getNumOperands(); i != e; ++i) {
217  Value *GEPOp = PHITranslateSubExpr(GEP->getOperand(i), CurBB, PredBB, DT);
218  if (!GEPOp) return nullptr;
219 
220  AnyChanged |= GEPOp != GEP->getOperand(i);
221  GEPOps.push_back(GEPOp);
222  }
223 
224  if (!AnyChanged)
225  return GEP;
226 
227  // Simplify the GEP to handle 'gep x, 0' -> x etc.
228  if (Value *V = SimplifyGEPInst(GEP->getSourceElementType(), GEPOps[0],
229  ArrayRef<Value *>(GEPOps).slice(1),
230  GEP->isInBounds(), {DL, TLI, DT, AC})) {
231  for (unsigned i = 0, e = GEPOps.size(); i != e; ++i)
232  RemoveInstInputs(GEPOps[i], InstInputs);
233 
234  return AddAsInput(V);
235  }
236 
237  // Scan to see if we have this GEP available.
238  Value *APHIOp = GEPOps[0];
239  for (User *U : APHIOp->users()) {
240  if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(U))
241  if (GEPI->getType() == GEP->getType() &&
242  GEPI->getSourceElementType() == GEP->getSourceElementType() &&
243  GEPI->getNumOperands() == GEPOps.size() &&
244  GEPI->getParent()->getParent() == CurBB->getParent() &&
245  (!DT || DT->dominates(GEPI->getParent(), PredBB))) {
246  if (std::equal(GEPOps.begin(), GEPOps.end(), GEPI->op_begin()))
247  return GEPI;
248  }
249  }
250  return nullptr;
251  }
252 
253  // Handle add with a constant RHS.
254  if (Inst->getOpcode() == Instruction::Add &&
255  isa<ConstantInt>(Inst->getOperand(1))) {
256  // PHI translate the LHS.
257  Constant *RHS = cast<ConstantInt>(Inst->getOperand(1));
258  bool isNSW = cast<BinaryOperator>(Inst)->hasNoSignedWrap();
259  bool isNUW = cast<BinaryOperator>(Inst)->hasNoUnsignedWrap();
260 
261  Value *LHS = PHITranslateSubExpr(Inst->getOperand(0), CurBB, PredBB, DT);
262  if (!LHS) return nullptr;
263 
264  // If the PHI translated LHS is an add of a constant, fold the immediates.
265  if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(LHS))
266  if (BOp->getOpcode() == Instruction::Add)
267  if (ConstantInt *CI = dyn_cast<ConstantInt>(BOp->getOperand(1))) {
268  LHS = BOp->getOperand(0);
270  isNSW = isNUW = false;
271 
272  // If the old 'LHS' was an input, add the new 'LHS' as an input.
273  if (is_contained(InstInputs, BOp)) {
274  RemoveInstInputs(BOp, InstInputs);
275  AddAsInput(LHS);
276  }
277  }
278 
279  // See if the add simplifies away.
280  if (Value *Res = SimplifyAddInst(LHS, RHS, isNSW, isNUW, {DL, TLI, DT, AC})) {
281  // If we simplified the operands, the LHS is no longer an input, but Res
282  // is.
283  RemoveInstInputs(LHS, InstInputs);
284  return AddAsInput(Res);
285  }
286 
287  // If we didn't modify the add, just return it.
288  if (LHS == Inst->getOperand(0) && RHS == Inst->getOperand(1))
289  return Inst;
290 
291  // Otherwise, see if we have this add available somewhere.
292  for (User *U : LHS->users()) {
293  if (BinaryOperator *BO = dyn_cast<BinaryOperator>(U))
294  if (BO->getOpcode() == Instruction::Add &&
295  BO->getOperand(0) == LHS && BO->getOperand(1) == RHS &&
296  BO->getParent()->getParent() == CurBB->getParent() &&
297  (!DT || DT->dominates(BO->getParent(), PredBB)))
298  return BO;
299  }
300 
301  return nullptr;
302  }
303 
304  // Otherwise, we failed.
305  return nullptr;
306 }
307 
308 
309 /// PHITranslateValue - PHI translate the current address up the CFG from
310 /// CurBB to Pred, updating our state to reflect any needed changes. If
311 /// 'MustDominate' is true, the translated value must dominate
312 /// PredBB. This returns true on failure and sets Addr to null.
314  const DominatorTree *DT,
315  bool MustDominate) {
316  assert(DT || !MustDominate);
317  assert(Verify() && "Invalid PHITransAddr!");
318  if (DT && DT->isReachableFromEntry(PredBB))
319  Addr =
320  PHITranslateSubExpr(Addr, CurBB, PredBB, MustDominate ? DT : nullptr);
321  else
322  Addr = nullptr;
323  assert(Verify() && "Invalid PHITransAddr!");
324 
325  if (MustDominate)
326  // Make sure the value is live in the predecessor.
327  if (Instruction *Inst = dyn_cast_or_null<Instruction>(Addr))
328  if (!DT->dominates(Inst->getParent(), PredBB))
329  Addr = nullptr;
330 
331  return Addr == nullptr;
332 }
333 
334 /// PHITranslateWithInsertion - PHI translate this value into the specified
335 /// predecessor block, inserting a computation of the value if it is
336 /// unavailable.
337 ///
338 /// All newly created instructions are added to the NewInsts list. This
339 /// returns null on failure.
340 ///
343  const DominatorTree &DT,
344  SmallVectorImpl<Instruction*> &NewInsts) {
345  unsigned NISize = NewInsts.size();
346 
347  // Attempt to PHI translate with insertion.
348  Addr = InsertPHITranslatedSubExpr(Addr, CurBB, PredBB, DT, NewInsts);
349 
350  // If successful, return the new value.
351  if (Addr) return Addr;
352 
353  // If not, destroy any intermediate instructions inserted.
354  while (NewInsts.size() != NISize)
355  NewInsts.pop_back_val()->eraseFromParent();
356  return nullptr;
357 }
358 
359 
360 /// InsertPHITranslatedPointer - Insert a computation of the PHI translated
361 /// version of 'V' for the edge PredBB->CurBB into the end of the PredBB
362 /// block. All newly created instructions are added to the NewInsts list.
363 /// This returns null on failure.
364 ///
365 Value *PHITransAddr::
366 InsertPHITranslatedSubExpr(Value *InVal, BasicBlock *CurBB,
367  BasicBlock *PredBB, const DominatorTree &DT,
368  SmallVectorImpl<Instruction*> &NewInsts) {
369  // See if we have a version of this value already available and dominating
370  // PredBB. If so, there is no need to insert a new instance of it.
371  PHITransAddr Tmp(InVal, DL, AC);
372  if (!Tmp.PHITranslateValue(CurBB, PredBB, &DT, /*MustDominate=*/true))
373  return Tmp.getAddr();
374 
375  // We don't need to PHI translate values which aren't instructions.
376  auto *Inst = dyn_cast<Instruction>(InVal);
377  if (!Inst)
378  return nullptr;
379 
380  // Handle cast of PHI translatable value.
381  if (CastInst *Cast = dyn_cast<CastInst>(Inst)) {
382  if (!isSafeToSpeculativelyExecute(Cast)) return nullptr;
383  Value *OpVal = InsertPHITranslatedSubExpr(Cast->getOperand(0),
384  CurBB, PredBB, DT, NewInsts);
385  if (!OpVal) return nullptr;
386 
387  // Otherwise insert a cast at the end of PredBB.
388  CastInst *New = CastInst::Create(Cast->getOpcode(), OpVal, InVal->getType(),
389  InVal->getName() + ".phi.trans.insert",
390  PredBB->getTerminator());
391  New->setDebugLoc(Inst->getDebugLoc());
392  NewInsts.push_back(New);
393  return New;
394  }
395 
396  // Handle getelementptr with at least one PHI operand.
397  if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Inst)) {
398  SmallVector<Value*, 8> GEPOps;
399  BasicBlock *CurBB = GEP->getParent();
400  for (unsigned i = 0, e = GEP->getNumOperands(); i != e; ++i) {
401  Value *OpVal = InsertPHITranslatedSubExpr(GEP->getOperand(i),
402  CurBB, PredBB, DT, NewInsts);
403  if (!OpVal) return nullptr;
404  GEPOps.push_back(OpVal);
405  }
406 
408  GEP->getSourceElementType(), GEPOps[0], makeArrayRef(GEPOps).slice(1),
409  InVal->getName() + ".phi.trans.insert", PredBB->getTerminator());
410  Result->setDebugLoc(Inst->getDebugLoc());
411  Result->setIsInBounds(GEP->isInBounds());
412  NewInsts.push_back(Result);
413  return Result;
414  }
415 
416 #if 0
417  // FIXME: This code works, but it is unclear that we actually want to insert
418  // a big chain of computation in order to make a value available in a block.
419  // This needs to be evaluated carefully to consider its cost trade offs.
420 
421  // Handle add with a constant RHS.
422  if (Inst->getOpcode() == Instruction::Add &&
423  isa<ConstantInt>(Inst->getOperand(1))) {
424  // PHI translate the LHS.
425  Value *OpVal = InsertPHITranslatedSubExpr(Inst->getOperand(0),
426  CurBB, PredBB, DT, NewInsts);
427  if (OpVal == 0) return 0;
428 
429  BinaryOperator *Res = BinaryOperator::CreateAdd(OpVal, Inst->getOperand(1),
430  InVal->getName()+".phi.trans.insert",
431  PredBB->getTerminator());
432  Res->setHasNoSignedWrap(cast<BinaryOperator>(Inst)->hasNoSignedWrap());
433  Res->setHasNoUnsignedWrap(cast<BinaryOperator>(Inst)->hasNoUnsignedWrap());
434  NewInsts.push_back(Res);
435  return Res;
436  }
437 #endif
438 
439  return nullptr;
440 }
i
i
Definition: README.txt:29
RemoveInstInputs
static void RemoveInstInputs(Value *V, SmallVectorImpl< Instruction * > &InstInputs)
Definition: PHITransAddr.cpp:121
LLVM_DUMP_METHOD
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:494
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::SmallVectorImpl::erase
iterator erase(const_iterator CI)
Definition: SmallVector.h:724
llvm::isSafeToSpeculativelyExecute
bool isSafeToSpeculativelyExecute(const Value *V, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr)
Return true if the instruction does not have any effects besides calculating the result and does not ...
Definition: ValueTracking.cpp:4576
llvm::PHITransAddr
PHITransAddr - An address value which tracks and handles phi translation.
Definition: PHITransAddr.h:35
llvm::BasicBlock::getParent
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:104
llvm::SmallVector< Instruction *, 8 >
ErrorHandling.h
llvm::CastInst::Create
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
Definition: Instructions.cpp:3180
ValueTracking.h
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:166
llvm::PHITransAddr::PHITranslateWithInsertion
Value * PHITranslateWithInsertion(BasicBlock *CurBB, BasicBlock *PredBB, const DominatorTree &DT, SmallVectorImpl< Instruction * > &NewInsts)
PHITranslateWithInsertion - PHI translate this value into the specified predecessor block,...
Definition: PHITransAddr.cpp:342
CanPHITrans
static bool CanPHITrans(Instruction *Inst)
Definition: PHITransAddr.cpp:24
llvm::Instruction::setHasNoUnsignedWrap
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
Definition: Instruction.cpp:123
llvm::PHITransAddr::IsPotentiallyPHITranslatable
bool IsPotentiallyPHITranslatable() const
IsPotentiallyPHITranslatable - If this needs PHI translation, return true if we have some hope of doi...
Definition: PHITransAddr.cpp:113
llvm::SimplifyGEPInst
Value * SimplifyGEPInst(Type *SrcTy, Value *Ptr, ArrayRef< Value * > Indices, bool InBounds, const SimplifyQuery &Q)
Given operands for a GetElementPtrInst, fold the result or return null.
Definition: InstructionSimplify.cpp:4662
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:893
llvm::SmallVectorImpl::pop_back_val
LLVM_NODISCARD T pop_back_val()
Definition: SmallVector.h:654
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
llvm::lltok::equal
@ equal
Definition: LLToken.h:25
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::DominatorTree::dominates
bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
Definition: Dominators.cpp:122
PHITransAddr.h
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
llvm::ConstantInt
This is the shared class of boolean and integer constants.
Definition: Constants.h:79
llvm::Instruction::getOpcode
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Definition: Instruction.h:157
hasNoUnsignedWrap
static bool hasNoUnsignedWrap(BinaryOperator &I)
Definition: InstructionCombining.cpp:298
Constants.h
llvm::Instruction::setHasNoSignedWrap
void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
Definition: Instruction.cpp:127
llvm::User
Definition: User.h:44
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::ms_demangle::QualifierMangleMode::Result
@ Result
llvm::Instruction
Definition: Instruction.h:42
llvm::ArrayRef::slice
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Definition: ArrayRef.h:194
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::Instruction::eraseFromParent
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
Definition: Instruction.cpp:77
VerifySubExpr
static bool VerifySubExpr(Value *Expr, SmallVectorImpl< Instruction * > &InstInputs)
Definition: PHITransAddr.cpp:56
llvm::find
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1625
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:57
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::GetElementPtrInst
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
Definition: Instructions.h:929
llvm::is_contained
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
Definition: STLExtras.h:1670
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::ConstantExpr::getCast
static Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
Definition: Constants.cpp:2002
llvm::DominatorTree::isReachableFromEntry
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
Definition: Dominators.cpp:335
llvm::PHITransAddr::PHITranslateValue
bool PHITranslateValue(BasicBlock *CurBB, BasicBlock *PredBB, const DominatorTree *DT, bool MustDominate)
PHITranslateValue - PHI translate the current address up the CFG from CurBB to Pred,...
Definition: PHITransAddr.cpp:313
llvm::GetElementPtrInst::Create
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Definition: Instructions.h:955
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::BinaryOperator
Definition: InstrTypes.h:188
llvm::PHITransAddr::dump
void dump() const
Definition: PHITransAddr.cpp:44
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
llvm::PHITransAddr::Verify
bool Verify() const
Verify - Check internal consistency of this data structure.
Definition: PHITransAddr.cpp:90
llvm::CastInst
This is the base class for all instructions that perform data casts.
Definition: InstrTypes.h:429
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:305
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:326
llvm::ConstantExpr::getAdd
static Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2715
isInput
static bool isInput(const StringSet<> &Prefixes, StringRef Arg)
Definition: OptTable.cpp:169
hasNoSignedWrap
static bool hasNoSignedWrap(BinaryOperator &I)
Definition: InstructionCombining.cpp:303
llvm::MCID::Add
@ Add
Definition: MCInstrDesc.h:185
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:475
Instructions.h
llvm::User::getNumOperands
unsigned getNumOperands() const
Definition: User.h:191
llvm::Instruction::getDebugLoc
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition: Instruction.h:367
Dominators.h
llvm::Instruction::getParent
const BasicBlock * getParent() const
Definition: Instruction.h:91
InstructionSimplify.h
llvm::PHINode
Definition: Instructions.h:2664
llvm::BasicBlock::getTerminator
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Definition: BasicBlock.h:119
llvm::SmallVectorImpl< Instruction * >
GEP
Hexagon Common GEP
Definition: HexagonCommonGEP.cpp:172
CreateAdd
static BinaryOperator * CreateAdd(Value *S1, Value *S2, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
Definition: Reassociate.cpp:231
llvm::User::getOperand
Value * getOperand(unsigned i) const
Definition: User.h:169
raw_ostream.h
llvm::SimplifyAddInst
Value * SimplifyAddInst(Value *LHS, Value *RHS, bool isNSW, bool isNUW, const SimplifyQuery &Q)
Given operands for an Add, fold the result or return null.
Definition: InstructionSimplify.cpp:683
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::Value::users
iterator_range< user_iterator > users()
Definition: Value.h:421