From: Ian Romanick Date: Tue, 11 Sep 2018 22:38:36 +0000 (-0700) Subject: nir/algebraic: Add lowering for uabs_usub and uabs_isub X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ea435560ee26b2669d923c8af6077cd0c7ac0ff4;p=mesa.git nir/algebraic: Add lowering for uabs_usub and uabs_isub v2: Remove some rebase failures noticed by Caio. Reviewed-by: Caio Marcelo de Oliveira Filho Part-of: --- diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 2e139ebb85f..db2107ce974 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -951,6 +951,9 @@ optimizations.extend([ # Lower all Subtractions first - they can get recombined later (('fsub', a, b), ('fadd', a, ('fneg', b))), (('isub', a, b), ('iadd', a, ('ineg', b))), + (('uabs_usub', a, b), ('bcsel', ('ult', a, b), ('ineg', ('isub', a, b)), ('isub', a, b))), + # This is correct. We don't need isub_sat because the result type is unsigned, so it cannot overflow. + (('uabs_isub', a, b), ('bcsel', ('ilt', a, b), ('ineg', ('isub', a, b)), ('isub', a, b))), # Propagate negation up multiplication chains (('fmul(is_used_by_non_fsat)', ('fneg', a), b), ('fneg', ('fmul', a, b))),