nir/optimize cmp(a, -0.0)
+0.0 can use an inline constant for AMD hardware, -0.0 needs a literal. Foz-DB Navi21: Totals from 1014 (1.28% of 79395) affected shaders: Instrs: 3037490 -> 3036849 (-0.02%); split: -0.02%, +0.00% CodeSize: 17060228 -> 17051276 (-0.05%); split: -0.05%, +0.00% Latency: 45916788 -> 45916600 (-0.00%); split: -0.00%, +0.00% InvThroughput: 12982201 -> 12982187 (-0.00%); split: -0.00%, +0.00% VClause: 79475 -> 79478 (+0.00%) SClause: 119935 -> 119934 (-0.00%); split: -0.00%, +0.00% Copies: 301641 -> 300964 (-0.22%); split: -0.23%, +0.00% PreSGPRs: 59155 -> 59144 (-0.02%) VALU: 2032016 -> 2032034 (+0.00%) SALU: 386424 -> 385729 (-0.18%) Reviewed-by: Timur Kristóf <timur.kristof@gmail.com> Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29467>
This commit is contained in:
@@ -608,6 +608,12 @@ optimizations.extend([
|
||||
(('fge', -1.0, ('fneg', a)), ('fge', a, 1.0)),
|
||||
(('fneu', ('fneg', a), -1.0), ('fneu', 1.0, a)),
|
||||
(('feq', -1.0, ('fneg', a)), ('feq', a, 1.0)),
|
||||
(('flt', a, '#b(is_negative_zero)'), ('flt', a, 0.0)),
|
||||
(('flt', '#b(is_negative_zero)', a), ('flt', 0.0, a)),
|
||||
(('fge', a, '#b(is_negative_zero)'), ('fge', a, 0.0)),
|
||||
(('fge', '#b(is_negative_zero)', a), ('fge', 0.0, a)),
|
||||
(('fneu', a, '#b(is_negative_zero)'), ('fneu', 0.0, a)),
|
||||
(('feq', '#b(is_negative_zero)', a), ('feq', a, 0.0)),
|
||||
|
||||
(('ieq', ('ineg', a), 0), ('ieq', a, 0)),
|
||||
(('ine', ('ineg', a), 0), ('ine', a, 0)),
|
||||
|
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <math.h>
|
||||
#include "util/bitscan.h"
|
||||
#include "util/u_math.h"
|
||||
#include "nir.h"
|
||||
#include "nir_range_analysis.h"
|
||||
|
||||
@@ -127,6 +128,24 @@ is_nan(UNUSED struct hash_table *ht, const nir_alu_instr *instr,
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
is_negative_zero(UNUSED struct hash_table *ht, const nir_alu_instr *instr,
|
||||
unsigned src, unsigned num_components, const uint8_t *swizzle)
|
||||
{
|
||||
/* only constant srcs: */
|
||||
if (!nir_src_is_const(instr->src[src].src))
|
||||
return false;
|
||||
|
||||
for (unsigned i = 0; i < num_components; i++) {
|
||||
union di tmp;
|
||||
tmp.d = nir_src_comp_as_float(instr->src[src].src, swizzle[i]);
|
||||
if (tmp.ui != 0x8000000000000000ull)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
is_any_comp_nan(UNUSED struct hash_table *ht, const nir_alu_instr *instr,
|
||||
unsigned src, unsigned num_components, const uint8_t *swizzle)
|
||||
|
Reference in New Issue
Block a user