[Mesa-dev] [PATCH 1/2] nir: optimize min(min(a, b), c) to min3(a, b, c) under an option

Eric Anholt eric at anholt.net
Fri Jun 1 17:17:39 UTC 2018


Samuel Pitoiset <samuel.pitoiset at gmail.com> writes:

> On 06/01/2018 02:17 AM, Ian Romanick wrote:
>> On 05/30/2018 10:06 AM, Samuel Pitoiset wrote:
>>> Similar for max().
>>>
>>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
>>> ---
>>>   src/compiler/nir/nir.h                | 3 +++
>>>   src/compiler/nir/nir_opt_algebraic.py | 8 ++++++++
>>>   2 files changed, 11 insertions(+)
>>>
>>> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
>>> index f6086bd6c0..04991b7d04 100644
>>> --- a/src/compiler/nir/nir.h
>>> +++ b/src/compiler/nir/nir.h
>>> @@ -1897,6 +1897,9 @@ typedef struct nir_shader_compiler_options {
>>>      /* lower b2f to iand */
>>>      bool lower_b2f;
>>>   
>>> +   /* lower min(min(a, b), c) to min3(a, b, c) (same for max()). */
>>> +   bool lower_minmax3;
>> 
>> The way this variable is named and the way it is used is confusing.
>> Every other lower_foo means "convert foo to something else."  This one
>> means "make some foo."
>
> Yes, the name is not that good. Any suggestions?

We use !options->lower_fsat to decide if we should turn min(max())
patterns into fsat, so we could go with that model again.  You'd just
need to be sure to update other NIR drivers to flag lower_minmax3 so
they don't start seeing unexpected minmax3s.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180601/de4786cf/attachment.sig>


More information about the mesa-dev mailing list