nir/algebraic: Tautology replacements require sources be numbers
It seems worth the small amount of damage to give an extra cushion of not having to debug problems later. Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> All Intel platforms had similar results. (Tiger Lake shown) total instructions in shared programs: 21043197 -> 21043359 (<.01%) instructions in affected programs: 4409 -> 4571 (3.67%) helped: 0 HURT: 25 HURT stats (abs) min: 1 max: 16 x̄: 6.48 x̃: 5 HURT stats (rel) min: 0.39% max: 15.38% x̄: 4.59% x̃: 4.40% 95% mean confidence interval for instructions value: 4.37 8.59 95% mean confidence interval for instructions %-change: 2.93% 6.26% Instructions are HURT. total cycles in shared programs: 856175986 -> 856176921 (<.01%) cycles in affected programs: 58908 -> 59843 (1.59%) helped: 0 HURT: 25 HURT stats (abs) min: 7 max: 70 x̄: 37.40 x̃: 38 HURT stats (rel) min: 0.27% max: 5.63% x̄: 1.87% x̃: 1.39% 95% mean confidence interval for cycles value: 31.11 43.69 95% mean confidence interval for cycles %-change: 1.35% 2.39% Cycles are HURT. No fossil-db changes on any Intel platform. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10012>
This commit is contained in:
@@ -1177,13 +1177,13 @@ optimizations.extend([
|
|||||||
# The results expecting true, must be marked imprecise. The results
|
# The results expecting true, must be marked imprecise. The results
|
||||||
# expecting false are fine because NaN compared >= or < anything is false.
|
# expecting false are fine because NaN compared >= or < anything is false.
|
||||||
|
|
||||||
(('~fge', 'a(is_not_negative)', 'b(is_not_positive)'), True),
|
(('fge', 'a(is_a_number_not_negative)', 'b(is_a_number_not_positive)'), True),
|
||||||
(('fge', 'a(is_not_positive)', 'b(is_gt_zero)'), False),
|
(('fge', 'a(is_not_positive)', 'b(is_gt_zero)'), False),
|
||||||
(('fge', 'a(is_lt_zero)', 'b(is_not_negative)'), False),
|
(('fge', 'a(is_lt_zero)', 'b(is_not_negative)'), False),
|
||||||
|
|
||||||
(('flt', 'a(is_not_negative)', 'b(is_not_positive)'), False),
|
(('flt', 'a(is_not_negative)', 'b(is_not_positive)'), False),
|
||||||
(('~flt', 'a(is_not_positive)', 'b(is_gt_zero)'), True),
|
(('flt', 'a(is_a_number_not_positive)', 'b(is_a_number_gt_zero)'), True),
|
||||||
(('~flt', 'a(is_lt_zero)', 'b(is_not_negative)'), True),
|
(('flt', 'a(is_a_number_lt_zero)', 'b(is_a_number_not_negative)'), True),
|
||||||
|
|
||||||
(('ine', 'a(is_not_zero)', 0), True),
|
(('ine', 'a(is_not_zero)', 0), True),
|
||||||
(('ieq', 'a(is_not_zero)', 0), False),
|
(('ieq', 'a(is_not_zero)', 0), False),
|
||||||
|
@@ -442,6 +442,15 @@ is_ ## r (struct hash_table *ht, const nir_alu_instr *instr, \
|
|||||||
{ \
|
{ \
|
||||||
const struct ssa_result_range v = nir_analyze_range(ht, instr, src); \
|
const struct ssa_result_range v = nir_analyze_range(ht, instr, src); \
|
||||||
return v.range == r; \
|
return v.range == r; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static inline bool \
|
||||||
|
is_a_number_ ## r (struct hash_table *ht, const nir_alu_instr *instr, \
|
||||||
|
unsigned src, UNUSED unsigned num_components, \
|
||||||
|
UNUSED const uint8_t *swizzle) \
|
||||||
|
{ \
|
||||||
|
const struct ssa_result_range v = nir_analyze_range(ht, instr, src); \
|
||||||
|
return v.is_a_number && v.range == r; \
|
||||||
}
|
}
|
||||||
|
|
||||||
RELATION(lt_zero)
|
RELATION(lt_zero)
|
||||||
@@ -458,6 +467,17 @@ is_not_negative(struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
|||||||
return v.range == ge_zero || v.range == gt_zero || v.range == eq_zero;
|
return v.range == ge_zero || v.range == gt_zero || v.range == eq_zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
is_a_number_not_negative(struct hash_table *ht, const nir_alu_instr *instr,
|
||||||
|
unsigned src, UNUSED unsigned num_components,
|
||||||
|
UNUSED const uint8_t *swizzle)
|
||||||
|
{
|
||||||
|
const struct ssa_result_range v = nir_analyze_range(ht, instr, src);
|
||||||
|
return v.is_a_number &&
|
||||||
|
(v.range == ge_zero || v.range == gt_zero || v.range == eq_zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
is_not_positive(struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
is_not_positive(struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
||||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
||||||
@@ -466,6 +486,16 @@ is_not_positive(struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
|||||||
return v.range == le_zero || v.range == lt_zero || v.range == eq_zero;
|
return v.range == le_zero || v.range == lt_zero || v.range == eq_zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
is_a_number_not_positive(struct hash_table *ht, const nir_alu_instr *instr,
|
||||||
|
unsigned src, UNUSED unsigned num_components,
|
||||||
|
UNUSED const uint8_t *swizzle)
|
||||||
|
{
|
||||||
|
const struct ssa_result_range v = nir_analyze_range(ht, instr, src);
|
||||||
|
return v.is_a_number &&
|
||||||
|
(v.range == le_zero || v.range == lt_zero || v.range == eq_zero);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
is_not_zero(struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
is_not_zero(struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
||||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
||||||
@@ -474,6 +504,16 @@ is_not_zero(struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
|||||||
return v.range == lt_zero || v.range == gt_zero || v.range == ne_zero;
|
return v.range == lt_zero || v.range == gt_zero || v.range == ne_zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
is_a_number_not_zero(struct hash_table *ht, const nir_alu_instr *instr,
|
||||||
|
unsigned src, UNUSED unsigned num_components,
|
||||||
|
UNUSED const uint8_t *swizzle)
|
||||||
|
{
|
||||||
|
const struct ssa_result_range v = nir_analyze_range(ht, instr, src);
|
||||||
|
return v.is_a_number &&
|
||||||
|
(v.range == lt_zero || v.range == gt_zero || v.range == ne_zero);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
is_a_number(struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
is_a_number(struct hash_table *ht, const nir_alu_instr *instr, unsigned src,
|
||||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
||||||
|
Reference in New Issue
Block a user