Lines Matching full:constant

14 // cost. If the constant can be folded into the instruction (the cost is
19 // If the cost is more than TCC_BASIC, then the integer constant can't be folded
20 // into the instruction and it might be beneficial to hoist the constant.
24 // When a constant is hoisted, it is also hidden behind a bitcast to force it to
25 // be live-out of the basic block. Otherwise the constant would be just
28 // certain transformations on them, which would create a new expensive constant.
31 // simple (this means not nested) constant cast expressions. For example:
89 cl::desc("Try hoisting constant gep expressions"));
99 /// The constant hoisting pass.
110 StringRef getPassName() const override { return "Constant Hoisting"; } in getPassName()
130 "Constant Hoisting", false, false)
136 "Constant Hoisting", false, false) in INITIALIZE_PASS_DEPENDENCY()
142 /// Perform the constant hoisting optimization for the given function.
147 LLVM_DEBUG(dbgs() << "********** Begin Constant Hoisting **********\n"); in runOnFunction()
159 LLVM_DEBUG(dbgs() << "********** End Constant Hoisting **********\n"); in runOnFunction()
172 /// Find the constant materialization insertion point.
176 // constant before the cast instruction. in findMatInsertPt()
184 // The simple and common case. This also includes constant expressions. in findMatInsertPt()
322 assert(!ConstInfo.RebasedConstants.empty() && "Invalid constant info entry."); in findConstantInsertionPoint()
359 /// Record constant integer ConstInt for instruction Inst at operand
362 /// The operand at index Idx is not necessarily the constant integer itself. It
363 /// could also be a cast instruction or a constant expression that uses the
364 /// constant integer.
372 // Ask the target about the cost of materializing the constant for the given in collectConstantCandidates()
395 << "Collect constant " << *ConstInt << " from " << *Inst in collectConstantCandidates()
397 else dbgs() << "Collect constant " << *ConstInt in collectConstantCandidates()
404 /// Record constant GEP expression for instruction Inst at operand index Idx.
425 // constant expression, in collectConstantCandidates()
435 // A constant GEP expression that has a GlobalVariable as base pointer is in collectConstantCandidates()
436 // usually lowered to a load from constant pool. Such operation is unlikely in collectConstantCandidates()
461 // Visit constant integers. in collectConstantCandidates()
467 // Visit cast instructions that have constant integers. in collectConstantCandidates()
475 // Pretend the constant is directly used by the instruction and ignore in collectConstantCandidates()
482 // Visit constant expressions that have constant integers. in collectConstantCandidates()
484 // Handle constant gep expressions. in collectConstantCandidates()
488 // Only visit constant cast expressions. in collectConstantCandidates()
493 // Pretend the constant is directly used by the instruction and ignore in collectConstantCandidates()
494 // the constant expression. in collectConstantCandidates()
502 /// in the constant candidate vector.
513 // take constant variables is lower than `TargetTransformInfo::TCC_Basic`. in collectConstantCandidates()
514 // So it's safe for us to collect constant candidates from all in collectConstantCandidates()
556 // constants will be transformed into an offset from that base constant. The
563 // Selecting constant 12 because it has the most uses will generate negative
567 // supported by the architecture, then selecting constant 2 is most optimal
571 // selecting the base constant the range of the offsets is a very important
573 // costs for selecting a constant as the base and substract the costs if
600 LLVM_DEBUG(dbgs() << "= Constant: " << ConstCand->ConstInt->getValue() in maximizeConstantsInRange()
634 /// Find the base constant within the given range and rebase all other
635 /// constants with respect to the base constant.
653 // Rebase the constants with respect to the base constant. in findAndMakeBaseConstant()
656 Constant *Offset = Diff == 0 ? nullptr : ConstantInt::get(Ty, Diff); in findAndMakeBaseConstant()
665 /// Finds and combines constant candidates that can be easily
666 /// rematerialized with an add from a common base constant.
668 // If BaseGV is nullptr, find base among candidate constant integers; in findBaseConstants()
669 // Otherwise find base among constant GEPs that share the same BaseGV. in findBaseConstants()
683 // Simple linear scan through the sorted constant candidate vector for viable in findBaseConstants()
696 // Make sure the constant is used as pointer operand of the StoreInst. in findBaseConstants()
704 // Check if the constant is in range of an add with immediate. in findBaseConstants()
715 // We either have now a different constant type or the constant is not in in findBaseConstants()
718 // Start a new base constant search. in findBaseConstants()
721 // Finalize the last base constant search. in findBaseConstants()
765 // Constant being rebased is a ConstantExpr. in emitBaseConstants()
772 // Constant being rebased is a ConstantInt. in emitBaseConstants()
777 LLVM_DEBUG(dbgs() << "Materialize constant (" << *Base->getOperand(0) in emitBaseConstants()
785 // Visit constant integer. in emitBaseConstants()
816 // Visit constant expression. in emitBaseConstants()
824 // Aside from constant GEPs, only constant cast expressions are collected. in emitBaseConstants()
846 /// Hoist and hide the base constant behind a bitcast and emit
874 // If Base constant is to be inserted in multiple places, in emitBaseConstants()
891 // Hoist and hide the base constant behind a bitcast. in emitBaseConstants()
893 assert(BaseGV && "A base constant expression must have an base GV"); in emitBaseConstants()
903 LLVM_DEBUG(dbgs() << "Hoist constant (" << *ConstInfo.BaseInt in emitBaseConstants()
911 // Use the same debug location as the last user of the constant. in emitBaseConstants()
928 // Base constant is also included in ConstInfo.RebasedConstants, so in emitBaseConstants()
960 // Collect all constant candidates. in runImpl()
964 // base constant. in runImpl()
971 // Finally hoist the base constant and emit materialization code for dependent in runImpl()