[Mesa-dev] [PATCH] i965/fs_nir: Put the immediate in src1 for commutative ALU ops
Matt Turner
mattst88 at gmail.com
Fri May 8 10:13:22 PDT 2015
On Fri, May 8, 2015 at 10:04 AM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> Shader-db results for fragment shaders on Broadwell:
>
> total instructions in shared programs: 4310987 -> 4310663 (-0.01%)
> instructions in affected programs: 43242 -> 42918 (-0.75%)
> helped: 142
> HURT: 0
>
> Shader-db results for vertex shaders on Broadwell:
>
> total instructions in shared programs: 2889581 -> 2844309 (-1.57%)
> instructions in affected programs: 1418720 -> 1373448 (-3.19%)
> helped: 6139
> HURT: 0
> ---
> src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> index 555987d..161a262 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> @@ -21,6 +21,8 @@
> * IN THE SOFTWARE.
> */
>
> +#include <algorithm>
> +
> #include "glsl/ir.h"
> #include "glsl/ir_optimization.h"
> #include "glsl/nir/glsl_to_nir.h"
> @@ -662,6 +664,16 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr)
> op[i] = offset(op[i], instr->src[i].swizzle[channel]);
> }
>
> + /* Immediates can only be used as the second source of two-source
> + * instructions. We have code in opt_algebraic to flip them as needed
> + * for most instructions. However, it doesn't hurt anything to just do
> + * the right thing if we can detect it at the NIR level.
> + */
> + if ((nir_op_infos[instr->op].algebraic_properties & NIR_OP_IS_COMMUTATIVE) &&
> + nir_src_as_const_value(instr->src[0].src)) {
> + std::swap(op[0], op[1]);
We don't use STL.
More information about the mesa-dev
mailing list