[Mesa-dev] [RFC PATCH] nir: Transform 4*x into x << 2 during late optimizations.

Ilia Mirkin imirkin at alum.mit.edu
Fri May 8 11:21:51 PDT 2015


On Fri, May 8, 2015 at 6:36 AM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> +   # Multiplication by 4 comes up fairly often in indirect offset calculations.
> +   # Some GPUs have weird integer multiplication limitations, but shifts should work
> +   # equally well everywhere.
> +   (('imul', 4, a), ('ishl', a, 2)),

Not sure what the cost of doing it this way, but really you want all
powers of 2... and also udiv -> shr. Since this is python, should be
easy enough to append onto that list. AFAIK all GPU's prefer a shift
over a mul. Adreno doen't have 32-bit imul in the first place (and no
idiv either).

In nouveau/codegen we just have a single check for whether the
immediate is a power of 2, perhaps that can be encoded here in some
way.

Cheers,

  -ilia


More information about the mesa-dev mailing list