[Mesa-dev] [PATCH v2] i965/fs: in MAD optimizations, switch last argument to be immediate
Kenneth Graunke
kenneth at whitecape.org
Mon Mar 16 01:19:02 PDT 2015
On Monday, March 16, 2015 10:08:08 AM Tapani Pälli wrote:
> Commit bb33a31 introduced optimizations that transform cases of MAD
> in to simpler forms but it did not take in to account that src[0]
> can not be immediate and did not report progress. Patch switches
> src[0] and src[1] if src[0] is immediate and adds progress
> reporting. If both sources are immediates, this is taken care of by
> the same opt_algebraic pass on later run.
>
> v2: Fix for all cases, use temporary fs_reg (Matt, Kenneth)
>
> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89569
> Reviewed-by: Francisco Jerez <currojerez at riseup.net> (v1)
> ---
> src/mesa/drivers/dri/i965/brw_fs.cpp | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index 8702ea8..53ceb29 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -2491,6 +2491,7 @@ fs_visitor::opt_algebraic()
> inst->opcode = BRW_OPCODE_MUL;
> inst->src[0] = inst->src[2];
> inst->src[2] = reg_undef;
> + progress = true;
Ouch, good catch :(
> } else if (inst->src[1].is_one()) {
> inst->opcode = BRW_OPCODE_ADD;
> inst->src[1] = inst->src[2];
> @@ -2521,8 +2522,16 @@ fs_visitor::opt_algebraic()
> default:
> break;
> }
> - }
>
> + /* Swap if src[0] is immediate. */
> + if (progress && inst->is_commutative()) {
> + if (inst->src[0].file == IMM) {
> + fs_reg tmp = inst->src[1];
> + inst->src[1] = inst->src[0];
> + inst->src[0] = tmp;
> + }
> + }
> + }
> return progress;
> }
>
>
Looks good to me! Thanks!
Cc: "10.5" <mesa-stable at lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150316/e4621acf/attachment-0001.sig>
More information about the mesa-dev
mailing list