[Mesa-dev] [PATCH 08/10] nir: Simplify 0 < fabs(a)

Ilia Mirkin imirkin at alum.mit.edu
Thu Mar 10 20:25:33 UTC 2016


On Thu, Mar 10, 2016 at 3:24 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> On Thu, Mar 10, 2016 at 1:25 PM, Ian Romanick <idr at freedesktop.org> wrote:
>> From: Ian Romanick <ian.d.romanick at intel.com>
>>
>> Sandy Bridge / Ivy Bridge / Haswell
>> total instructions in shared programs: 8462180 -> 8462174 (-0.00%)
>> instructions in affected programs: 564 -> 558 (-1.06%)
>> helped: 6
>> HURT: 0
>>
>> total cycles in shared programs: 117542462 -> 117542276 (-0.00%)
>> cycles in affected programs: 9768 -> 9582 (-1.90%)
>> helped: 12
>> HURT: 0
>>
>> Broadwell / Skylake
>> total instructions in shared programs: 8980833 -> 8980826 (-0.00%)
>> instructions in affected programs: 626 -> 619 (-1.12%)
>> helped: 7
>> HURT: 0
>>
>> total cycles in shared programs: 70077900 -> 70077714 (-0.00%)
>> cycles in affected programs: 9378 -> 9192 (-1.98%)
>> helped: 12
>> HURT: 0
>>
>> G45 and Ironlake showed no change.
>>
>> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
>> ---
>>  src/compiler/nir/nir_opt_algebraic.py | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
>> index 4db8f84..1442ce8 100644
>> --- a/src/compiler/nir/nir_opt_algebraic.py
>> +++ b/src/compiler/nir/nir_opt_algebraic.py
>> @@ -108,6 +108,11 @@ optimizations = [
>>     # inot(a)
>>     (('fge', 0.0, ('b2f', a)), ('inot', a)),
>>
>> +   # 0.0 < fabs(a)
>> +   # 0.0 != fabs(a)  because fabs(a) must be >= 0
>> +   # 0.0 != a
>> +   (('flt', 0.0, ('fabs', a)), ('fne', a, 0.0)),
>
> Can you walk me through the logic? You're saying that
>
> 0 < |a| <-> a != 0
>
> If a == 0, 0 < |a| would still be false, no? I think that
>
> 0 < |a| <-> false
> 0 <= |a| <-> a != 0
>
> But I could just be missing something obvious...

Yeah. Nevermind. I'm tired. Ignore this.

  -ilia


More information about the mesa-dev mailing list