[Mesa-dev] [PATCH v4 31/40] intel/compiler: remove inexact algebraic optimizations from the backend

Jason Ekstrand jason at jlekstrand.net
Sat Feb 16 15:30:26 UTC 2019


Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

On Tue, Feb 12, 2019 at 5:57 AM Iago Toral Quiroga <itoral at igalia.com>
wrote:

> NIR already has these and correctly considers exact/inexact qualification,
> whereas the backend doesn't and can apply the optimizations where it
> shouldn't. This happened to be the case in a handful of Tomb Raider
> shaders,
> where NIR would skip the optimizations because of a precise qualification
> but the backend would then (incorrectly) apply them anyway.
>
> Besides this, considering that we are not emitting much math in the backend
> these days it is unlikely that these optimizations are useful in general. A
> shader-db run confirms that MAD and LRP optimizations, for example, were
> only
> being triggered in cases where NIR would skip them due to precise
> requirements, so in the near future we might want to remove more of these,
> but for now we just remove the ones that are not completely correct.
>
> Suggested-by: Jason Ekstrand <jason at jlekstrand.net>
> ---
>  src/intel/compiler/brw_fs.cpp | 39 +----------------------------------
>  1 file changed, 1 insertion(+), 38 deletions(-)
>
> diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
> index 0f04e577de3..873a1dd8196 100644
> --- a/src/intel/compiler/brw_fs.cpp
> +++ b/src/intel/compiler/brw_fs.cpp
> @@ -2547,15 +2547,6 @@ fs_visitor::opt_algebraic()
>              break;
>           }
>
> -         /* a * 0.0 = 0.0 */
> -         if (inst->src[1].is_zero()) {
> -            inst->opcode = BRW_OPCODE_MOV;
> -            inst->src[0] = inst->src[1];
> -            inst->src[1] = reg_undef;
> -            progress = true;
> -            break;
> -         }
> -
>           if (inst->src[0].file == IMM) {
>              assert(inst->src[0].type == BRW_REGISTER_TYPE_F);
>              inst->opcode = BRW_OPCODE_MOV;
> @@ -2569,14 +2560,6 @@ fs_visitor::opt_algebraic()
>           if (inst->src[1].file != IMM)
>              continue;
>
> -         /* a + 0.0 = a */
> -         if (inst->src[1].is_zero()) {
> -            inst->opcode = BRW_OPCODE_MOV;
> -            inst->src[1] = reg_undef;
> -            progress = true;
> -            break;
> -         }
> -
>           if (inst->src[0].file == IMM) {
>              assert(inst->src[0].type == BRW_REGISTER_TYPE_F);
>              inst->opcode = BRW_OPCODE_MOV;
> @@ -2595,16 +2578,6 @@ fs_visitor::opt_algebraic()
>              break;
>           }
>           break;
> -      case BRW_OPCODE_LRP:
> -         if (inst->src[1].equals(inst->src[2])) {
> -            inst->opcode = BRW_OPCODE_MOV;
> -            inst->src[0] = inst->src[1];
> -            inst->src[1] = reg_undef;
> -            inst->src[2] = reg_undef;
> -            progress = true;
> -            break;
> -         }
> -         break;
>        case BRW_OPCODE_CMP:
>           if ((inst->conditional_mod == BRW_CONDITIONAL_Z ||
>                inst->conditional_mod == BRW_CONDITIONAL_NZ) &&
> @@ -2682,17 +2655,7 @@ fs_visitor::opt_algebraic()
>           }
>           break;
>        case BRW_OPCODE_MAD:
> -         if (inst->src[1].is_zero() || inst->src[2].is_zero()) {
> -            inst->opcode = BRW_OPCODE_MOV;
> -            inst->src[1] = reg_undef;
> -            inst->src[2] = reg_undef;
> -            progress = true;
> -         } else if (inst->src[0].is_zero()) {
> -            inst->opcode = BRW_OPCODE_MUL;
> -            inst->src[0] = inst->src[2];
> -            inst->src[2] = reg_undef;
> -            progress = true;
> -         } else if (inst->src[1].is_one()) {
> +         if (inst->src[1].is_one()) {
>              inst->opcode = BRW_OPCODE_ADD;
>              inst->src[1] = inst->src[2];
>              inst->src[2] = reg_undef;
> --
> 2.17.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20190216/5188abd7/attachment-0001.html>


More information about the mesa-dev mailing list