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