OSDN Git Service

gallivm: Use alloca_undef with array type instead of alloca_array
authorRoland Scheidegger <sroland@vmware.com>
Tue, 15 May 2018 02:35:50 +0000 (04:35 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Tue, 15 May 2018 22:04:48 +0000 (00:04 +0200)
commite01af38d6faf5dfd0f4ac6548ae03c27cca1dede
treeb877282f21480650a74a4dc6df4b95bd87dfdf40
parentbd0b6b9f17d401aa70eac279a3541d8e2a96ae0f
gallivm: Use alloca_undef with array type instead of alloca_array

Use a single allocation of array type instead of the old-style array
allocation for the temp and immediate arrays.
Probably only makes a difference if they aren't used indirectly (so,
if we used them solely because there's too many temps or immediates).
In this case the sroa and early-cse passes can sometimes do some
optimizations which they otherwise cannot.
(As a side note, for the temp reg array, we actually really should
use one allocation per array id, not just one for everything.)
Note that the instcombine pass would actually promote such
allocations to single alloc of array type as well, but it's too late
for some artificial shaders we've seen to help (we don't want to run
instcombine at the beginning due to its cost, hence would need
another sroa/cse pass after instcombine). sroa/early-cse help there
because they can actually eliminate all of the huge shader, reducing
it to a single const output (don't ask...).
(Interestingly, instcombine also removes all the bitcasts we do on that
allocation for single-value gathering, and in the end directly indexes
into the single vector elements, which according to spec is only
semi-valid, but this happens regardless. Another thing instcombine also
does is use inbound GEPs, which is probably something we should do
manually as well - for indirectly indexed reg files llvm may not be
able to figure it out on its own, but we should be able to guarantee
all pointers are always inbound. In any case, by the looks of it
using single allocation with array type seems to be the right thing
to do even for ordinary shaders.)
No piglit change.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c