Lines Matching full:basis

43 // When such rewriting is possible, we call S1 a "basis" of S2. When S2 has
45 // basis, the basis that is the closest ancestor in the dominator tree.
158 // candidate with respect to its immediate basis. Note that one instruction
173 // Points to the immediate basis of this candidate, or nullptr if we cannot
174 // find any basis for this candidate.
175 Candidate *Basis = nullptr;
181 // Returns true if Basis is a basis for C, i.e., Basis dominates C and they
183 bool isBasisFor(const Candidate &Basis, const Candidate &C);
194 // to Candidates, and tries to find the immediate basis for each of them.
222 // basis.
227 // Rewrites candidate C with respect to Basis.
228 void rewriteCandidateWithBasis(const Candidate &C, const Candidate &Basis);
236 // Emit code that computes the "bump" from Basis to C.
237 static Value *emitBump(const Candidate &Basis, const Candidate &C,
268 bool StraightLineStrengthReduce::isBasisFor(const Candidate &Basis,
270 return (Basis.Ins != C.Ins && // skip the same instruction
271 // They must have the same type too. Basis.Base == C.Base doesn't
273 Basis.Ins->getType() == C.Ins->getType() &&
274 // Basis must dominate C in order to rewrite C with respect to Basis.
275 DT->dominates(Basis.Ins->getParent(), C.Ins->getParent()) &&
277 Basis.Base == C.Base && Basis.Stride == C.Stride &&
278 Basis.CandidateKind == C.CandidateKind);
340 // a candidate. Therefore, finding the immediate basis of a candidate boils down
357 // the basis of other candidates, but we leave I's basis blank so that I
360 // Try to compute the immediate basis of C.
364 for (auto Basis = Candidates.rbegin();
365 Basis != Candidates.rend() && NumIterations < MaxNumIterations;
366 ++Basis, ++NumIterations) {
367 if (isBasisFor(*Basis, C)) {
368 C.Basis = &(*Basis);
373 // Regardless of whether we find a basis for C, we need to push C to the
374 // candidate list so that it can be the basis of other candidates.
575 Value *StraightLineStrengthReduce::emitBump(const Candidate &Basis,
579 APInt Idx = C.Index->getValue(), BasisIdx = Basis.Index->getValue();
583 // Compute Bump = C - Basis = (i' - i) * S.
594 IntegerType::get(Basis.Ins->getContext(), IndexOffset.getBitWidth());
612 const Candidate &C, const Candidate &Basis) {
613 assert(C.CandidateKind == Basis.CandidateKind && C.Base == Basis.Base &&
614 C.Stride == Basis.Stride);
616 // basis of a candidate cannot be unlinked before the candidate.
617 assert(Basis.Ins->getParent() != nullptr && "the basis is unlinked");
627 Value *Bump = emitBump(Basis, C, Builder, DL);
632 // C = Basis + Bump
635 // If Bump is a neg instruction, emit C = Basis - (-Bump).
636 Reduced = Builder.CreateSub(Basis.Ins, NegBump);
650 Reduced = Builder.CreateAdd(Basis.Ins, Bump);
656 // C = (char *)Basis + Bump
657 Reduced = Builder.CreatePtrAdd(Basis.Ins, Bump, "", InBounds);
689 // a candidate being rewritten is not a basis for any other candidate.
692 if (C.Basis != nullptr) {
693 rewriteCandidateWithBasis(C, *C.Basis);