nir/builder: Don't emit no-op swizzles
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 22 Feb 2019 23:06:39 +0000 (17:06 -0600)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 25 Feb 2019 02:01:27 +0000 (20:01 -0600)
commit743700be1f583db28ff84104754f38bc6852668e
treedf83af961cb9e322eaf86dccb759297f46f47121
parent724371c6b990d3a66ecebbe4bd1802c53e89ed46
nir/builder: Don't emit no-op swizzles

The nir_swizzle helper is used some on it's own but it's also called by
nir_channel and nir_channels which are used everywhere.  It's pretty
quick to check while we're walking the swizzle anyway whether or not
it's an identity swizzle.  If it is, we now don't bother emitting the
instruction.  Sure, copy-prop will clean it up for us but there's no
sense making more work for the optimizer than we have to.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/compiler/nir/nir_builder.h