[Mesa-dev] [PATCH v3 2/6] anv: Add a helper for doing mass allocations
Jason Ekstrand
jason at jlekstrand.net
Fri Apr 7 23:30:49 UTC 2017
On Fri, Apr 7, 2017 at 3:19 PM, Chris Wilson <chris at chris-wilson.co.uk>
wrote:
> On Fri, Apr 07, 2017 at 02:41:13PM -0700, Jason Ekstrand wrote:
> > On Fri, Apr 7, 2017 at 1:26 PM, Chris Wilson <[1]
> chris at chris-wilson.co.uk>
> > wrote:
> >
> > On Fri, Apr 07, 2017 at 12:55:53PM -0700, Jason Ekstrand wrote:
> > > +#define _ANV_MULTIALLOC_UPDATE_POINTER(_i) \
> > > + if ((_i) < ma->ptr_count) \
> > > + *ma->ptrs[_i] = ptr + (uintptr_t)*ma->ptrs[_i]
> > > + _ANV_MULTIALLOC_UPDATE_POINTER(0);
> > > + _ANV_MULTIALLOC_UPDATE_POINTER(1);
> > > + _ANV_MULTIALLOC_UPDATE_POINTER(2);
> > > + _ANV_MULTIALLOC_UPDATE_POINTER(3);
> > > + _ANV_MULTIALLOC_UPDATE_POINTER(4);
> > > + _ANV_MULTIALLOC_UPDATE_POINTER(5);
> > > + _ANV_MULTIALLOC_UPDATE_POINTER(6);
> > > + _ANV_MULTIALLOC_UPDATE_POINTER(7);
> > > +#undef _ANV_MULTIALLOC_UPDATE_POINTER
> >
> > #define _ANV_MULTIALLOC_UPDATE_POINTER(_i) case _i + 1:
> *ma->ptrs[_i] =
> > ptr +(uintptr)*ma->ptrs[_i]
> >
> > switch (ma->ptr_count) {
> > _ANV_MULTIALLOC_UPDATE_POINTER(7);
> > _ANV_MULTIALLOC_UPDATE_POINTER(6);
> > _ANV_MULTIALLOC_UPDATE_POINTER(5);
> > _ANV_MULTIALLOC_UPDATE_POINTER(4);
> > _ANV_MULTIALLOC_UPDATE_POINTER(3);
> > _ANV_MULTIALLOC_UPDATE_POINTER(2);
> > _ANV_MULTIALLOC_UPDATE_POINTER(1);
> > _ANV_MULTIALLOC_UPDATE_POINTER(0);
> > }
> >
> > #undef _ANV_MULITALLOC_UPDATE_POINTER
> >
> > If ma->ptr_count is constant, they generate exactly the same code.
> If it
> > isn't (i.e. if one of the multialloc_adds is predicated), then they
> still
> > generate basically the same code with the code for the if version
> being
> > slightly more straightforward.
>
> Took a look at this with https://godbolt.org/g/UwrMk1
>
Weird... That's not at all what I'm seeing with my demo file. In fact,
when I try to compile your demo file with GCC on my local machine, it
reduces the entire thing down to less than a dozen instrutions.
> clang does much better at seeing the constants, but gcc doesn't and
> generates a large if-ladder for one and a jump table for the switch. icc
> doesn't fare any better than gcc. The if-ladder is going to be worse
> than the computed jump, but best is to file a gcc bug :|
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170407/9c4f720b/attachment.html>
More information about the mesa-dev
mailing list