LLVM  10.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  const DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
64  return Impl.runImpl(F, DT);
65  }
66 
67  void getAnalysisUsage(AnalysisUsage &AU) const override {
68  AU.setPreservesCFG();
71  }
72 
73  private:
74  Float2IntPass Impl;
75  };
76 }
77 
79 INITIALIZE_PASS(Float2IntLegacyPass, "float2int", "Float to int", false, false)
80 
81 // Given a FCmp predicate, return a matching ICmp predicate if one
82 // exists, otherwise return BAD_ICMP_PREDICATE.
84  switch (P) {
85  case CmpInst::FCMP_OEQ:
86  case CmpInst::FCMP_UEQ:
87  return CmpInst::ICMP_EQ;
88  case CmpInst::FCMP_OGT:
89  case CmpInst::FCMP_UGT:
90  return CmpInst::ICMP_SGT;
91  case CmpInst::FCMP_OGE:
92  case CmpInst::FCMP_UGE:
93  return CmpInst::ICMP_SGE;
94  case CmpInst::FCMP_OLT:
95  case CmpInst::FCMP_ULT:
96  return CmpInst::ICMP_SLT;
97  case CmpInst::FCMP_OLE:
98  case CmpInst::FCMP_ULE:
99  return CmpInst::ICMP_SLE;
100  case CmpInst::FCMP_ONE:
101  case CmpInst::FCMP_UNE:
102  return CmpInst::ICMP_NE;
103  default:
105  }
106 }
107 
108 // Given a floating point binary operator, return the matching
109 // integer version.
110 static Instruction::BinaryOps mapBinOpcode(unsigned Opcode) {
111  switch (Opcode) {
112  default: llvm_unreachable("Unhandled opcode!");
113  case Instruction::FAdd: return Instruction::Add;
114  case Instruction::FSub: return Instruction::Sub;
115  case Instruction::FMul: return Instruction::Mul;
116  }
117 }
118 
119 // Find the roots - instructions that convert from the FP domain to
120 // integer domain.
121 void Float2IntPass::findRoots(Function &F, const DominatorTree &DT,
123  for (BasicBlock &BB : F) {
124  // Unreachable code can take on strange forms that we are not prepared to
125  // handle. For example, an instruction may have itself as an operand.
126  if (!DT.isReachableFromEntry(&BB))
127  continue;
128 
129  for (Instruction &I : BB) {
130  if (isa<VectorType>(I.getType()))
131  continue;
132  switch (I.getOpcode()) {
133  default: break;
134  case Instruction::FPToUI:
135  case Instruction::FPToSI:
136  Roots.insert(&I);
137  break;
138  case Instruction::FCmp:
139  if (mapFCmpPred(cast<CmpInst>(&I)->getPredicate()) !=
141  Roots.insert(&I);
142  break;
143  }
144  }
145  }
146 }
147 
148 // Helper - mark I as having been traversed, having range R.
149 void Float2IntPass::seen(Instruction *I, ConstantRange R) {
150  LLVM_DEBUG(dbgs() << "F2I: " << *I << ":" << R << "\n");
151  auto IT = SeenInsts.find(I);
152  if (IT != SeenInsts.end())
153  IT->second = std::move(R);
154  else
155  SeenInsts.insert(std::make_pair(I, std::move(R)));
156 }
157 
158 // Helper - get a range representing a poison value.
159 ConstantRange Float2IntPass::badRange() {
160  return ConstantRange::getFull(MaxIntegerBW + 1);
161 }
162 ConstantRange Float2IntPass::unknownRange() {
163  return ConstantRange::getEmpty(MaxIntegerBW + 1);
164 }
165 ConstantRange Float2IntPass::validateRange(ConstantRange R) {
166  if (R.getBitWidth() > MaxIntegerBW + 1)
167  return badRange();
168  return R;
169 }
170 
171 // The most obvious way to structure the search is a depth-first, eager
172 // search from each root. However, that require direct recursion and so
173 // can only handle small instruction sequences. Instead, we split the search
174 // up into two phases:
175 // - walkBackwards: A breadth-first walk of the use-def graph starting from
176 // the roots. Populate "SeenInsts" with interesting
177 // instructions and poison values if they're obvious and
178 // cheap to compute. Calculate the equivalance set structure
179 // while we're here too.
180 // - walkForwards: Iterate over SeenInsts in reverse order, so we visit
181 // defs before their uses. Calculate the real range info.
182 
183 // Breadth-first walk of the use-def graph; determine the set of nodes
184 // we care about and eagerly determine if some of them are poisonous.
185 void Float2IntPass::walkBackwards(const SmallPtrSetImpl<Instruction*> &Roots) {
186  std::deque<Instruction*> Worklist(Roots.begin(), Roots.end());
187  while (!Worklist.empty()) {
188  Instruction *I = Worklist.back();
189  Worklist.pop_back();
190 
191  if (SeenInsts.find(I) != SeenInsts.end())
192  // Seen already.
193  continue;
194 
195  switch (I->getOpcode()) {
196  // FIXME: Handle select and phi nodes.
197  default:
198  // Path terminated uncleanly.
199  seen(I, badRange());
200  break;
201 
202  case Instruction::UIToFP:
203  case Instruction::SIToFP: {
204  // Path terminated cleanly - use the type of the integer input to seed
205  // the analysis.
206  unsigned BW = I->getOperand(0)->getType()->getPrimitiveSizeInBits();
207  auto Input = ConstantRange::getFull(BW);
208  auto CastOp = (Instruction::CastOps)I->getOpcode();
209  seen(I, validateRange(Input.castOp(CastOp, MaxIntegerBW+1)));
210  continue;
211  }
212 
213  case Instruction::FNeg:
214  case Instruction::FAdd:
215  case Instruction::FSub:
216  case Instruction::FMul:
217  case Instruction::FPToUI:
218  case Instruction::FPToSI:
219  case Instruction::FCmp:
220  seen(I, unknownRange());
221  break;
222  }
223 
224  for (Value *O : I->operands()) {
225  if (Instruction *OI = dyn_cast<Instruction>(O)) {
226  // Unify def-use chains if they interfere.
227  ECs.unionSets(I, OI);
228  if (SeenInsts.find(I)->second != badRange())
229  Worklist.push_back(OI);
230  } else if (!isa<ConstantFP>(O)) {
231  // Not an instruction or ConstantFP? we can't do anything.
232  seen(I, badRange());
233  }
234  }
235  }
236 }
237 
238 // Walk forwards down the list of seen instructions, so we visit defs before
239 // uses.
240 void Float2IntPass::walkForwards() {
241  for (auto &It : reverse(SeenInsts)) {
242  if (It.second != unknownRange())
243  continue;
244 
245  Instruction *I = It.first;
246  std::function<ConstantRange(ArrayRef<ConstantRange>)> Op;
247  switch (I->getOpcode()) {
248  // FIXME: Handle select and phi nodes.
249  default:
250  case Instruction::UIToFP:
251  case Instruction::SIToFP:
252  llvm_unreachable("Should have been handled in walkForwards!");
253 
254  case Instruction::FNeg:
255  Op = [](ArrayRef<ConstantRange> Ops) {
256  assert(Ops.size() == 1 && "FNeg is a unary operator!");
257  unsigned Size = Ops[0].getBitWidth();
258  auto Zero = ConstantRange(APInt::getNullValue(Size));
259  return Zero.sub(Ops[0]);
260  };
261  break;
262 
263  case Instruction::FAdd:
264  case Instruction::FSub:
265  case Instruction::FMul:
266  Op = [I](ArrayRef<ConstantRange> Ops) {
267  assert(Ops.size() == 2 && "its a binary operator!");
268  auto BinOp = (Instruction::BinaryOps) I->getOpcode();
269  return Ops[0].binaryOp(BinOp, Ops[1]);
270  };
271  break;
272 
273  //
274  // Root-only instructions - we'll only see these if they're the
275  // first node in a walk.
276  //
277  case Instruction::FPToUI:
278  case Instruction::FPToSI:
279  Op = [I](ArrayRef<ConstantRange> Ops) {
280  assert(Ops.size() == 1 && "FPTo[US]I is a unary operator!");
281  // Note: We're ignoring the casts output size here as that's what the
282  // caller expects.
283  auto CastOp = (Instruction::CastOps)I->getOpcode();
284  return Ops[0].castOp(CastOp, MaxIntegerBW+1);
285  };
286  break;
287 
288  case Instruction::FCmp:
289  Op = [](ArrayRef<ConstantRange> Ops) {
290  assert(Ops.size() == 2 && "FCmp is a binary operator!");
291  return Ops[0].unionWith(Ops[1]);
292  };
293  break;
294  }
295 
296  bool Abort = false;
298  for (Value *O : I->operands()) {
299  if (Instruction *OI = dyn_cast<Instruction>(O)) {
300  assert(SeenInsts.find(OI) != SeenInsts.end() &&
301  "def not seen before use!");
302  OpRanges.push_back(SeenInsts.find(OI)->second);
303  } else if (ConstantFP *CF = dyn_cast<ConstantFP>(O)) {
304  // Work out if the floating point number can be losslessly represented
305  // as an integer.
306  // APFloat::convertToInteger(&Exact) purports to do what we want, but
307  // the exactness can be too precise. For example, negative zero can
308  // never be exactly converted to an integer.
309  //
310  // Instead, we ask APFloat to round itself to an integral value - this
311  // preserves sign-of-zero - then compare the result with the original.
312  //
313  const APFloat &F = CF->getValueAPF();
314 
315  // First, weed out obviously incorrect values. Non-finite numbers
316  // can't be represented and neither can negative zero, unless
317  // we're in fast math mode.
318  if (!F.isFinite() ||
319  (F.isZero() && F.isNegative() && isa<FPMathOperator>(I) &&
320  !I->hasNoSignedZeros())) {
321  seen(I, badRange());
322  Abort = true;
323  break;
324  }
325 
326  APFloat NewF = F;
328  if (Res != APFloat::opOK || NewF.compare(F) != APFloat::cmpEqual) {
329  seen(I, badRange());
330  Abort = true;
331  break;
332  }
333  // OK, it's representable. Now get it.
334  APSInt Int(MaxIntegerBW+1, false);
335  bool Exact;
336  CF->getValueAPF().convertToInteger(Int,
338  &Exact);
339  OpRanges.push_back(ConstantRange(Int));
340  } else {
341  llvm_unreachable("Should have already marked this as badRange!");
342  }
343  }
344 
345  // Reduce the operands' ranges to a single range and return.
346  if (!Abort)
347  seen(I, Op(OpRanges));
348  }
349 }
350 
351 // If there is a valid transform to be done, do it.
352 bool Float2IntPass::validateAndTransform() {
353  bool MadeChange = false;
354 
355  // Iterate over every disjoint partition of the def-use graph.
356  for (auto It = ECs.begin(), E = ECs.end(); It != E; ++It) {
357  ConstantRange R(MaxIntegerBW + 1, false);
358  bool Fail = false;
359  Type *ConvertedToTy = nullptr;
360 
361  // For every member of the partition, union all the ranges together.
362  for (auto MI = ECs.member_begin(It), ME = ECs.member_end();
363  MI != ME; ++MI) {
364  Instruction *I = *MI;
365  auto SeenI = SeenInsts.find(I);
366  if (SeenI == SeenInsts.end())
367  continue;
368 
369  R = R.unionWith(SeenI->second);
370  // We need to ensure I has no users that have not been seen.
371  // If it does, transformation would be illegal.
372  //
373  // Don't count the roots, as they terminate the graphs.
374  if (Roots.count(I) == 0) {
375  // Set the type of the conversion while we're here.
376  if (!ConvertedToTy)
377  ConvertedToTy = I->getType();
378  for (User *U : I->users()) {
379  Instruction *UI = dyn_cast<Instruction>(U);
380  if (!UI || SeenInsts.find(UI) == SeenInsts.end()) {
381  LLVM_DEBUG(dbgs() << "F2I: Failing because of " << *U << "\n");
382  Fail = true;
383  break;
384  }
385  }
386  }
387  if (Fail)
388  break;
389  }
390 
391  // If the set was empty, or we failed, or the range is poisonous,
392  // bail out.
393  if (ECs.member_begin(It) == ECs.member_end() || Fail ||
394  R.isFullSet() || R.isSignWrappedSet())
395  continue;
396  assert(ConvertedToTy && "Must have set the convertedtoty by this point!");
397 
398  // The number of bits required is the maximum of the upper and
399  // lower limits, plus one so it can be signed.
400  unsigned MinBW = std::max(R.getLower().getMinSignedBits(),
401  R.getUpper().getMinSignedBits()) + 1;
402  LLVM_DEBUG(dbgs() << "F2I: MinBitwidth=" << MinBW << ", R: " << R << "\n");
403 
404  // If we've run off the realms of the exactly representable integers,
405  // the floating point result will differ from an integer approximation.
406 
407  // Do we need more bits than are in the mantissa of the type we converted
408  // to? semanticsPrecision returns the number of mantissa bits plus one
409  // for the sign bit.
410  unsigned MaxRepresentableBits
411  = APFloat::semanticsPrecision(ConvertedToTy->getFltSemantics()) - 1;
412  if (MinBW > MaxRepresentableBits) {
413  LLVM_DEBUG(dbgs() << "F2I: Value not guaranteed to be representable!\n");
414  continue;
415  }
416  if (MinBW > 64) {
417  LLVM_DEBUG(
418  dbgs() << "F2I: Value requires more than 64 bits to represent!\n");
419  continue;
420  }
421 
422  // OK, R is known to be representable. Now pick a type for it.
423  // FIXME: Pick the smallest legal type that will fit.
424  Type *Ty = (MinBW > 32) ? Type::getInt64Ty(*Ctx) : Type::getInt32Ty(*Ctx);
425 
426  for (auto MI = ECs.member_begin(It), ME = ECs.member_end();
427  MI != ME; ++MI)
428  convert(*MI, Ty);
429  MadeChange = true;
430  }
431 
432  return MadeChange;
433 }
434 
435 Value *Float2IntPass::convert(Instruction *I, Type *ToTy) {
436  if (ConvertedInsts.find(I) != ConvertedInsts.end())
437  // Already converted this instruction.
438  return ConvertedInsts[I];
439 
440  SmallVector<Value*,4> NewOperands;
441  for (Value *V : I->operands()) {
442  // Don't recurse if we're an instruction that terminates the path.
443  if (I->getOpcode() == Instruction::UIToFP ||
444  I->getOpcode() == Instruction::SIToFP) {
445  NewOperands.push_back(V);
446  } else if (Instruction *VI = dyn_cast<Instruction>(V)) {
447  NewOperands.push_back(convert(VI, ToTy));
448  } else if (ConstantFP *CF = dyn_cast<ConstantFP>(V)) {
449  APSInt Val(ToTy->getPrimitiveSizeInBits(), /*isUnsigned=*/false);
450  bool Exact;
451  CF->getValueAPF().convertToInteger(Val,
453  &Exact);
454  NewOperands.push_back(ConstantInt::get(ToTy, Val));
455  } else {
456  llvm_unreachable("Unhandled operand type?");
457  }
458  }
459 
460  // Now create a new instruction.
461  IRBuilder<> IRB(I);
462  Value *NewV = nullptr;
463  switch (I->getOpcode()) {
464  default: llvm_unreachable("Unhandled instruction!");
465 
466  case Instruction::FPToUI:
467  NewV = IRB.CreateZExtOrTrunc(NewOperands[0], I->getType());
468  break;
469 
470  case Instruction::FPToSI:
471  NewV = IRB.CreateSExtOrTrunc(NewOperands[0], I->getType());
472  break;
473 
474  case Instruction::FCmp: {
475  CmpInst::Predicate P = mapFCmpPred(cast<CmpInst>(I)->getPredicate());
476  assert(P != CmpInst::BAD_ICMP_PREDICATE && "Unhandled predicate!");
477  NewV = IRB.CreateICmp(P, NewOperands[0], NewOperands[1], I->getName());
478  break;
479  }
480 
481  case Instruction::UIToFP:
482  NewV = IRB.CreateZExtOrTrunc(NewOperands[0], ToTy);
483  break;
484 
485  case Instruction::SIToFP:
486  NewV = IRB.CreateSExtOrTrunc(NewOperands[0], ToTy);
487  break;
488 
489  case Instruction::FNeg:
490  NewV = IRB.CreateNeg(NewOperands[0], I->getName());
491  break;
492 
493  case Instruction::FAdd:
494  case Instruction::FSub:
495  case Instruction::FMul:
496  NewV = IRB.CreateBinOp(mapBinOpcode(I->getOpcode()),
497  NewOperands[0], NewOperands[1],
498  I->getName());
499  break;
500  }
501 
502  // If we're a root instruction, RAUW.
503  if (Roots.count(I))
504  I->replaceAllUsesWith(NewV);
505 
506  ConvertedInsts[I] = NewV;
507  return NewV;
508 }
509 
510 // Perform dead code elimination on the instructions we just modified.
511 void Float2IntPass::cleanup() {
512  for (auto &I : reverse(ConvertedInsts))
513  I.first->eraseFromParent();
514 }
515 
517  LLVM_DEBUG(dbgs() << "F2I: Looking at function " << F.getName() << "\n");
518  // Clear out all state.
520  SeenInsts.clear();
521  ConvertedInsts.clear();
522  Roots.clear();
523 
524  Ctx = &F.getParent()->getContext();
525 
526  findRoots(F, DT, Roots);
527 
528  walkBackwards(Roots);
529  walkForwards();
530 
531  bool Modified = validateAndTransform();
532  if (Modified)
533  cleanup();
534  return Modified;
535 }
536 
537 namespace llvm {
538 FunctionPass *createFloat2IntPass() { return new Float2IntLegacyPass(); }
539 
542  if (!runImpl(F, DT))
543  return PreservedAnalyses::all();
544 
546  PA.preserveSet<CFGAnalyses>();
547  PA.preserve<GlobalsAA>();
548  return PA;
549 }
550 } // End namespace llvm
Legacy wrapper pass to provide the GlobalsAAResult object.
opStatus roundToIntegral(roundingMode RM)
Definition: APFloat.h:1023
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:2212
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:1158
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
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:776
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:538
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
Analysis pass which computes a DominatorTree.
Definition: Dominators.h:230
F(f)
static void cleanup(BlockFrequencyInfoImplBase &BFI)
Clear all memory not needed downstream.
static IntegerType * getInt64Ty(LLVMContext &C)
Definition: Type.cpp:176
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
Definition: Dominators.cpp:299
1 0 0 1 True if unordered or equal
Definition: InstrTypes.h:743
uint32_t getBitWidth() const
Get the bit width of this ConstantRange.
AnalysisUsage & addRequired()
#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:261
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: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
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:144
Value * getOperand(unsigned i) const
Definition: User.h:169
static CmpInst::Predicate mapFCmpPred(CmpInst::Predicate P)
Definition: Float2Int.cpp:83
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:1162
LLVM Basic Block Representation.
Definition: BasicBlock.h:57
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:1167
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:540
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:653
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:419
Represents analyses that only rely on functions&#39; control flow.
Definition: PassManager.h:114
static Instruction::BinaryOps mapBinOpcode(unsigned Opcode)
Definition: Float2Int.cpp:110
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:1560
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:73
bool runImpl(Function &F, const DominatorTree &DT)
Definition: Float2Int.cpp:516
1 0 1 1 True if unordered, greater than, or equal
Definition: InstrTypes.h:745
IRTranslator LLVM IR MI
A container for analyses that lazily runs them and caches their results.
Legacy analysis pass which computes a DominatorTree.
Definition: Dominators.h:259
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:1117
const fltSemantics & getFltSemantics() const
Definition: Type.h:168