nir/opt_offsets: add option to allow offset wrapping
On some ISAs (e.g., ir3) the offset calculation wraps the same way as normal unsigned addition so potentially wrapping operations do not have to be ignored. Signed-off-by: Job Noorman <jnoorman@igalia.com> Reviewed-by: Connor Abbott <cwabbott0@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28664>
This commit is contained in:
@@ -6584,6 +6584,12 @@ typedef struct {
|
||||
|
||||
/** Data to pass to max_offset_cb. */
|
||||
const void *max_offset_data;
|
||||
|
||||
/**
|
||||
* Allow the offset calculation to wrap. If false, constant additions that
|
||||
* might wrap will not be folded into the offset.
|
||||
*/
|
||||
bool allow_offset_wrap;
|
||||
} nir_opt_offsets_options;
|
||||
|
||||
bool nir_opt_offsets(nir_shader *shader, const nir_opt_offsets_options *options);
|
||||
|
@@ -56,7 +56,7 @@ try_extract_const_addition(nir_builder *b, nir_scalar val, opt_offsets_state *st
|
||||
* Ignored for ints-as-floats (lower_bitops is a proxy for that), where
|
||||
* unsigned wrapping doesn't make sense.
|
||||
*/
|
||||
if (!alu->no_unsigned_wrap && !b->shader->options->lower_bitops) {
|
||||
if (!state->options->allow_offset_wrap && !alu->no_unsigned_wrap && !b->shader->options->lower_bitops) {
|
||||
if (!state->range_ht) {
|
||||
/* Cache for nir_unsigned_upper_bound */
|
||||
state->range_ht = _mesa_pointer_hash_table_create(NULL);
|
||||
|
Reference in New Issue
Block a user