LLVM  9.0.0svn
Float2Int.cpp
Go to the documentation of this file.
1 //===- Float2Int.cpp - Demote floating point ops to work on integers ------===//
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 Float2Int pass, which aims to demote floating
10 // point operations to work on integers, where that is losslessly possible.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #define DEBUG_TYPE "float2int"
15 
17 #include "llvm/ADT/APInt.h"
18 #include "llvm/ADT/APSInt.h"
19 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/IR/Constants.h"
23 #include "llvm/IR/IRBuilder.h"
24 #include "llvm/IR/InstIterator.h"
25 #include "llvm/IR/Instructions.h"
26 #include "llvm/IR/Module.h"
27 #include "llvm/Pass.h"
28 #include "llvm/Support/Debug.h"
30 #include "llvm/Transforms/Scalar.h"
31 #include <deque>
32 #include <functional> // For std::function
33 using namespace llvm;
34 
35 // The algorithm is simple. Start at instructions that convert from the
36 // float to the int domain: fptoui, fptosi and fcmp. Walk up the def-use
37 // graph, using an equivalence datastructure to unify graphs that interfere.
38 //
39 // Mappable instructions are those with an integer corrollary that, given
40 // integer domain inputs, produce an integer output; fadd, for example.
41 //
42 // If a non-mappable instruction is seen, this entire def-use graph is marked
43 // as non-transformable. If we see an instruction that converts from the
44 // integer domain to FP domain (uitofp,sitofp), we terminate our walk.
45 
46 /// The largest integer type worth dealing with.
47 static cl::opt<unsigned>
48 MaxIntegerBW("float2int-max-integer-bw", cl::init(64), cl::Hidden,
49  cl::desc("Max integer bitwidth to consider in float2int"
50  "(default=64)"));
51 
52 namespace {
53  struct Float2IntLegacyPass : public FunctionPass {
54  static char ID; // Pass identification, replacement for typeid
55  Float2IntLegacyPass() : FunctionPass(ID) {
57  }
58 
59  bool runOnFunction(Function &F) override {
60  if (skipFunction(F))
61  return false;
62 
63  return Impl.runImpl(F);
64  }
65 
66  void getAnalysisUsage(AnalysisUsage &AU) const override {
67  AU.setPreservesCFG();
69  }
70 
71  private:
72  Float2IntPass Impl;
73  };
74 }
75 
77 INITIALIZE_PASS(Float2IntLegacyPass, "float2int", "Float to int", false, false)
78 
79 // Given a FCmp predicate, return a matching ICmp predicate if one
80 // exists, otherwise return BAD_ICMP_PREDICATE.
82  switch (P) {
83  case CmpInst::FCMP_OEQ:
84  case CmpInst::FCMP_UEQ:
85  return CmpInst::ICMP_EQ;
86  case CmpInst::FCMP_OGT:
87  case CmpInst::FCMP_UGT:
88  return CmpInst::ICMP_SGT;
89  case CmpInst::FCMP_OGE:
90  case CmpInst::FCMP_UGE:
91  return CmpInst::ICMP_SGE;
92  case CmpInst::FCMP_OLT:
93  case CmpInst::FCMP_ULT:
94  return CmpInst::ICMP_SLT;
95  case CmpInst::FCMP_OLE:
96  case CmpInst::FCMP_ULE:
97  return CmpInst::ICMP_SLE;
98  case CmpInst::FCMP_ONE:
99  case CmpInst::FCMP_UNE:
100  return CmpInst::ICMP_NE;
101  default:
103  }
104 }
105 
106 // Given a floating point binary operator, return the matching
107 // integer version.
108 static Instruction::BinaryOps mapBinOpcode(unsigned Opcode) {
109  switch (Opcode) {
110  default: llvm_unreachable("Unhandled opcode!");
111  case Instruction::FAdd: return Instruction::Add;
112  case Instruction::FSub: return Instruction::Sub;
113  case Instruction::FMul: return Instruction::Mul;
114  }
115 }
116 
117 // Find the roots - instructions that convert from the FP domain to
118 // integer domain.
119 void Float2IntPass::findRoots(Function &F, SmallPtrSet<Instruction*,8> &Roots) {
120  for (auto &I : instructions(F)) {
121  if (isa<VectorType>(I.getType()))
122  continue;
123  switch (I.getOpcode()) {
124  default: break;
125  case Instruction::FPToUI:
126  case Instruction::FPToSI:
127  Roots.insert(&I);
128  break;
129  case Instruction::FCmp:
130  if (mapFCmpPred(cast<CmpInst>(&I)->getPredicate()) !=
132  Roots.insert(&I);
133  break;
134  }
135  }
136 }
137 
138 // Helper - mark I as having been traversed, having range R.
139 void Float2IntPass::seen(Instruction *I, ConstantRange R) {
140  LLVM_DEBUG(dbgs() << "F2I: " << *I << ":" << R << "\n");
141  auto IT = SeenInsts.find(I);
142  if (IT != SeenInsts.end())
143  IT->second = std::move(R);
144  else
145  SeenInsts.insert(std::make_pair(I, std::move(R)));
146 }
147 
148 // Helper - get a range representing a poison value.
149 ConstantRange Float2IntPass::badRange() {
150  return ConstantRange::getFull(MaxIntegerBW + 1);
151 }
152 ConstantRange Float2IntPass::unknownRange() {
153  return ConstantRange::getEmpty(MaxIntegerBW + 1);
154 }
155 ConstantRange Float2IntPass::validateRange(ConstantRange R) {
156  if (R.getBitWidth() > MaxIntegerBW + 1)
157  return badRange();
158  return R;
159 }
160 
161 // The most obvious way to structure the search is a depth-first, eager
162 // search from each root. However, that require direct recursion and so
163 // can only handle small instruction sequences. Instead, we split the search
164 // up into two phases:
165 // - walkBackwards: A breadth-first walk of the use-def graph starting from
166 // the roots. Populate "SeenInsts" with interesting
167 // instructions and poison values if they're obvious and
168 // cheap to compute. Calculate the equivalance set structure
169 // while we're here too.
170 // - walkForwards: Iterate over SeenInsts in reverse order, so we visit
171 // defs before their uses. Calculate the real range info.
172 
173 // Breadth-first walk of the use-def graph; determine the set of nodes
174 // we care about and eagerly determine if some of them are poisonous.
175 void Float2IntPass::walkBackwards(const SmallPtrSetImpl<Instruction*> &Roots) {
176  std::deque<Instruction*> Worklist(Roots.begin(), Roots.end());
177  while (!Worklist.empty()) {
178  Instruction *I = Worklist.back();
179  Worklist.pop_back();
180 
181  if (SeenInsts.find(I) != SeenInsts.end())
182  // Seen already.
183  continue;
184 
185  switch (I->getOpcode()) {
186  // FIXME: Handle select and phi nodes.
187  default:
188  // Path terminated uncleanly.
189  seen(I, badRange());
190  break;
191 
192  case Instruction::UIToFP:
193  case Instruction::SIToFP: {
194  // Path terminated cleanly - use the type of the integer input to seed
195  // the analysis.
196  unsigned BW = I->getOperand(0)->getType()->getPrimitiveSizeInBits();
197  auto Input = ConstantRange::getFull(BW);
198  auto CastOp = (Instruction::CastOps)I->getOpcode();
199  seen(I, validateRange(Input.castOp(CastOp, MaxIntegerBW+1)));
200  continue;
201  }
202 
203  case Instruction::FNeg:
204  case Instruction::FAdd:
205  case Instruction::FSub:
206  case Instruction::FMul:
207  case Instruction::FPToUI:
208  case Instruction::FPToSI:
209  case Instruction::FCmp:
210  seen(I, unknownRange());
211  break;
212  }
213 
214  for (Value *O : I->operands()) {
215  if (Instruction *OI = dyn_cast<Instruction>(O)) {
216  // Unify def-use chains if they interfere.
217  ECs.unionSets(I, OI);
218  if (SeenInsts.find(I)->second != badRange())
219  Worklist.push_back(OI);
220  } else if (!isa<ConstantFP>(O)) {
221  // Not an instruction or ConstantFP? we can't do anything.
222  seen(I, badRange());
223  }
224  }
225  }
226 }
227 
228 // Walk forwards down the list of seen instructions, so we visit defs before
229 // uses.
230 void Float2IntPass::walkForwards() {
231  for (auto &It : reverse(SeenInsts)) {
232  if (It.second != unknownRange())
233  continue;
234 
235  Instruction *I = It.first;
236  std::function<ConstantRange(ArrayRef<ConstantRange>)> Op;
237  switch (I->getOpcode()) {
238  // FIXME: Handle select and phi nodes.
239  default:
240  case Instruction::UIToFP:
241  case Instruction::SIToFP:
242  llvm_unreachable("Should have been handled in walkForwards!");
243 
244  case Instruction::FNeg:
245  Op = [](ArrayRef<ConstantRange> Ops) {
246  assert(Ops.size() == 1 && "FNeg is a unary operator!");
247  unsigned Size = Ops[0].getBitWidth();
248  auto Zero = ConstantRange(APInt::getNullValue(Size));
249  return Zero.sub(Ops[0]);
250  };
251  break;
252 
253  case Instruction::FAdd:
254  case Instruction::FSub:
255  case Instruction::FMul:
256  Op = [I](ArrayRef<ConstantRange> Ops) {
257  assert(Ops.size() == 2 && "its a binary operator!");
258  auto BinOp = (Instruction::BinaryOps) I->getOpcode();
259  return Ops[0].binaryOp(BinOp, Ops[1]);
260  };
261  break;
262 
263  //
264  // Root-only instructions - we'll only see these if they're the
265  // first node in a walk.
266  //
267  case Instruction::FPToUI:
268  case Instruction::FPToSI:
269  Op = [I](ArrayRef<ConstantRange> Ops) {
270  assert(Ops.size() == 1 && "FPTo[US]I is a unary operator!");
271  // Note: We're ignoring the casts output size here as that's what the
272  // caller expects.
273  auto CastOp = (Instruction::CastOps)I->getOpcode();
274  return Ops[0].castOp(CastOp, MaxIntegerBW+1);
275  };
276  break;
277 
278  case Instruction::FCmp:
279  Op = [](ArrayRef<ConstantRange> Ops) {
280  assert(Ops.size() == 2 && "FCmp is a binary operator!");
281  return Ops[0].unionWith(Ops[1]);
282  };
283  break;
284  }
285 
286  bool Abort = false;
288  for (Value *O : I->operands()) {
289  if (Instruction *OI = dyn_cast<Instruction>(O)) {
290  assert(SeenInsts.find(OI) != SeenInsts.end() &&
291  "def not seen before use!");
292  OpRanges.push_back(SeenInsts.find(OI)->second);
293  } else if (ConstantFP *CF = dyn_cast<ConstantFP>(O)) {
294  // Work out if the floating point number can be losslessly represented
295  // as an integer.
296  // APFloat::convertToInteger(&Exact) purports to do what we want, but
297  // the exactness can be too precise. For example, negative zero can
298  // never be exactly converted to an integer.
299  //
300  // Instead, we ask APFloat to round itself to an integral value - this
301  // preserves sign-of-zero - then compare the result with the original.
302  //
303  const APFloat &F = CF->getValueAPF();
304 
305  // First, weed out obviously incorrect values. Non-finite numbers
306  // can't be represented and neither can negative zero, unless
307  // we're in fast math mode.
308  if (!F.isFinite() ||
309  (F.isZero() && F.isNegative() && isa<FPMathOperator>(I) &&
310  !I->hasNoSignedZeros())) {
311  seen(I, badRange());
312  Abort = true;
313  break;
314  }
315 
316  APFloat NewF = F;
318  if (Res != APFloat::opOK || NewF.compare(F) != APFloat::cmpEqual) {
319  seen(I, badRange());
320  Abort = true;
321  break;
322  }
323  // OK, it's representable. Now get it.
324  APSInt Int(MaxIntegerBW+1, false);
325  bool Exact;
326  CF->getValueAPF().convertToInteger(Int,
328  &Exact);
329  OpRanges.push_back(ConstantRange(Int));
330  } else {
331  llvm_unreachable("Should have already marked this as badRange!");
332  }
333  }
334 
335  // Reduce the operands' ranges to a single range and return.
336  if (!Abort)
337  seen(I, Op(OpRanges));
338  }
339 }
340 
341 // If there is a valid transform to be done, do it.
342 bool Float2IntPass::validateAndTransform() {
343  bool MadeChange = false;
344 
345  // Iterate over every disjoint partition of the def-use graph.
346  for (auto It = ECs.begin(), E = ECs.end(); It != E; ++It) {
347  ConstantRange R(MaxIntegerBW + 1, false);
348  bool Fail = false;
349  Type *ConvertedToTy = nullptr;
350 
351  // For every member of the partition, union all the ranges together.
352  for (auto MI = ECs.member_begin(It), ME = ECs.member_end();
353  MI != ME; ++MI) {
354  Instruction *I = *MI;
355  auto SeenI = SeenInsts.find(I);
356  if (SeenI == SeenInsts.end())
357  continue;
358 
359  R = R.unionWith(SeenI->second);
360  // We need to ensure I has no users that have not been seen.
361  // If it does, transformation would be illegal.
362  //
363  // Don't count the roots, as they terminate the graphs.
364  if (Roots.count(I) == 0) {
365  // Set the type of the conversion while we're here.
366  if (!ConvertedToTy)
367  ConvertedToTy = I->getType();
368  for (User *U : I->users()) {
369  Instruction *UI = dyn_cast<Instruction>(U);
370  if (!UI || SeenInsts.find(UI) == SeenInsts.end()) {
371  LLVM_DEBUG(dbgs() << "F2I: Failing because of " << *U << "\n");
372  Fail = true;
373  break;
374  }
375  }
376  }
377  if (Fail)
378  break;
379  }
380 
381  // If the set was empty, or we failed, or the range is poisonous,
382  // bail out.
383  if (ECs.member_begin(It) == ECs.member_end() || Fail ||
384  R.isFullSet() || R.isSignWrappedSet())
385  continue;
386  assert(ConvertedToTy && "Must have set the convertedtoty by this point!");
387 
388  // The number of bits required is the maximum of the upper and
389  // lower limits, plus one so it can be signed.
390  unsigned MinBW = std::max(R.getLower().getMinSignedBits(),
391  R.getUpper().getMinSignedBits()) + 1;
392  LLVM_DEBUG(dbgs() << "F2I: MinBitwidth=" << MinBW << ", R: " << R << "\n");
393 
394  // If we've run off the realms of the exactly representable integers,
395  // the floating point result will differ from an integer approximation.
396 
397  // Do we need more bits than are in the mantissa of the type we converted
398  // to? semanticsPrecision returns the number of mantissa bits plus one
399  // for the sign bit.
400  unsigned MaxRepresentableBits
401  = APFloat::semanticsPrecision(ConvertedToTy->getFltSemantics()) - 1;
402  if (MinBW > MaxRepresentableBits) {
403  LLVM_DEBUG(dbgs() << "F2I: Value not guaranteed to be representable!\n");
404  continue;
405  }
406  if (MinBW > 64) {
407  LLVM_DEBUG(
408  dbgs() << "F2I: Value requires more than 64 bits to represent!\n");
409  continue;
410  }
411 
412  // OK, R is known to be representable. Now pick a type for it.
413  // FIXME: Pick the smallest legal type that will fit.
414  Type *Ty = (MinBW > 32) ? Type::getInt64Ty(*Ctx) : Type::getInt32Ty(*Ctx);
415 
416  for (auto MI = ECs.member_begin(It), ME = ECs.member_end();
417  MI != ME; ++MI)
418  convert(*MI, Ty);
419  MadeChange = true;
420  }
421 
422  return MadeChange;
423 }
424 
425 Value *Float2IntPass::convert(Instruction *I, Type *ToTy) {
426  if (ConvertedInsts.find(I) != ConvertedInsts.end())
427  // Already converted this instruction.
428  return ConvertedInsts[I];
429 
430  SmallVector<Value*,4> NewOperands;
431  for (Value *V : I->operands()) {
432  // Don't recurse if we're an instruction that terminates the path.
433  if (I->getOpcode() == Instruction::UIToFP ||
434  I->getOpcode() == Instruction::SIToFP) {
435  NewOperands.push_back(V);
436  } else if (Instruction *VI = dyn_cast<Instruction>(V)) {
437  NewOperands.push_back(convert(VI, ToTy));
438  } else if (ConstantFP *CF = dyn_cast<ConstantFP>(V)) {
439  APSInt Val(ToTy->getPrimitiveSizeInBits(), /*IsUnsigned=*/false);
440  bool Exact;
441  CF->getValueAPF().convertToInteger(Val,
443  &Exact);
444  NewOperands.push_back(ConstantInt::get(ToTy, Val));
445  } else {
446  llvm_unreachable("Unhandled operand type?");
447  }
448  }
449 
450  // Now create a new instruction.
451  IRBuilder<> IRB(I);
452  Value *NewV = nullptr;
453  switch (I->getOpcode()) {
454  default: llvm_unreachable("Unhandled instruction!");
455 
456  case Instruction::FPToUI:
457  NewV = IRB.CreateZExtOrTrunc(NewOperands[0], I->getType());
458  break;
459 
460  case Instruction::FPToSI:
461  NewV = IRB.CreateSExtOrTrunc(NewOperands[0], I->getType());
462  break;
463 
464  case Instruction::FCmp: {
465  CmpInst::Predicate P = mapFCmpPred(cast<CmpInst>(I)->getPredicate());
466  assert(P != CmpInst::BAD_ICMP_PREDICATE && "Unhandled predicate!");
467  NewV = IRB.CreateICmp(P, NewOperands[0], NewOperands[1], I->getName());
468  break;
469  }
470 
471  case Instruction::UIToFP:
472  NewV = IRB.CreateZExtOrTrunc(NewOperands[0], ToTy);
473  break;
474 
475  case Instruction::SIToFP:
476  NewV = IRB.CreateSExtOrTrunc(NewOperands[0], ToTy);
477  break;
478 
479  case Instruction::FNeg:
480  NewV = IRB.CreateNeg(NewOperands[0], I->getName());
481  break;
482 
483  case Instruction::FAdd:
484  case Instruction::FSub:
485  case Instruction::FMul:
486  NewV = IRB.CreateBinOp(mapBinOpcode(I->getOpcode()),
487  NewOperands[0], NewOperands[1],
488  I->getName());
489  break;
490  }
491 
492  // If we're a root instruction, RAUW.
493  if (Roots.count(I))
494  I->replaceAllUsesWith(NewV);
495 
496  ConvertedInsts[I] = NewV;
497  return NewV;
498 }
499 
500 // Perform dead code elimination on the instructions we just modified.
501 void Float2IntPass::cleanup() {
502  for (auto &I : reverse(ConvertedInsts))
503  I.first->eraseFromParent();
504 }
505 
507  LLVM_DEBUG(dbgs() << "F2I: Looking at function " << F.getName() << "\n");
508  // Clear out all state.
510  SeenInsts.clear();
511  ConvertedInsts.clear();
512  Roots.clear();
513 
514  Ctx = &F.getParent()->getContext();
515 
516  findRoots(F, Roots);
517 
518  walkBackwards(Roots);
519  walkForwards();
520 
521  bool Modified = validateAndTransform();
522  if (Modified)
523  cleanup();
524  return Modified;
525 }
526 
527 namespace llvm {
528 FunctionPass *createFloat2IntPass() { return new Float2IntLegacyPass(); }
529 
531  if (!runImpl(F))
532  return PreservedAnalyses::all();
533 
535  PA.preserveSet<CFGAnalyses>();
536  PA.preserve<GlobalsAA>();
537  return PA;
538 }
539 } // End namespace llvm
Legacy wrapper pass to provide the GlobalsAAResult object.
opStatus roundToIntegral(roundingMode RM)
Definition: APFloat.h:1018
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks &#39;this&#39; from the containing basic block and deletes it.
Definition: Instruction.cpp:67
static cl::opt< unsigned > MaxIntegerBW("float2int-max-integer-bw", cl::init(64), cl::Hidden, cl::desc("Max integer bitwidth to consider in float2int" "(default=64)"))
The largest integer type worth dealing with.
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
Definition: IRBuilder.h:2168
This class is the base class for the comparison instructions.
Definition: InstrTypes.h:722
static bool runImpl(Function &F, TargetLibraryInfo &TLI, DominatorTree &DT)
This is the entry point for all transforms.
bool isZero() const
Definition: APFloat.h:1153
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
bool hasNoSignedZeros() const
Determine whether the no-signed-zeros flag is set.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Value * CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Definition: IRBuilder.h:1458
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy.
Definition: IRBuilder.h:1888
This class represents lattice values for constants.
Definition: AllocatorList.h:23
const APInt & getUpper() const
Return the upper value for this range.
This is the interface for a simple mod/ref and alias analysis over globals.
FunctionPass * createFloat2IntPass()
Definition: Float2Int.cpp:528
0 1 0 0 True if ordered and less than
Definition: InstrTypes.h:738
1 1 1 0 True if unordered or not equal
Definition: InstrTypes.h:748
F(f)
static void cleanup(BlockFrequencyInfoImplBase &BFI)
Clear all memory not needed downstream.
static IntegerType * getInt64Ty(LLVMContext &C)
Definition: Type.cpp:176
bool runImpl(Function &F)
Definition: Float2Int.cpp:506
1 0 0 1 True if unordered or equal
Definition: InstrTypes.h:743
uint32_t getBitWidth() const
Get the bit width of this ConstantRange.
#define Fail
LLVMContext & getContext() const
Get the global data context.
Definition: Module.h:244
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:779
0 1 0 1 True if ordered and less than or equal
Definition: InstrTypes.h:739
This file implements a class to represent arbitrary precision integral constant values and operations...
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
Definition: STLExtras.h:273
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:244
Value * CreateSExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a SExt or Trunc from the integer value V to DestTy.
Definition: IRBuilder.h:1903
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Definition: Instruction.h:125
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:429
Value * getOperand(unsigned i) const
Definition: User.h:169
static CmpInst::Predicate mapFCmpPred(CmpInst::Predicate P)
Definition: Float2Int.cpp:81
static bool runOnFunction(Function &F, bool PostInlining)
#define P(N)
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:432
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:153
bool isNegative() const
Definition: APFloat.h:1157
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
bool isSignWrappedSet() const
Return true if this set wraps around the signed domain.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
ConstantFP - Floating Point Values [float, double].
Definition: Constants.h:263
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:370
EquivalenceClasses - This represents a collection of equivalence classes and supports three efficient...
Represent the analysis usage information of a pass.
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Definition: IRBuilder.h:1485
Analysis pass providing a never-invalidated alias analysis result.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:732
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:284
op_range operands()
Definition: User.h:237
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Definition: SmallPtrSet.h:381
bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type. ...
void initializeFloat2IntLegacyPassPass(PassRegistry &)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:159
1 1 0 1 True if unordered, less than, or equal
Definition: InstrTypes.h:747
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
signed greater than
Definition: InstrTypes.h:759
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:33
0 0 1 0 True if ordered and greater than
Definition: InstrTypes.h:736
bool isFinite() const
Definition: APFloat.h:1162
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
Definition: PPCPredicates.h:87
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
Definition: SmallPtrSet.h:417
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:837
1 1 0 0 True if unordered or less than
Definition: InstrTypes.h:746
Module.h This file contains the declarations for the Module class.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: Float2Int.cpp:530
This class represents a range of values.
Definition: ConstantRange.h:47
signed less than
Definition: InstrTypes.h:761
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:631
void setPreservesCFG()
This function should be called by the pass, iff they do not:
Definition: Pass.cpp:301
static unsigned int semanticsPrecision(const fltSemantics &)
Definition: APFloat.cpp:190
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
signed less or equal
Definition: InstrTypes.h:762
iterator_range< user_iterator > users()
Definition: Value.h:399
Represents analyses that only rely on functions&#39; control flow.
Definition: PassManager.h:114
static Instruction::BinaryOps mapBinOpcode(unsigned Opcode)
Definition: Float2Int.cpp:108
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::ZeroOrMore, cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate IT block based on arch"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow deprecated IT based on ARMv8"), clEnumValN(NoRestrictedIT, "arm-no-restrict-it", "Allow IT blocks based on ARMv7")))
iterator begin() const
Definition: SmallPtrSet.h:396
static IntegerType * getInt32Ty(LLVMContext &C)
Definition: Type.cpp:175
void preserveSet()
Mark an analysis set as preserved.
Definition: PassManager.h:189
StringRef getName() const
Return a constant reference to the value&#39;s name.
Definition: Value.cpp:214
const APInt & getLower() const
Return the lower value for this range.
#define I(x, y, z)
Definition: MD5.cpp:58
0 1 1 0 True if ordered and operands are unequal
Definition: InstrTypes.h:740
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:332
uint32_t Size
Definition: Profile.cpp:46
void preserve()
Mark an analysis as preserved.
Definition: PassManager.h:174
1 0 1 0 True if unordered or greater than
Definition: InstrTypes.h:744
iterator end() const
Definition: SmallPtrSet.h:401
ConstantRange unionWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the union of this range with another range.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getMinSignedBits() const
Get the minimum bit size for this signed APInt.
Definition: APInt.h:1551
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Definition: Type.cpp:114
0 0 0 1 True if ordered and equal
Definition: InstrTypes.h:735
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:575
LLVM Value Representation.
Definition: Value.h:72
1 0 1 1 True if unordered, greater than, or equal
Definition: InstrTypes.h:745
IRTranslator LLVM IR MI
inst_range instructions(Function *F)
Definition: InstIterator.h:133
A container for analyses that lazily runs them and caches their results.
static APInt getNullValue(unsigned numBits)
Get the &#39;0&#39; value.
Definition: APInt.h:568
#define LLVM_DEBUG(X)
Definition: Debug.h:122
0 0 1 1 True if ordered and greater than or equal
Definition: InstrTypes.h:737
signed greater or equal
Definition: InstrTypes.h:760
cmpResult compare(const APFloat &RHS) const
Definition: APFloat.h:1112
const fltSemantics & getFltSemantics() const
Definition: Type.h:168