Home | History | Annotate | Download | only in Scalar

Lines Matching refs:Value

10 // This pass performs global value numbering to eliminate fully redundant
13 // Note that this pass does the value numbering itself; it does not use the
81 /// This class holds the mapping between values and value numbers. It is used
104 friend hash_code hash_value(const Expression &Value) {
105 return hash_combine(Value.opcode, Value.type,
106 hash_combine_range(Value.varargs.begin(),
107 Value.varargs.end()));
112 DenseMap<Value*, uint32_t> valueNumbering;
123 Value *LHS, Value *RHS);
128 uint32_t lookup_or_add(Value *V);
129 uint32_t lookup(Value *V) const;
131 Value *LHS, Value *RHS);
132 bool exists(Value *V) const;
133 void add(Value *V, uint32_t num);
135 void erase(Value *v);
141 void verifyRemoved(const Value *) const;
179 // of their operands get the same value number by sorting the operand value
188 // Sort the operand value numbers so x<y and y>x get the same value number.
206 Value *LHS, Value *RHS) {
214 // Sort the operand value numbers so x<y and y>x get the same value number.
233 // an extract value expression.
261 // Not a recognised intrinsic. Fall back to producing an extract value
279 /// add - Insert a value into the table with a specified value number.
280 void ValueTable::add(Value *V, uint32_t num) {
393 /// Returns true if a value number exists for the specified value.
394 bool ValueTable::exists(Value *V) const { return valueNumbering.count(V) != 0; }
396 /// lookup_or_add - Returns the value number for the specified value, assigning
398 uint32_t ValueTable::lookup_or_add(Value *V) {
399 DenseMap<Value*, uint32_t>::iterator VI = valueNumbering.find(V);
467 /// Returns the value number of the specified value. Fails if
468 /// the value has not yet been numbered.
469 uint32_t ValueTable::lookup(Value *V) const {
470 DenseMap<Value*, uint32_t>::const_iterator VI = valueNumbering.find(V);
471 assert(VI != valueNumbering.end() && "Value not numbered?");
475 /// Returns the value number of the given comparison,
481 Value *LHS, Value *RHS) {
495 /// Remove a value from the value numbering.
496 void ValueTable::erase(Value *V) {
500 /// verifyRemoved - Verify that the value is removed from all internal data
502 void ValueTable::verifyRemoved(const Value *V) const {
503 for (DenseMap<Value*, uint32_t>::const_iterator
505 assert(I->first != V && "Inst still occurs in value numbering map!");
519 SimpleVal, // A simple offsetted value that is accessed.
520 LoadVal, // A value produced by a load.
522 UndefVal // A UndefValue representing a value from dead block (which
526 /// V - The value that is live out of the block.
527 PointerIntPair<Value *, 2, ValType> Val;
532 static AvailableValueInBlock get(BasicBlock *BB, Value *V,
576 Value *getSimpleValue() const {
591 /// Emit code into this block to adjust the value defined here to the
593 Value *MaterializeAdjustedValue(LoadInst *LI, GVN &gvn) const;
606 /// A mapping from value numbers to lists of Value*'s that
607 /// have that value number. Use findLeader to query it.
609 Value *Val;
619 SmallMapVector<llvm::Value *, llvm::Constant *, 4> ReplaceWithConstMap;
646 /// Push a new Value to the LeaderTable onto the list for its value number.
647 void addToLeaderTable(uint32_t N, Value *V, const BasicBlock *BB) {
663 /// value number, and remove the given instruction if encountered.
721 void dump(DenseMap<uint32_t, Value*> &d);
727 Value *findLeader(const BasicBlock *BB, uint32_t num);
733 bool propagateEquality(Value *LHS, Value *RHS, const BasicBlockEdge &Root,
748 INITIALIZE_PASS_BEGIN(GVN, "gvn", "Global Value Numbering", false, false)
755 INITIALIZE_PASS_END(GVN, "gvn", "Global Value Numbering", false, false)
758 void GVN::dump(DenseMap<uint32_t, Value*>& d) {
760 for (DenseMap<uint32_t, Value*>::iterator I = d.begin(),
769 /// Return true if we can prove that the value
790 // If the entry already existed for this block, return the precomputed value.
792 // If this is a speculative "available" value, mark it as being used for
807 // If the value isn't fully available in one of our predecessors, then it
827 // If we did speculate on this value, we could have blocks set to 1 that are
851 static bool CanCoerceMustAliasedValueToLoad(Value *StoredVal,
854 // If the loaded or stored value is an first class array or struct, don't try
869 /// If we saw a store of a value to memory, and
871 /// the stored value. LoadedTy is the type of the load we want to replace.
875 static Value *CoerceAvailableValueToLoadType(Value *StoredVal, Type *LoadedTy,
914 // If the loaded value is smaller than the available value, then we can
915 // extract out a piece from it. If the available value is too small, then we
931 // If this is a big-endian system, we need to shift the value down to the low
959 /// value of the piece that feeds the load.
960 static int AnalyzeLoadFromClobberingWrite(Type *LoadTy, Value *LoadPtr,
961 Value *WritePtr,
964 // If the loaded or stored value is a first class array or struct, don't try
970 Value *StoreBase =
972 Value *LoadBase = GetPointerBaseWithConstantOffset(LoadPtr, LoadOffset, DL);
1035 static int AnalyzeLoadFromClobberingStore(Type *LoadTy, Value *LoadPtr,
1043 Value *StorePtr = DepSI->getPointerOperand();
1052 static int AnalyzeLoadFromClobberingLoad(Type *LoadTy, Value *LoadPtr,
1058 Value *DepPtr = DepLI->getPointerOperand();
1066 const Value *LoadBase =
1079 static int AnalyzeLoadFromClobberingMemInst(Type *LoadTy, Value *LoadPtr,
1131 static Value *GetStoreValueForLoad(Value *SrcVal, unsigned Offset,
1141 // Compute which bits of the stored value are being used by the load. Convert
1170 static Value *GetLoadValueForLoad(LoadInst *SrcVal, unsigned Offset,
1187 Value *PtrVal = SrcVal->getPointerOperand();
1191 // load completely because it is already in the value numbering table.
1208 Value *RV = NewLoad;
1230 static Value *GetMemInstValueForLoad(MemIntrinsic *SrcInst, unsigned Offset,
1243 Value *Val = MSI->getValue();
1247 Value *OneElt = Val;
1249 // Splat the value out to the right number of bits.
1253 Value *ShVal = Builder.CreateShl(Val, NumBytesSet*8);
1260 Value *ShVal = Builder.CreateShl(Val, 1*8);
1287 /// construct SSA form, allowing us to eliminate LI. This returns the value
1289 static Value *ConstructSSAForLoadSet(LoadInst *LI,
1293 // just use the dominating value directly.
1319 Value *AvailableValueInBlock::MaterializeAdjustedValue(LoadInst *LI,
1321 Value *Res;
1370 // where we have a value available in repl, also keep track of whether we see
1371 // dependencies that produce an unknown value for the load (such as a call
1380 // Dead dependent mem-op disguise as a load evaluating the same value
1395 Value *Address = Deps[i].getAddress();
1399 // stored value.
1432 // If the clobbering value is a memset/memcpy/memmove, see if we can
1433 // forward a value on from it.
1474 // If the stored value is larger or equal to the loaded value, we can
1491 // If the stored value is larger or equal to the loaded value, we can
1508 // Okay, we have *some* definitions of the value. This means that the value
1543 // Check to see how many predecessors have the loaded value fully
1545 MapVector<BasicBlock *, Value *> PredLoads;
1591 "Fully available value should already be eliminated!");
1616 // Do PHI translation to get its value in the predecessor if necessary. The
1623 Value *LoadPtr = nullptr;
1627 // If we couldn't find or insert a computation of this phi translated value,
1630 DEBUG(dbgs() << "COULDN'T INSERT PHI TRANSLATED VALUE OF: "
1651 // and using PHI construction to get the value in the other predecessors, do
1658 // Assign value numbers to the new instructions.
1660 // FIXME: We really _ought_ to insert these value numbers into their
1663 // marking a value as AVAIL-IN, which isn't what we intend.
1669 Value *LoadPtr = PredLoad.second;
1697 Value *V = ConstructSSAForLoadSet(LI, ValuesPerBlock, *this);
1754 // If we have no predecessors that produce a known value for this load, exit
1761 // If all of the instructions we depend on produce a known value for this
1763 // its value. Insert PHIs and remove the fully redundant value now.
1768 Value *V = ConstructSSAForLoadSet(LI, ValuesPerBlock, *this);
1793 Value *V = IntrinsicI->getArgOperand(0);
1820 // We can replace assume value with true, which covers cases like this:
1834 Value *CmpLHS = CmpI->getOperand(0);
1835 Value *CmpRHS = CmpI->getOperand(1);
1848 static void patchReplacementInstruction(Instruction *I, Value *Repl) {
1849 // Patch the replacement so that it is not more restrictive than the value
1857 // FIXME: If both the original and replacement value are part of the
1875 static void patchAndReplaceAllUsesWith(Instruction *I, Value *Repl) {
1911 Value *AvailVal = nullptr;
1936 // If the clobbering value is a memset/memcpy/memmove, see if we can forward
1937 // a value on from it.
1958 // If the value isn't available, don't do anything!
1985 Value *StoredVal = DepSI->getValueOperand();
1989 // value (depending on its type).
2011 Value *AvailableVal = DepLI;
2014 // the same type. See if we know how to reuse the previously loaded value
2037 // undef value. This can happen when loading for a fresh allocation with no
2047 // then the loaded value is undefined.
2058 // then the loaded value is zero
2069 // In order to find a leader for a given value number at a
2074 Value *GVN::findLeader(const BasicBlock *BB, uint32_t num) {
2078 Value *Val = nullptr;
2119 Value *Operand = Instr->getOperand(OpNum);
2137 bool GVN::propagateEquality(Value *LHS, Value *RHS, const BasicBlockEdge &Root,
2139 SmallVector<std::pair<Value*, Value*>, 4> Worklist;
2147 std::pair<Value*, Value*> Item = Worklist.pop_back_val();
2161 assert((isa<Argument>(LHS) || isa<Instruction>(LHS)) && "Unexpected value!");
2170 // Move the 'oldest' value to the right-hand side, using the value number
2179 // If value numbering later sees that an instruction in the scope is equal
2182 // own value number (this is used by removeFromLeaderTable), do not do this
2221 Value *A, *B;
2233 Value *Op0 = Cmp->getOperand(0), *Op1 = Cmp->getOperand(1);
2247 // its value is non-zero.
2261 // out the value number that it would have and use that to find an
2268 Value *NotCmp = findLeader(Root.getEnd(), Num);
2279 // Ensure that any instruction in scope that gets the "A < B" value number
2301 // to value numbering it. Value numbering often exposes redundancies, for
2305 if (Value *V = SimplifyInstruction(I, DL, TLI, DT, AC)) {
2328 // the condition value itself.
2336 Value *BranchCond = BI->getCondition();
2346 Value *TrueVal = ConstantInt::getTrue(TrueSucc->getContext());
2350 Value *FalseVal = ConstantInt::getFalse(FalseSucc->getContext());
2359 Value *SwitchCond = SI->getCondition();
2371 // If there is only a single edge, propagate the case value into it.
2380 // Instructions with void type don't return a value, so there's
2403 // Perform fast-path value-number based elimination of values inherited from
2405 Value *Repl = findLeader(I->getParent(), Num);
2537 // Because we are going top-down through the block, all value numbers
2543 Value *Op = Instr->getOperand(i);
2547 // find a value number, and should give up before we hurt ourselves.
2548 // FIXME: Rewrite the infrastructure to let it easier to value number
2554 if (Value *V = findLeader(Pred, VN.lookup(Op))) {
2564 // are not value numbered precisely.
2579 SmallVector<std::pair<Value*, BasicBlock*>, 8> predMap;
2594 // We don't currently value number ANY inline asm calls.
2603 // a value is computed in the successor and one predecessor,
2625 Value *predV = findLeader(P, ValNo);
2627 predMap.push_back(std::make_pair(static_cast<Value *>(nullptr), P));
2679 // Create a PHI to make the value available in this block.
2684 if (Value *V = predMap[i].first)
2771 // Needed for value numbering with phi construction to work.
2796 // Walk through the value number scope to make sure the instruction isn't
2801 assert(Node->Val != Inst && "Inst still in value numbering scope!");
2805 assert(Node->Val != Inst && "Inst still in value numbering scope!");