nir: Add optimizations for iadd3
This patch also adds has_iadd3 bit to give more control if backend supports ternary add instruction or not. v2: - Add patterns in late optimization (Connor Abbott) Suggested-by: Alyssa/Jason Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com> Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11596>
This commit is contained in:
@@ -3433,6 +3433,9 @@ typedef struct nir_shader_compiler_options {
|
||||
/* Lowers when rotate instruction is not supported */
|
||||
bool lower_rotate;
|
||||
|
||||
/** Backend supports ternary addition */
|
||||
bool has_iadd3;
|
||||
|
||||
/**
|
||||
* Backend supports imul24, and would like to use it (when possible)
|
||||
* for address/offset calculation. If true, driver should call
|
||||
|
||||
@@ -2269,6 +2269,10 @@ late_optimizations = [
|
||||
(('~fadd@32', ('fmul', a, b), c), ('ffma', a, b, c), 'options->fuse_ffma32'),
|
||||
(('~fadd@64', ('fmul', a, b), c), ('ffma', a, b, c), 'options->fuse_ffma64'),
|
||||
|
||||
(('iadd', ('iadd(is_used_once)', 'a(is_not_const)', 'b(is_not_const)'), 'c(is_not_const)'), ('iadd3', a, b, c), 'options->has_iadd3'),
|
||||
(('iadd', ('isub(is_used_once)', 'a(is_not_const)', 'b(is_not_const)'), 'c(is_not_const)'), ('iadd3', a, ('ineg', b), c), 'options->has_iadd3'),
|
||||
(('isub', ('isub(is_used_once)', 'a(is_not_const)', 'b(is_not_const)'), 'c(is_not_const)'), ('iadd3', a, ('ineg', b), ('ineg', c)), 'options->has_iadd3'),
|
||||
|
||||
# These are duplicated from the main optimizations table. The late
|
||||
# patterns that rearrange expressions like x - .5 < 0 to x < .5 can create
|
||||
# new patterns like these. The patterns that compare with zero are removed
|
||||
|
||||
Reference in New Issue
Block a user