[llvm-commits] [llvm] r89356 - /llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp

David Greene dag at cray.com
Thu Nov 19 13:10:53 PST 2009


On Thursday 19 November 2009 13:36, Evan Cheng wrote:
> On Nov 19, 2009, at 7:55 AM, David Greene wrote:
> > +    // The queue of recently-used registers.
> > +    SmallVector<unsigned, 3> RecentRegs;
>
> Why the odd sized vector?

Why not?  We have the queue sized to three in our code.  I can
change it if you'd like.  It's an arbitrary choice.

> > +
> > +    // Record that we just picked this register.
> > +    void recordRecentlyUsed(unsigned reg) {
> > +      assert(reg != 0 && "Recently used register is NOREG!");
> > +      if (!RecentRegs.empty()) {
> > +        std::copy(RecentRegs.begin() + 1, RecentRegs.end(),
> > RecentRegs.begin()); +        RecentRegs.back() = reg;
>
> This seems extremely slow? Why not pop front and push back? Or just use a
> fixed size array and keep rotating the begin and end pointers?

pop_front on a vector is no faster than the copy and might actually be slower.
Perhaps this should be a list<> or deque<>.  What do you think?

                                    -Dave



More information about the llvm-commits mailing list