mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 07:08:04 +02:00
nir/search_helpers: switch to fp class analysis
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39987>
This commit is contained in:
parent
58799c4e7c
commit
eb431efc19
1 changed files with 20 additions and 116 deletions
|
|
@ -911,125 +911,29 @@ xz_components_unused(const nir_alu_instr *instr)
|
||||||
return (nir_def_components_read(&instr->def) & 0x5) == 0;
|
return (nir_def_components_read(&instr->def) & 0x5) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
#define RELATION(r, exclude) \
|
||||||
is_integral(const nir_search_state *state, const nir_alu_instr *instr, unsigned src,
|
static inline bool \
|
||||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
is_##r(const nir_search_state *state, const nir_alu_instr *instr, \
|
||||||
{
|
unsigned src, UNUSED unsigned num_components, \
|
||||||
const struct fp_result_range r = nir_analyze_fp_range(state->range_ht, instr->src[src].src.ssa);
|
UNUSED const uint8_t *swizzle) \
|
||||||
|
{ \
|
||||||
return r.is_integral;
|
const fp_class_mask fp_class = nir_analyze_fp_class(state->range_ht, instr->src[src].src.ssa); \
|
||||||
}
|
return (fp_class & (exclude)) == 0; \
|
||||||
|
|
||||||
/**
|
|
||||||
* Is the value finite?
|
|
||||||
*/
|
|
||||||
static inline bool
|
|
||||||
is_finite(UNUSED const nir_search_state *state, const nir_alu_instr *instr,
|
|
||||||
unsigned src, UNUSED unsigned num_components,
|
|
||||||
UNUSED const uint8_t *swizzle)
|
|
||||||
{
|
|
||||||
const struct fp_result_range v = nir_analyze_fp_range(state->range_ht, instr->src[src].src.ssa);
|
|
||||||
|
|
||||||
return v.is_finite;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool
|
|
||||||
is_finite_not_zero(UNUSED const nir_search_state *state, const nir_alu_instr *instr,
|
|
||||||
unsigned src, UNUSED unsigned num_components,
|
|
||||||
UNUSED const uint8_t *swizzle)
|
|
||||||
{
|
|
||||||
const struct fp_result_range v = nir_analyze_fp_range(state->range_ht, instr->src[src].src.ssa);
|
|
||||||
|
|
||||||
return v.is_finite &&
|
|
||||||
(v.range == lt_zero || v.range == gt_zero || v.range == ne_zero);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define RELATION(r) \
|
|
||||||
static inline bool \
|
|
||||||
is_##r(const nir_search_state *state, const nir_alu_instr *instr, \
|
|
||||||
unsigned src, UNUSED unsigned num_components, \
|
|
||||||
UNUSED const uint8_t *swizzle) \
|
|
||||||
{ \
|
|
||||||
const struct fp_result_range v = nir_analyze_fp_range(state->range_ht, instr->src[src].src.ssa); \
|
|
||||||
return v.range == r; \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
static inline bool \
|
|
||||||
is_a_number_##r(const nir_search_state *state, const nir_alu_instr *instr, \
|
|
||||||
unsigned src, UNUSED unsigned num_components, \
|
|
||||||
UNUSED const uint8_t *swizzle) \
|
|
||||||
{ \
|
|
||||||
const struct fp_result_range v = nir_analyze_fp_range(state->range_ht, instr->src[src].src.ssa); \
|
|
||||||
return v.is_a_number && v.range == r; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RELATION(lt_zero)
|
#define RELATION_AND_NUM(r, exclude) \
|
||||||
RELATION(le_zero)
|
RELATION(r, exclude) \
|
||||||
RELATION(gt_zero)
|
RELATION(a_number_##r, (exclude) | FP_CLASS_NAN)
|
||||||
RELATION(ge_zero)
|
|
||||||
RELATION(ne_zero)
|
|
||||||
|
|
||||||
static inline bool
|
RELATION_AND_NUM(lt_zero, FP_CLASS_ANY_POS | FP_CLASS_ANY_ZERO)
|
||||||
is_not_negative(const nir_search_state *state, const nir_alu_instr *instr, unsigned src,
|
RELATION_AND_NUM(not_positive, FP_CLASS_ANY_POS)
|
||||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
RELATION_AND_NUM(gt_zero, FP_CLASS_ANY_NEG | FP_CLASS_ANY_ZERO)
|
||||||
{
|
RELATION_AND_NUM(not_negative, FP_CLASS_ANY_NEG)
|
||||||
const struct fp_result_range v = nir_analyze_fp_range(state->range_ht, instr->src[src].src.ssa);
|
RELATION_AND_NUM(not_zero, FP_CLASS_ANY_ZERO)
|
||||||
return v.range == ge_zero || v.range == gt_zero || v.range == eq_zero;
|
RELATION(a_number, FP_CLASS_NAN)
|
||||||
}
|
RELATION(finite, FP_CLASS_ANY_INF | FP_CLASS_NAN)
|
||||||
|
RELATION(finite_not_zero, FP_CLASS_ANY_INF | FP_CLASS_NAN | FP_CLASS_ANY_ZERO)
|
||||||
static inline bool
|
RELATION(integral, FP_CLASS_NON_INTEGRAL)
|
||||||
is_a_number_not_negative(const nir_search_state *state, const nir_alu_instr *instr,
|
|
||||||
unsigned src, UNUSED unsigned num_components,
|
|
||||||
UNUSED const uint8_t *swizzle)
|
|
||||||
{
|
|
||||||
const struct fp_result_range v = nir_analyze_fp_range(state->range_ht, instr->src[src].src.ssa);
|
|
||||||
return v.is_a_number &&
|
|
||||||
(v.range == ge_zero || v.range == gt_zero || v.range == eq_zero);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool
|
|
||||||
is_not_positive(const nir_search_state *state, const nir_alu_instr *instr, unsigned src,
|
|
||||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
|
||||||
{
|
|
||||||
const struct fp_result_range v = nir_analyze_fp_range(state->range_ht, instr->src[src].src.ssa);
|
|
||||||
return v.range == le_zero || v.range == lt_zero || v.range == eq_zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool
|
|
||||||
is_a_number_not_positive(const nir_search_state *state, const nir_alu_instr *instr,
|
|
||||||
unsigned src, UNUSED unsigned num_components,
|
|
||||||
UNUSED const uint8_t *swizzle)
|
|
||||||
{
|
|
||||||
const struct fp_result_range v = nir_analyze_fp_range(state->range_ht, instr->src[src].src.ssa);
|
|
||||||
return v.is_a_number &&
|
|
||||||
(v.range == le_zero || v.range == lt_zero || v.range == eq_zero);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool
|
|
||||||
is_not_zero(const nir_search_state *state, const nir_alu_instr *instr, unsigned src,
|
|
||||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
|
||||||
{
|
|
||||||
const struct fp_result_range v = nir_analyze_fp_range(state->range_ht, instr->src[src].src.ssa);
|
|
||||||
return v.range == lt_zero || v.range == gt_zero || v.range == ne_zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool
|
|
||||||
is_a_number_not_zero(const nir_search_state *state, const nir_alu_instr *instr,
|
|
||||||
unsigned src, UNUSED unsigned num_components,
|
|
||||||
UNUSED const uint8_t *swizzle)
|
|
||||||
{
|
|
||||||
const struct fp_result_range v = nir_analyze_fp_range(state->range_ht, instr->src[src].src.ssa);
|
|
||||||
return v.is_a_number &&
|
|
||||||
(v.range == lt_zero || v.range == gt_zero || v.range == ne_zero);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool
|
|
||||||
is_a_number(const nir_search_state *state, const nir_alu_instr *instr, unsigned src,
|
|
||||||
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
|
|
||||||
{
|
|
||||||
const struct fp_result_range v = nir_analyze_fp_range(state->range_ht, instr->src[src].src.ssa);
|
|
||||||
return v.is_a_number;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
compare_component(const nir_alu_instr *instr, unsigned src, unsigned component,
|
compare_component(const nir_alu_instr *instr, unsigned src, unsigned component,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue