LLVM  7.0.0svn
InstCombineInternal.h
Go to the documentation of this file.
1 //===- InstCombineInternal.h - InstCombine pass internals -------*- C++ -*-===//
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 /// \file
11 ///
12 /// This file provides internal interfaces used to implement the InstCombine.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_LIB_TRANSFORMS_INSTCOMBINE_INSTCOMBINEINTERNAL_H
17 #define LLVM_LIB_TRANSFORMS_INSTCOMBINE_INSTCOMBINEINTERNAL_H
18 
19 #include "llvm/ADT/ArrayRef.h"
24 #include "llvm/IR/Argument.h"
25 #include "llvm/IR/BasicBlock.h"
26 #include "llvm/IR/Constant.h"
27 #include "llvm/IR/Constants.h"
28 #include "llvm/IR/DerivedTypes.h"
29 #include "llvm/IR/IRBuilder.h"
30 #include "llvm/IR/InstVisitor.h"
31 #include "llvm/IR/InstrTypes.h"
32 #include "llvm/IR/Instruction.h"
33 #include "llvm/IR/IntrinsicInst.h"
34 #include "llvm/IR/Intrinsics.h"
35 #include "llvm/IR/Use.h"
36 #include "llvm/IR/Value.h"
37 #include "llvm/Support/Casting.h"
38 #include "llvm/Support/Compiler.h"
39 #include "llvm/Support/Debug.h"
40 #include "llvm/Support/KnownBits.h"
44 #include <cassert>
45 #include <cstdint>
46 
47 #define DEBUG_TYPE "instcombine"
48 
49 namespace llvm {
50 
51 class APInt;
52 class AssumptionCache;
53 class CallSite;
54 class DataLayout;
55 class DominatorTree;
56 class GEPOperator;
57 class GlobalVariable;
58 class LoopInfo;
59 class OptimizationRemarkEmitter;
60 class TargetLibraryInfo;
61 class User;
62 
63 /// Assign a complexity or rank value to LLVM Values. This is used to reduce
64 /// the amount of pattern matching needed for compares and commutative
65 /// instructions. For example, if we have:
66 /// icmp ugt X, Constant
67 /// or
68 /// xor (add X, Constant), cast Z
69 ///
70 /// We do not have to consider the commuted variants of these patterns because
71 /// canonicalization based on complexity guarantees the above ordering.
72 ///
73 /// This routine maps IR values to various complexity ranks:
74 /// 0 -> undef
75 /// 1 -> Constants
76 /// 2 -> Other non-instructions
77 /// 3 -> Arguments
78 /// 4 -> Cast and (f)neg/not instructions
79 /// 5 -> Other instructions
80 static inline unsigned getComplexity(Value *V) {
81  if (isa<Instruction>(V)) {
82  if (isa<CastInst>(V) || BinaryOperator::isNeg(V) ||
84  return 4;
85  return 5;
86  }
87  if (isa<Argument>(V))
88  return 3;
89  return isa<Constant>(V) ? (isa<UndefValue>(V) ? 0 : 1) : 2;
90 }
91 
92 /// Predicate canonicalization reduces the number of patterns that need to be
93 /// matched by other transforms. For example, we may swap the operands of a
94 /// conditional branch or select to create a compare with a canonical (inverted)
95 /// predicate which is then more likely to be matched with other values.
96 static inline bool isCanonicalPredicate(CmpInst::Predicate Pred) {
97  switch (Pred) {
98  case CmpInst::ICMP_NE:
99  case CmpInst::ICMP_ULE:
100  case CmpInst::ICMP_SLE:
101  case CmpInst::ICMP_UGE:
102  case CmpInst::ICMP_SGE:
103  // TODO: There are 16 FCMP predicates. Should others be (not) canonical?
104  case CmpInst::FCMP_ONE:
105  case CmpInst::FCMP_OLE:
106  case CmpInst::FCMP_OGE:
107  return false;
108  default:
109  return true;
110  }
111 }
112 
113 /// Return the source operand of a potentially bitcasted value while optionally
114 /// checking if it has one use. If there is no bitcast or the one use check is
115 /// not met, return the input value itself.
116 static inline Value *peekThroughBitcast(Value *V, bool OneUseOnly = false) {
117  if (auto *BitCast = dyn_cast<BitCastInst>(V))
118  if (!OneUseOnly || BitCast->hasOneUse())
119  return BitCast->getOperand(0);
120 
121  // V is not a bitcast or V has more than one use and OneUseOnly is true.
122  return V;
123 }
124 
125 /// \brief Add one to a Constant
126 static inline Constant *AddOne(Constant *C) {
127  return ConstantExpr::getAdd(C, ConstantInt::get(C->getType(), 1));
128 }
129 
130 /// \brief Subtract one from a Constant
131 static inline Constant *SubOne(Constant *C) {
132  return ConstantExpr::getSub(C, ConstantInt::get(C->getType(), 1));
133 }
134 
135 /// \brief Return true if the specified value is free to invert (apply ~ to).
136 /// This happens in cases where the ~ can be eliminated. If WillInvertAllUses
137 /// is true, work under the assumption that the caller intends to remove all
138 /// uses of V and only keep uses of ~V.
139 static inline bool IsFreeToInvert(Value *V, bool WillInvertAllUses) {
140  // ~(~(X)) -> X.
141  if (BinaryOperator::isNot(V))
142  return true;
143 
144  // Constants can be considered to be not'ed values.
145  if (isa<ConstantInt>(V))
146  return true;
147 
148  // A vector of constant integers can be inverted easily.
149  if (V->getType()->isVectorTy() && isa<Constant>(V)) {
150  unsigned NumElts = V->getType()->getVectorNumElements();
151  for (unsigned i = 0; i != NumElts; ++i) {
152  Constant *Elt = cast<Constant>(V)->getAggregateElement(i);
153  if (!Elt)
154  return false;
155 
156  if (isa<UndefValue>(Elt))
157  continue;
158 
159  if (!isa<ConstantInt>(Elt))
160  return false;
161  }
162  return true;
163  }
164 
165  // Compares can be inverted if all of their uses are being modified to use the
166  // ~V.
167  if (isa<CmpInst>(V))
168  return WillInvertAllUses;
169 
170  // If `V` is of the form `A + Constant` then `-1 - V` can be folded into `(-1
171  // - Constant) - A` if we are willing to invert all of the uses.
172  if (BinaryOperator *BO = dyn_cast<BinaryOperator>(V))
173  if (BO->getOpcode() == Instruction::Add ||
174  BO->getOpcode() == Instruction::Sub)
175  if (isa<Constant>(BO->getOperand(0)) || isa<Constant>(BO->getOperand(1)))
176  return WillInvertAllUses;
177 
178  return false;
179 }
180 
181 /// \brief Specific patterns of overflow check idioms that we match.
189 
191 };
192 
193 /// \brief Returns the OverflowCheckFlavor corresponding to a overflow_with_op
194 /// intrinsic.
195 static inline OverflowCheckFlavor
197  switch (ID) {
198  default:
199  return OCF_INVALID;
200  case Intrinsic::uadd_with_overflow:
201  return OCF_UNSIGNED_ADD;
202  case Intrinsic::sadd_with_overflow:
203  return OCF_SIGNED_ADD;
204  case Intrinsic::usub_with_overflow:
205  return OCF_UNSIGNED_SUB;
206  case Intrinsic::ssub_with_overflow:
207  return OCF_SIGNED_SUB;
208  case Intrinsic::umul_with_overflow:
209  return OCF_UNSIGNED_MUL;
210  case Intrinsic::smul_with_overflow:
211  return OCF_SIGNED_MUL;
212  }
213 }
214 
215 /// \brief The core instruction combiner logic.
216 ///
217 /// This class provides both the logic to recursively visit instructions and
218 /// combine them.
220  : public InstVisitor<InstCombiner, Instruction *> {
221  // FIXME: These members shouldn't be public.
222 public:
223  /// \brief A worklist of the instructions that need to be simplified.
225 
226  /// \brief An IRBuilder that automatically inserts new instructions into the
227  /// worklist.
230 
231 private:
232  // Mode in which we are running the combiner.
233  const bool MinimizeSize;
234 
235  /// Enable combines that trigger rarely but are costly in compiletime.
236  const bool ExpensiveCombines;
237 
238  AliasAnalysis *AA;
239 
240  // Required analyses.
241  AssumptionCache &AC;
242  TargetLibraryInfo &TLI;
243  DominatorTree &DT;
244  const DataLayout &DL;
245  const SimplifyQuery SQ;
247 
248  // Optional analyses. When non-null, these can both be used to do better
249  // combining and will be updated to reflect any changes.
250  LoopInfo *LI;
251 
252  bool MadeIRChange = false;
253 
254 public:
256  bool MinimizeSize, bool ExpensiveCombines, AliasAnalysis *AA,
258  OptimizationRemarkEmitter &ORE, const DataLayout &DL,
259  LoopInfo *LI)
260  : Worklist(Worklist), Builder(Builder), MinimizeSize(MinimizeSize),
261  ExpensiveCombines(ExpensiveCombines), AA(AA), AC(AC), TLI(TLI), DT(DT),
262  DL(DL), SQ(DL, &TLI, &DT, &AC), ORE(ORE), LI(LI) {}
263 
264  /// \brief Run the combiner over the entire worklist until it is empty.
265  ///
266  /// \returns true if the IR is changed.
267  bool run();
268 
269  AssumptionCache &getAssumptionCache() const { return AC; }
270 
271  const DataLayout &getDataLayout() const { return DL; }
272 
273  DominatorTree &getDominatorTree() const { return DT; }
274 
275  LoopInfo *getLoopInfo() const { return LI; }
276 
277  TargetLibraryInfo &getTargetLibraryInfo() const { return TLI; }
278 
279  // Visitation implementation - Implement instruction combining for different
280  // instruction types. The semantics are as follows:
281  // Return Value:
282  // null - No change was made
283  // I - Change was made, I is still valid, I may be dead though
284  // otherwise - Change was made, replace I with returned instruction
285  //
286  Instruction *visitAdd(BinaryOperator &I);
287  Instruction *visitFAdd(BinaryOperator &I);
288  Value *OptimizePointerDifference(Value *LHS, Value *RHS, Type *Ty);
289  Instruction *visitSub(BinaryOperator &I);
290  Instruction *visitFSub(BinaryOperator &I);
291  Instruction *visitMul(BinaryOperator &I);
292  Value *foldFMulConst(Instruction *FMulOrDiv, Constant *C,
293  Instruction *InsertBefore);
294  Instruction *visitFMul(BinaryOperator &I);
295  Instruction *visitURem(BinaryOperator &I);
296  Instruction *visitSRem(BinaryOperator &I);
297  Instruction *visitFRem(BinaryOperator &I);
298  bool simplifyDivRemOfSelectWithZeroOp(BinaryOperator &I);
299  Instruction *commonRemTransforms(BinaryOperator &I);
300  Instruction *commonIRemTransforms(BinaryOperator &I);
301  Instruction *commonDivTransforms(BinaryOperator &I);
302  Instruction *commonIDivTransforms(BinaryOperator &I);
303  Instruction *visitUDiv(BinaryOperator &I);
304  Instruction *visitSDiv(BinaryOperator &I);
305  Instruction *visitFDiv(BinaryOperator &I);
306  Value *simplifyRangeCheck(ICmpInst *Cmp0, ICmpInst *Cmp1, bool Inverted);
307  Instruction *visitAnd(BinaryOperator &I);
308  Instruction *visitOr(BinaryOperator &I);
309  Instruction *visitXor(BinaryOperator &I);
310  Instruction *visitShl(BinaryOperator &I);
311  Instruction *visitAShr(BinaryOperator &I);
312  Instruction *visitLShr(BinaryOperator &I);
313  Instruction *commonShiftTransforms(BinaryOperator &I);
314  Instruction *visitFCmpInst(FCmpInst &I);
315  Instruction *visitICmpInst(ICmpInst &I);
316  Instruction *FoldShiftByConstant(Value *Op0, Constant *Op1,
317  BinaryOperator &I);
318  Instruction *commonCastTransforms(CastInst &CI);
319  Instruction *commonPointerCastTransforms(CastInst &CI);
320  Instruction *visitTrunc(TruncInst &CI);
321  Instruction *visitZExt(ZExtInst &CI);
322  Instruction *visitSExt(SExtInst &CI);
323  Instruction *visitFPTrunc(FPTruncInst &CI);
324  Instruction *visitFPExt(CastInst &CI);
325  Instruction *visitFPToUI(FPToUIInst &FI);
326  Instruction *visitFPToSI(FPToSIInst &FI);
327  Instruction *visitUIToFP(CastInst &CI);
328  Instruction *visitSIToFP(CastInst &CI);
329  Instruction *visitPtrToInt(PtrToIntInst &CI);
330  Instruction *visitIntToPtr(IntToPtrInst &CI);
331  Instruction *visitBitCast(BitCastInst &CI);
332  Instruction *visitAddrSpaceCast(AddrSpaceCastInst &CI);
333  Instruction *FoldItoFPtoI(Instruction &FI);
334  Instruction *visitSelectInst(SelectInst &SI);
335  Instruction *visitCallInst(CallInst &CI);
336  Instruction *visitInvokeInst(InvokeInst &II);
337 
338  Instruction *SliceUpIllegalIntegerPHI(PHINode &PN);
339  Instruction *visitPHINode(PHINode &PN);
340  Instruction *visitGetElementPtrInst(GetElementPtrInst &GEP);
341  Instruction *visitAllocaInst(AllocaInst &AI);
342  Instruction *visitAllocSite(Instruction &FI);
343  Instruction *visitFree(CallInst &FI);
344  Instruction *visitLoadInst(LoadInst &LI);
345  Instruction *visitStoreInst(StoreInst &SI);
346  Instruction *visitBranchInst(BranchInst &BI);
347  Instruction *visitFenceInst(FenceInst &FI);
348  Instruction *visitSwitchInst(SwitchInst &SI);
349  Instruction *visitReturnInst(ReturnInst &RI);
350  Instruction *visitInsertValueInst(InsertValueInst &IV);
351  Instruction *visitInsertElementInst(InsertElementInst &IE);
352  Instruction *visitExtractElementInst(ExtractElementInst &EI);
353  Instruction *visitShuffleVectorInst(ShuffleVectorInst &SVI);
354  Instruction *visitExtractValueInst(ExtractValueInst &EV);
355  Instruction *visitLandingPadInst(LandingPadInst &LI);
356  Instruction *visitVAStartInst(VAStartInst &I);
357  Instruction *visitVACopyInst(VACopyInst &I);
358 
359  /// Specify what to return for unhandled instructions.
360  Instruction *visitInstruction(Instruction &I) { return nullptr; }
361 
362  /// True when DB dominates all uses of DI except UI.
363  /// UI must be in the same block as DI.
364  /// The routine checks that the DI parent and DB are different.
365  bool dominatesAllUses(const Instruction *DI, const Instruction *UI,
366  const BasicBlock *DB) const;
367 
368  /// Try to replace select with select operand SIOpd in SI-ICmp sequence.
369  bool replacedSelectWithOperand(SelectInst *SI, const ICmpInst *Icmp,
370  const unsigned SIOpd);
371 
372  /// Try to replace instruction \p I with value \p V which are pointers
373  /// in different address space.
374  /// \return true if successful.
375  bool replacePointer(Instruction &I, Value *V);
376 
377 private:
378  bool shouldChangeType(unsigned FromBitWidth, unsigned ToBitWidth) const;
379  bool shouldChangeType(Type *From, Type *To) const;
380  Value *dyn_castNegVal(Value *V) const;
381  Value *dyn_castFNegVal(Value *V, bool NoSignedZero = false) const;
382  Type *FindElementAtOffset(PointerType *PtrTy, int64_t Offset,
383  SmallVectorImpl<Value *> &NewIndices);
384 
385  /// Classify whether a cast is worth optimizing.
386  ///
387  /// This is a helper to decide whether the simplification of
388  /// logic(cast(A), cast(B)) to cast(logic(A, B)) should be performed.
389  ///
390  /// \param CI The cast we are interested in.
391  ///
392  /// \return true if this cast actually results in any code being generated and
393  /// if it cannot already be eliminated by some other transformation.
394  bool shouldOptimizeCast(CastInst *CI);
395 
396  /// \brief Try to optimize a sequence of instructions checking if an operation
397  /// on LHS and RHS overflows.
398  ///
399  /// If this overflow check is done via one of the overflow check intrinsics,
400  /// then CtxI has to be the call instruction calling that intrinsic. If this
401  /// overflow check is done by arithmetic followed by a compare, then CtxI has
402  /// to be the arithmetic instruction.
403  ///
404  /// If a simplification is possible, stores the simplified result of the
405  /// operation in OperationResult and result of the overflow check in
406  /// OverflowResult, and return true. If no simplification is possible,
407  /// returns false.
408  bool OptimizeOverflowCheck(OverflowCheckFlavor OCF, Value *LHS, Value *RHS,
409  Instruction &CtxI, Value *&OperationResult,
411 
412  Instruction *visitCallSite(CallSite CS);
413  Instruction *tryOptimizeCall(CallInst *CI);
414  bool transformConstExprCastCall(CallSite CS);
415  Instruction *transformCallThroughTrampoline(CallSite CS,
416  IntrinsicInst *Tramp);
417 
418  /// Transform (zext icmp) to bitwise / integer operations in order to
419  /// eliminate it.
420  ///
421  /// \param ICI The icmp of the (zext icmp) pair we are interested in.
422  /// \parem CI The zext of the (zext icmp) pair we are interested in.
423  /// \param DoTransform Pass false to just test whether the given (zext icmp)
424  /// would be transformed. Pass true to actually perform the transformation.
425  ///
426  /// \return null if the transformation cannot be performed. If the
427  /// transformation can be performed the new instruction that replaces the
428  /// (zext icmp) pair will be returned (if \p DoTransform is false the
429  /// unmodified \p ICI will be returned in this case).
430  Instruction *transformZExtICmp(ICmpInst *ICI, ZExtInst &CI,
431  bool DoTransform = true);
432 
433  Instruction *transformSExtICmp(ICmpInst *ICI, Instruction &CI);
434 
435  bool willNotOverflowSignedAdd(const Value *LHS, const Value *RHS,
436  const Instruction &CxtI) const {
437  return computeOverflowForSignedAdd(LHS, RHS, &CxtI) ==
439  }
440 
441  bool willNotOverflowUnsignedAdd(const Value *LHS, const Value *RHS,
442  const Instruction &CxtI) const {
443  return computeOverflowForUnsignedAdd(LHS, RHS, &CxtI) ==
445  }
446 
447  bool willNotOverflowSignedSub(const Value *LHS, const Value *RHS,
448  const Instruction &CxtI) const;
449  bool willNotOverflowUnsignedSub(const Value *LHS, const Value *RHS,
450  const Instruction &CxtI) const;
451  bool willNotOverflowSignedMul(const Value *LHS, const Value *RHS,
452  const Instruction &CxtI) const;
453 
454  bool willNotOverflowUnsignedMul(const Value *LHS, const Value *RHS,
455  const Instruction &CxtI) const {
456  return computeOverflowForUnsignedMul(LHS, RHS, &CxtI) ==
458  }
459 
460  Value *EmitGEPOffset(User *GEP);
461  Instruction *scalarizePHI(ExtractElementInst &EI, PHINode *PN);
462  Value *EvaluateInDifferentElementOrder(Value *V, ArrayRef<int> Mask);
463  Instruction *foldCastedBitwiseLogic(BinaryOperator &I);
464  Instruction *narrowBinOp(TruncInst &Trunc);
465  Instruction *narrowMaskedBinOp(BinaryOperator &And);
466  Instruction *narrowRotate(TruncInst &Trunc);
467  Instruction *optimizeBitCastFromPhi(CastInst &CI, PHINode *PN);
468 
469  /// Determine if a pair of casts can be replaced by a single cast.
470  ///
471  /// \param CI1 The first of a pair of casts.
472  /// \param CI2 The second of a pair of casts.
473  ///
474  /// \return 0 if the cast pair cannot be eliminated, otherwise returns an
475  /// Instruction::CastOps value for a cast that can replace the pair, casting
476  /// CI1->getSrcTy() to CI2->getDstTy().
477  ///
478  /// \see CastInst::isEliminableCastPair
479  Instruction::CastOps isEliminableCastPair(const CastInst *CI1,
480  const CastInst *CI2);
481 
482  Value *foldAndOfICmps(ICmpInst *LHS, ICmpInst *RHS, Instruction &CxtI);
483  Value *foldOrOfICmps(ICmpInst *LHS, ICmpInst *RHS, Instruction &CxtI);
484  Value *foldXorOfICmps(ICmpInst *LHS, ICmpInst *RHS);
485 
486  /// Optimize (fcmp)&(fcmp) or (fcmp)|(fcmp).
487  /// NOTE: Unlike most of instcombine, this returns a Value which should
488  /// already be inserted into the function.
489  Value *foldLogicOfFCmps(FCmpInst *LHS, FCmpInst *RHS, bool IsAnd);
490 
491  Value *foldAndOrOfICmpsOfAndWithPow2(ICmpInst *LHS, ICmpInst *RHS,
492  bool JoinedByAnd, Instruction &CxtI);
493 public:
494  /// \brief Inserts an instruction \p New before instruction \p Old
495  ///
496  /// Also adds the new instruction to the worklist and returns \p New so that
497  /// it is suitable for use as the return from the visitation patterns.
499  assert(New && !New->getParent() &&
500  "New instruction already inserted into a basic block!");
501  BasicBlock *BB = Old.getParent();
502  BB->getInstList().insert(Old.getIterator(), New); // Insert inst
503  Worklist.Add(New);
504  return New;
505  }
506 
507  /// \brief Same as InsertNewInstBefore, but also sets the debug loc.
509  New->setDebugLoc(Old.getDebugLoc());
510  return InsertNewInstBefore(New, Old);
511  }
512 
513  /// \brief A combiner-aware RAUW-like routine.
514  ///
515  /// This method is to be used when an instruction is found to be dead,
516  /// replaceable with another preexisting expression. Here we add all uses of
517  /// I to the worklist, replace all uses of I with the new value, then return
518  /// I, so that the inst combiner will know that I was modified.
520  // If there are no uses to replace, then we return nullptr to indicate that
521  // no changes were made to the program.
522  if (I.use_empty()) return nullptr;
523 
524  Worklist.AddUsersToWorkList(I); // Add all modified instrs to worklist.
525 
526  // If we are replacing the instruction with itself, this must be in a
527  // segment of unreachable code, so just clobber the instruction.
528  if (&I == V)
529  V = UndefValue::get(I.getType());
530 
531  DEBUG(dbgs() << "IC: Replacing " << I << "\n"
532  << " with " << *V << '\n');
533 
534  I.replaceAllUsesWith(V);
535  return &I;
536  }
537 
538  /// Creates a result tuple for an overflow intrinsic \p II with a given
539  /// \p Result and a constant \p Overflow value.
541  Constant *Overflow) {
542  Constant *V[] = {UndefValue::get(Result->getType()), Overflow};
543  StructType *ST = cast<StructType>(II->getType());
544  Constant *Struct = ConstantStruct::get(ST, V);
545  return InsertValueInst::Create(Struct, Result, 0);
546  }
547 
548  /// \brief Combiner aware instruction erasure.
549  ///
550  /// When dealing with an instruction that has side effects or produces a void
551  /// value, we can't rely on DCE to delete the instruction. Instead, visit
552  /// methods should return the value returned by this function.
554  DEBUG(dbgs() << "IC: ERASE " << I << '\n');
555  assert(I.use_empty() && "Cannot erase instruction that is used!");
556  salvageDebugInfo(I);
557 
558  // Make sure that we reprocess all operands now that we reduced their
559  // use counts.
560  if (I.getNumOperands() < 8) {
561  for (Use &Operand : I.operands())
562  if (auto *Inst = dyn_cast<Instruction>(Operand))
563  Worklist.Add(Inst);
564  }
565  Worklist.Remove(&I);
566  I.eraseFromParent();
567  MadeIRChange = true;
568  return nullptr; // Don't do anything with FI
569  }
570 
571  void computeKnownBits(const Value *V, KnownBits &Known,
572  unsigned Depth, const Instruction *CxtI) const {
573  llvm::computeKnownBits(V, Known, DL, Depth, &AC, CxtI, &DT);
574  }
575 
576  KnownBits computeKnownBits(const Value *V, unsigned Depth,
577  const Instruction *CxtI) const {
578  return llvm::computeKnownBits(V, DL, Depth, &AC, CxtI, &DT);
579  }
580 
581  bool isKnownToBeAPowerOfTwo(const Value *V, bool OrZero = false,
582  unsigned Depth = 0,
583  const Instruction *CxtI = nullptr) {
584  return llvm::isKnownToBeAPowerOfTwo(V, DL, OrZero, Depth, &AC, CxtI, &DT);
585  }
586 
587  bool MaskedValueIsZero(const Value *V, const APInt &Mask, unsigned Depth = 0,
588  const Instruction *CxtI = nullptr) const {
589  return llvm::MaskedValueIsZero(V, Mask, DL, Depth, &AC, CxtI, &DT);
590  }
591 
592  unsigned ComputeNumSignBits(const Value *Op, unsigned Depth = 0,
593  const Instruction *CxtI = nullptr) const {
594  return llvm::ComputeNumSignBits(Op, DL, Depth, &AC, CxtI, &DT);
595  }
596 
597  OverflowResult computeOverflowForUnsignedMul(const Value *LHS,
598  const Value *RHS,
599  const Instruction *CxtI) const {
600  return llvm::computeOverflowForUnsignedMul(LHS, RHS, DL, &AC, CxtI, &DT);
601  }
602 
603  OverflowResult computeOverflowForUnsignedAdd(const Value *LHS,
604  const Value *RHS,
605  const Instruction *CxtI) const {
606  return llvm::computeOverflowForUnsignedAdd(LHS, RHS, DL, &AC, CxtI, &DT);
607  }
608 
609  OverflowResult computeOverflowForSignedAdd(const Value *LHS,
610  const Value *RHS,
611  const Instruction *CxtI) const {
612  return llvm::computeOverflowForSignedAdd(LHS, RHS, DL, &AC, CxtI, &DT);
613  }
614 
615  /// Maximum size of array considered when transforming.
617 
618 private:
619  /// \brief Performs a few simplifications for operators which are associative
620  /// or commutative.
621  bool SimplifyAssociativeOrCommutative(BinaryOperator &I);
622 
623  /// \brief Tries to simplify binary operations which some other binary
624  /// operation distributes over.
625  ///
626  /// It does this by either by factorizing out common terms (eg "(A*B)+(A*C)"
627  /// -> "A*(B+C)") or expanding out if this results in simplifications (eg: "A
628  /// & (B | C) -> (A&B) | (A&C)" if this is a win). Returns the simplified
629  /// value, or null if it didn't simplify.
630  Value *SimplifyUsingDistributiveLaws(BinaryOperator &I);
631 
632  // Binary Op helper for select operations where the expression can be
633  // efficiently reorganized.
634  Value *SimplifySelectsFeedingBinaryOp(BinaryOperator &I, Value *LHS,
635  Value *RHS);
636 
637  /// This tries to simplify binary operations by factorizing out common terms
638  /// (e. g. "(A*B)+(A*C)" -> "A*(B+C)").
639  Value *tryFactorization(BinaryOperator &, Instruction::BinaryOps, Value *,
640  Value *, Value *, Value *);
641 
642  /// Match a select chain which produces one of three values based on whether
643  /// the LHS is less than, equal to, or greater than RHS respectively.
644  /// Return true if we matched a three way compare idiom. The LHS, RHS, Less,
645  /// Equal and Greater values are saved in the matching process and returned to
646  /// the caller.
647  bool matchThreeWayIntCompare(SelectInst *SI, Value *&LHS, Value *&RHS,
649  ConstantInt *&Greater);
650 
651  /// \brief Attempts to replace V with a simpler value based on the demanded
652  /// bits.
653  Value *SimplifyDemandedUseBits(Value *V, APInt DemandedMask, KnownBits &Known,
654  unsigned Depth, Instruction *CxtI);
655  bool SimplifyDemandedBits(Instruction *I, unsigned Op,
656  const APInt &DemandedMask, KnownBits &Known,
657  unsigned Depth = 0);
658 
659  /// Helper routine of SimplifyDemandedUseBits. It computes KnownZero/KnownOne
660  /// bits. It also tries to handle simplifications that can be done based on
661  /// DemandedMask, but without modifying the Instruction.
662  Value *SimplifyMultipleUseDemandedBits(Instruction *I,
663  const APInt &DemandedMask,
664  KnownBits &Known,
665  unsigned Depth, Instruction *CxtI);
666 
667  /// Helper routine of SimplifyDemandedUseBits. It tries to simplify demanded
668  /// bit for "r1 = shr x, c1; r2 = shl r1, c2" instruction sequence.
669  Value *simplifyShrShlDemandedBits(
670  Instruction *Shr, const APInt &ShrOp1, Instruction *Shl,
671  const APInt &ShlOp1, const APInt &DemandedMask, KnownBits &Known);
672 
673  /// \brief Tries to simplify operands to an integer instruction based on its
674  /// demanded bits.
675  bool SimplifyDemandedInstructionBits(Instruction &Inst);
676 
677  Value *SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
678  APInt &UndefElts, unsigned Depth = 0);
679 
680  Value *SimplifyVectorOp(BinaryOperator &Inst);
681 
682 
683  /// Given a binary operator, cast instruction, or select which has a PHI node
684  /// as operand #0, see if we can fold the instruction into the PHI (which is
685  /// only possible if all operands to the PHI are constants).
686  Instruction *foldOpIntoPhi(Instruction &I, PHINode *PN);
687 
688  /// Given an instruction with a select as one operand and a constant as the
689  /// other operand, try to fold the binary operator into the select arguments.
690  /// This also works for Cast instructions, which obviously do not have a
691  /// second operand.
692  Instruction *FoldOpIntoSelect(Instruction &Op, SelectInst *SI);
693 
694  /// This is a convenience wrapper function for the above two functions.
695  Instruction *foldOpWithConstantIntoOperand(BinaryOperator &I);
696 
697  Instruction *foldAddWithConstant(BinaryOperator &Add);
698 
699  /// \brief Try to rotate an operation below a PHI node, using PHI nodes for
700  /// its operands.
701  Instruction *FoldPHIArgOpIntoPHI(PHINode &PN);
702  Instruction *FoldPHIArgBinOpIntoPHI(PHINode &PN);
703  Instruction *FoldPHIArgGEPIntoPHI(PHINode &PN);
704  Instruction *FoldPHIArgLoadIntoPHI(PHINode &PN);
705  Instruction *FoldPHIArgZextsIntoPHI(PHINode &PN);
706 
707  /// If an integer typed PHI has only one use which is an IntToPtr operation,
708  /// replace the PHI with an existing pointer typed PHI if it exists. Otherwise
709  /// insert a new pointer typed PHI and replace the original one.
710  Instruction *FoldIntegerTypedPHI(PHINode &PN);
711 
712  /// Helper function for FoldPHIArgXIntoPHI() to set debug location for the
713  /// folded operation.
714  void PHIArgMergedDebugLoc(Instruction *Inst, PHINode &PN);
715 
716  Instruction *foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
718  Instruction *foldAllocaCmp(ICmpInst &ICI, const AllocaInst *Alloca,
719  const Value *Other);
720  Instruction *foldCmpLoadFromIndexedGlobal(GetElementPtrInst *GEP,
721  GlobalVariable *GV, CmpInst &ICI,
722  ConstantInt *AndCst = nullptr);
723  Instruction *foldFCmpIntToFPConst(FCmpInst &I, Instruction *LHSI,
724  Constant *RHSC);
725  Instruction *foldICmpAddOpConst(Value *X, ConstantInt *CI,
726  ICmpInst::Predicate Pred);
727  Instruction *foldICmpWithCastAndCast(ICmpInst &ICI);
728 
729  Instruction *foldICmpUsingKnownBits(ICmpInst &Cmp);
730  Instruction *foldICmpWithConstant(ICmpInst &Cmp);
731  Instruction *foldICmpInstWithConstant(ICmpInst &Cmp);
732  Instruction *foldICmpInstWithConstantNotInt(ICmpInst &Cmp);
733  Instruction *foldICmpBinOp(ICmpInst &Cmp);
734  Instruction *foldICmpEquality(ICmpInst &Cmp);
735  Instruction *foldICmpWithZero(ICmpInst &Cmp);
736 
737  Instruction *foldICmpSelectConstant(ICmpInst &Cmp, SelectInst *Select,
738  ConstantInt *C);
739  Instruction *foldICmpTruncConstant(ICmpInst &Cmp, TruncInst *Trunc,
740  const APInt &C);
741  Instruction *foldICmpAndConstant(ICmpInst &Cmp, BinaryOperator *And,
742  const APInt &C);
743  Instruction *foldICmpXorConstant(ICmpInst &Cmp, BinaryOperator *Xor,
744  const APInt &C);
745  Instruction *foldICmpOrConstant(ICmpInst &Cmp, BinaryOperator *Or,
746  const APInt &C);
747  Instruction *foldICmpMulConstant(ICmpInst &Cmp, BinaryOperator *Mul,
748  const APInt &C);
749  Instruction *foldICmpShlConstant(ICmpInst &Cmp, BinaryOperator *Shl,
750  const APInt &C);
751  Instruction *foldICmpShrConstant(ICmpInst &Cmp, BinaryOperator *Shr,
752  const APInt &C);
753  Instruction *foldICmpUDivConstant(ICmpInst &Cmp, BinaryOperator *UDiv,
754  const APInt &C);
755  Instruction *foldICmpDivConstant(ICmpInst &Cmp, BinaryOperator *Div,
756  const APInt &C);
757  Instruction *foldICmpSubConstant(ICmpInst &Cmp, BinaryOperator *Sub,
758  const APInt &C);
759  Instruction *foldICmpAddConstant(ICmpInst &Cmp, BinaryOperator *Add,
760  const APInt &C);
761  Instruction *foldICmpAndConstConst(ICmpInst &Cmp, BinaryOperator *And,
762  const APInt &C1);
763  Instruction *foldICmpAndShift(ICmpInst &Cmp, BinaryOperator *And,
764  const APInt &C1, const APInt &C2);
765  Instruction *foldICmpShrConstConst(ICmpInst &I, Value *ShAmt, const APInt &C1,
766  const APInt &C2);
767  Instruction *foldICmpShlConstConst(ICmpInst &I, Value *ShAmt, const APInt &C1,
768  const APInt &C2);
769 
770  Instruction *foldICmpBinOpEqualityWithConstant(ICmpInst &Cmp,
771  BinaryOperator *BO,
772  const APInt &C);
773  Instruction *foldICmpIntrinsicWithConstant(ICmpInst &ICI, const APInt &C);
774 
775  // Helpers of visitSelectInst().
776  Instruction *foldSelectExtConst(SelectInst &Sel);
777  Instruction *foldSelectOpOp(SelectInst &SI, Instruction *TI, Instruction *FI);
778  Instruction *foldSelectIntoOp(SelectInst &SI, Value *, Value *);
779  Instruction *foldSPFofSPF(Instruction *Inner, SelectPatternFlavor SPF1,
780  Value *A, Value *B, Instruction &Outer,
781  SelectPatternFlavor SPF2, Value *C);
782  Instruction *foldSelectInstWithICmp(SelectInst &SI, ICmpInst *ICI);
783 
784  Instruction *OptAndOp(BinaryOperator *Op, ConstantInt *OpRHS,
785  ConstantInt *AndRHS, BinaryOperator &TheAnd);
786 
787  Value *insertRangeTest(Value *V, const APInt &Lo, const APInt &Hi,
788  bool isSigned, bool Inside);
789  Instruction *PromoteCastOfAllocation(BitCastInst &CI, AllocaInst &AI);
790  Instruction *MatchBSwap(BinaryOperator &I);
791  bool SimplifyStoreAtEndOfBlock(StoreInst &SI);
792 
793  Instruction *SimplifyElementUnorderedAtomicMemCpy(AtomicMemCpyInst *AMI);
794  Instruction *SimplifyMemTransfer(MemIntrinsic *MI);
795  Instruction *SimplifyMemSet(MemSetInst *MI);
796 
797  Value *EvaluateInDifferentType(Value *V, Type *Ty, bool isSigned);
798 
799  /// \brief Returns a value X such that Val = X * Scale, or null if none.
800  ///
801  /// If the multiplication is known not to overflow then NoSignedWrap is set.
802  Value *Descale(Value *Val, APInt Scale, bool &NoSignedWrap);
803 };
804 
805 } // end namespace llvm
806 
807 #undef DEBUG_TYPE
808 
809 #endif // LLVM_LIB_TRANSFORMS_INSTCOMBINE_INSTCOMBINEINTERNAL_H
Value * EmitGEPOffset(IRBuilderTy *Builder, const DataLayout &DL, User *GEP, bool NoAssumptions=false)
Given a getelementptr instruction/constantexpr, emit the code necessary to compute the offset from th...
Definition: Local.h:259
uint64_t CallInst * C
Return a value (possibly void), from a function.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks &#39;this&#39; from the containing basic block and deletes it.
Definition: Instruction.cpp:67
Instruction * InsertNewInstWith(Instruction *New, Instruction &Old)
Same as InsertNewInstBefore, but also sets the debug loc.
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
void computeKnownBits(const Value *V, KnownBits &Known, unsigned Depth, const Instruction *CxtI) const
bool isKnownToBeAPowerOfTwo(const Value *V, const DataLayout &DL, bool OrZero=false, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
Return true if the given value is known to have exactly one bit set when defined. ...
This class is the base class for the comparison instructions.
Definition: InstrTypes.h:875
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static bool IsFreeToInvert(Value *V, bool WillInvertAllUses)
Return true if the specified value is free to invert (apply ~ to).
This instruction extracts a struct member or array element value from an aggregate value...
Base class for instruction visitors.
Definition: InstVisitor.h:81
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
An instruction for ordering other memory operations.
Definition: Instructions.h:440
This class represents zero extension of integer types.
This class represents a function call, abstracting a target machine&#39;s calling convention.
static bool isCanonicalPredicate(CmpInst::Predicate Pred)
Predicate canonicalization reduces the number of patterns that need to be matched by other transforms...
unsigned less or equal
Definition: InstrTypes.h:911
void Remove(Instruction *I)
A cache of .assume calls within a function.
This class represents the atomic memcpy intrinsic i.e.
This instruction constructs a fixed permutation of two input vectors.
void Add(Instruction *I)
Add - Add the specified instruction to the worklist if it isn&#39;t already in it.
This class wraps the llvm.memset intrinsic.
This class represents a sign extension of integer types.
An instruction for reading from memory.
Definition: Instructions.h:164
uint64_t MaxArraySizeForCombine
Maximum size of array considered when transforming.
Hexagon Common GEP
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2175
bool isVectorTy() const
True if this is an instance of VectorType.
Definition: Type.h:227
static OverflowCheckFlavor IntrinsicIDToOverflowCheckFlavor(unsigned ID)
Returns the OverflowCheckFlavor corresponding to a overflow_with_op intrinsic.
This defines the Use class.
OverflowResult computeOverflowForSignedAdd(const Value *LHS, const Value *RHS, const Instruction *CxtI) const
static Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2164
This class represents a conversion between pointers from one address space to another.
static unsigned getComplexity(Value *V)
Assign a complexity or rank value to LLVM Values.
OverflowResult computeOverflowForUnsignedMul(const Value *LHS, const Value *RHS, const Instruction *CxtI) const
This class represents the LLVM &#39;select&#39; instruction.
OverflowCheckFlavor
Specific patterns of overflow check idioms that we match.
This is the base class for all instructions that perform data casts.
Definition: InstrTypes.h:592
Class to represent struct types.
Definition: DerivedTypes.h:201
A Use represents the edge between a Value definition and its users.
Definition: Use.h:56
Instruction * eraseInstFromFunction(Instruction &I)
Combiner aware instruction erasure.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:714
The core instruction combiner logic.
static Constant * AddOne(Constant *C)
Add one to a Constant.
0 1 0 1 True if ordered and less than or equal
Definition: InstrTypes.h:892
This class represents a cast from a pointer to an integer.
DominatorTree & getDominatorTree() const
static Value * peekThroughBitcast(Value *V, bool OneUseOnly=false)
Return the source operand of a potentially bitcasted value while optionally checking if it has one us...
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:245
This represents the llvm.va_start intrinsic.
void salvageDebugInfo(Instruction &I)
Assuming the instruction I is going to be deleted, attempt to salvage any dbg.value intrinsics referr...
Definition: Local.cpp:1491
This instruction compares its operands according to the predicate given to the constructor.
This class represents a no-op cast from one type to another.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
An instruction for storing to memory.
Definition: Instructions.h:306
Instruction * visitInstruction(Instruction &I)
Specify what to return for unhandled instructions.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:439
This class represents a cast from floating point to signed integer.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:142
This class represents a truncation of integer types.
Class to represent pointers.
Definition: DerivedTypes.h:467
const DataLayout & getDataLayout() const
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
Definition: Instructions.h:837
This instruction inserts a single (scalar) element into a VectorType value.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
OverflowResult computeOverflowForSignedAdd(const Value *LHS, const Value *RHS, const DataLayout &DL, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
Definition: Instruction.h:282
LLVM Basic Block Representation.
Definition: BasicBlock.h:59
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
void AddUsersToWorkList(Instruction &I)
AddUsersToWorkList - When an instruction is simplified, add all users of the instruction to the work ...
Conditional or Unconditional Branch instruction.
This is an important base class in LLVM.
Definition: Constant.h:42
bool isKnownToBeAPowerOfTwo(const Value *V, bool OrZero=false, unsigned Depth=0, const Instruction *CxtI=nullptr)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool MaskedValueIsZero(const Value *V, const APInt &Mask, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
Return true if &#39;V & Mask&#39; is known to be zero.
InstCombiner(InstCombineWorklist &Worklist, BuilderTy &Builder, bool MinimizeSize, bool ExpensiveCombines, AliasAnalysis *AA, AssumptionCache &AC, TargetLibraryInfo &TLI, DominatorTree &DT, OptimizationRemarkEmitter &ORE, const DataLayout &DL, LoopInfo *LI)
This instruction compares its operands according to the predicate given to the constructor.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:885
Instruction * CreateOverflowTuple(IntrinsicInst *II, Value *Result, Constant *Overflow)
Creates a result tuple for an overflow intrinsic II with a given Result and a constant Overflow value...
static Constant * get(StructType *T, ArrayRef< Constant *> V)
Definition: Constants.cpp:998
op_range operands()
Definition: User.h:222
#define LLVM_LIBRARY_VISIBILITY
LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked into a shared library...
Definition: Compiler.h:105
static bool isNot(const Value *V)
self_iterator getIterator()
Definition: ilist_node.h:82
This class represents a cast from an integer to a pointer.
InstCombineWorklist - This is the worklist management logic for InstCombine.
static UndefValue * get(Type *T)
Static factory methods - Return an &#39;undef&#39; object of the specified type.
Definition: Constants.cpp:1369
TargetLibraryInfo & getTargetLibraryInfo() const
InstCombineWorklist & Worklist
A worklist of the instructions that need to be simplified.
const InstListType & getInstList() const
Return the underlying instruction list container.
Definition: BasicBlock.h:317
OverflowResult computeOverflowForUnsignedAdd(const Value *LHS, const Value *RHS, const Instruction *CxtI) const
This is the common base class for memset/memcpy/memmove.
unsigned getNumOperands() const
Definition: User.h:176
This is the shared class of boolean and integer constants.
Definition: Constants.h:84
unsigned ComputeNumSignBits(const Value *Op, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
Return the number of times the sign bit of the register is replicated into the other bits...
SelectPatternFlavor
Specific patterns of select instructions we can match.
Provides information about what library functions are available for the current target.
unsigned ComputeNumSignBits(const Value *Op, unsigned Depth=0, const Instruction *CxtI=nullptr) const
This class represents a cast from floating point to unsigned integer.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Definition: Constants.cpp:598
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
unsigned getVectorNumElements() const
Definition: DerivedTypes.h:462
signed less or equal
Definition: InstrTypes.h:915
static bool isNeg(const Value *V)
Check if the given Value is a NEG, FNeg, or NOT instruction.
Class for arbitrary precision integers.
Definition: APInt.h:69
LoopInfo * getLoopInfo() const
bool MaskedValueIsZero(const Value *V, const APInt &Mask, unsigned Depth=0, const Instruction *CxtI=nullptr) const
iterator insert(iterator where, pointer New)
Definition: ilist.h:241
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition: Instruction.h:285
OverflowResult
unsigned greater or equal
Definition: InstrTypes.h:909
KnownBits computeKnownBits(const Value *V, unsigned Depth, const Instruction *CxtI) const
static bool isFNeg(const Value *V, bool IgnoreZeroSign=false)
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
#define I(x, y, z)
Definition: MD5.cpp:58
0 1 1 0 True if ordered and operands are unequal
Definition: InstrTypes.h:893
This instruction extracts a single (scalar) element from a VectorType value.
Instruction * InsertNewInstBefore(Instruction *New, Instruction &Old)
Inserts an instruction New before instruction Old.
AssumptionCache & getAssumptionCache() const
OverflowResult computeOverflowForUnsignedMul(const Value *LHS, const Value *RHS, const DataLayout &DL, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT)
OverflowResult computeOverflowForUnsignedAdd(const Value *LHS, const Value *RHS, const DataLayout &DL, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT)
Multiway switch.
This represents the llvm.va_copy intrinsic.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Instruction * replaceInstUsesWith(Instruction &I, Value *V)
A combiner-aware RAUW-like routine.
This class represents a truncation of floating point types.
LLVM Value Representation.
Definition: Value.h:73
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E&#39;s largest value.
Definition: BitmaskEnum.h:81
Invoke instruction.
#define DEBUG(X)
Definition: Debug.h:118
IRTranslator LLVM IR MI
0 0 1 1 True if ordered and greater than or equal
Definition: InstrTypes.h:890
void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
The optimization diagnostic interface.
bool use_empty() const
Definition: Value.h:328
static Constant * SubOne(Constant *C)
Subtract one from a Constant.
signed greater or equal
Definition: InstrTypes.h:913
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:44
const BasicBlock * getParent() const
Definition: Instruction.h:67
an instruction to allocate memory on the stack
Definition: Instructions.h:60
This instruction inserts a struct field of array element value into an aggregate value.