[llvm-commits] [llvm] r159746 - /llvm/trunk/lib/CodeGen/LiveInterval.cpp

Chandler Carruth chandlerc at gmail.com
Thu Jul 5 10:02:24 PDT 2012


While this is interesting, it isn't what I'm looking at. I don't have any
test cases that currently point a finger at extendInBlock (but that may
change, see below).

I'm working on a patch to fix the super-linear performance of
MergeValueInAsValue (and MergeRangeInAsValue). I've two or three ideas, and
should have a patch mailed out today.

I spotted the merge-able remove calls by inspection, and was inspecting it
because the remove is what makes the above super-linear so it showed up
blazing hot in the profile.

I never really expected this patch to make a big difference, it only seemed
worth it because the code actually became simpler in the process.


On Thu, Jul 5, 2012 at 9:49 AM, Jakob Stoklund Olesen <stoklund at 2pi.dk>wrote:

>
> On Jul 5, 2012, at 8:36 AM, Jakob Stoklund Olesen <stoklund at 2pi.dk> wrote:
>
>
> On Jul 5, 2012, at 5:40 AM, Chandler Carruth <chandlerc at gmail.com> wrote:
>
> Author: chandlerc
> Date: Thu Jul  5 07:40:45 2012
> New Revision: 159746
>
> URL: http://llvm.org/viewvc/llvm-project?rev=159746&view=rev
> Log:
> Optimize extendIntervalEndTo a tiny bit by saving one call through the
> vector erase. No functionality changed.
>
>
> This function is very hot when called from LiveInterval::extendInBlock(),
> and in that case it is known that the new live range doesn't overlap any
> existing live ranges.
>
> You may be able to squeeze out a bit more performance by inlining a
> simpler extendIntervalEndTo() into extendInBlock(). The for-loop and
> std::max conditional are not needed in that case.
>
>
> I wasn't able to measure a performance difference with this patch:
>
> diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp
> index 3d34c08..fc09c02 100644
> --- a/lib/CodeGen/LiveInterval.cpp
> +++ b/lib/CodeGen/LiveInterval.cpp
> @@ -305,8 +305,20 @@ VNInfo *LiveInterval::extendInBlock(SlotIndex
> StartIdx, SlotIndex Kill) {
>    --I;
>    if (I->end <= StartIdx)
>      return 0;
> -  if (I->end < Kill)
> -    extendIntervalEndTo(I, Kill);
> +  if (I->end >= Kill)
> +    return I->valno;
> +
> +  // I needs to be extended up to Kill.
> +  // Check if it would merge with the next segment.
> +  iterator Next = llvm::next(I);
> +  if (Next == end() || Next->start != Kill || Next->valno != I->valno) {
> +    I->end = Kill;
> +    return I->valno;
> +  }
> +
> +  // Merge Next into I.
> +  I->end = Next->end;
> +  ranges.erase(Next);
>    return I->valno;
>  }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120705/c048619d/attachment.html>


More information about the llvm-commits mailing list