diff options
author | Jason Ekstrand <[email protected]> | 2019-05-06 11:26:27 -0500 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-05-24 08:38:11 -0500 |
commit | 22421ca7be608f38ce701a43e3f6b7f3132b7aab (patch) | |
tree | cf0995e67b47c17850c0b207ac86d83abb248348 /src/compiler | |
parent | cd73b6174b093b75f581c3310bf784bed7c74c1f (diff) |
nir/builder: Merge nir_[if]mov_alu into one nir_mov_alu helper
Unless source modifiers are present, fmov and imov are the same.
There's no good reason for having two helpers.
Reviewed-by: Kristian H. Kristensen <[email protected]>
Acked-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/nir/nir_builder.h | 26 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_double_ops.c | 10 | ||||
-rw-r--r-- | src/compiler/nir/nir_opt_remove_phis.c | 4 | ||||
-rw-r--r-- | src/compiler/nir/nir_search.c | 2 |
4 files changed, 12 insertions, 30 deletions
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index 68cf886fa1c..e14151ab7b5 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -492,26 +492,10 @@ nir_vec(nir_builder *build, nir_ssa_def **comp, unsigned num_components) return nir_build_alu_src_arr(build, nir_op_vec(num_components), comp); } -/** - * Similar to nir_fmov, but takes a nir_alu_src instead of a nir_ssa_def. - */ -static inline nir_ssa_def * -nir_fmov_alu(nir_builder *build, nir_alu_src src, unsigned num_components) -{ - nir_alu_instr *mov = nir_alu_instr_create(build->shader, nir_op_fmov); - nir_ssa_dest_init(&mov->instr, &mov->dest.dest, num_components, - nir_src_bit_size(src.src), NULL); - mov->exact = build->exact; - mov->dest.write_mask = (1 << num_components) - 1; - mov->src[0] = src; - nir_builder_instr_insert(build, &mov->instr); - - return &mov->dest.dest.ssa; -} - static inline nir_ssa_def * -nir_imov_alu(nir_builder *build, nir_alu_src src, unsigned num_components) +nir_mov_alu(nir_builder *build, nir_alu_src src, unsigned num_components) { + assert(!src.abs && !src.negate); nir_alu_instr *mov = nir_alu_instr_create(build->shader, nir_op_imov); nir_ssa_dest_init(&mov->instr, &mov->dest.dest, num_components, nir_src_bit_size(src.src), NULL); @@ -544,7 +528,7 @@ nir_swizzle(nir_builder *build, nir_ssa_def *src, const unsigned *swiz, if (num_components == src->num_components && is_identity_swizzle) return src; - return nir_imov_alu(build, alu_src, num_components); + return nir_mov_alu(build, alu_src, num_components); } /* Selects the right fdot given the number of components in each source. */ @@ -838,7 +822,7 @@ nir_ssa_for_src(nir_builder *build, nir_src src, int num_components) for (int j = 0; j < 4; j++) alu.swizzle[j] = j; - return nir_imov_alu(build, alu, num_components); + return nir_mov_alu(build, alu, num_components); } /** @@ -859,7 +843,7 @@ nir_ssa_for_alu_src(nir_builder *build, nir_alu_instr *instr, unsigned srcn) (memcmp(src->swizzle, trivial_swizzle, num_components) == 0)) return src->src.ssa; - return nir_imov_alu(build, *src, num_components); + return nir_mov_alu(build, *src, num_components); } static inline unsigned diff --git a/src/compiler/nir/nir_lower_double_ops.c b/src/compiler/nir/nir_lower_double_ops.c index 04ec2a82801..4ddd91f9054 100644 --- a/src/compiler/nir/nir_lower_double_ops.c +++ b/src/compiler/nir/nir_lower_double_ops.c @@ -581,7 +581,7 @@ lower_doubles_instr_to_soft(nir_builder *b, nir_alu_instr *instr, assert(nir_op_infos[instr->op].num_inputs + 1 == func->num_params); for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) { assert(i + 1 < ARRAY_SIZE(params)); - params[i + 1] = nir_imov_alu(b, instr->src[i], 1); + params[i + 1] = nir_mov_alu(b, instr->src[i], 1); } nir_inline_function_impl(b, func->impl, params); @@ -633,8 +633,8 @@ lower_doubles_instr(nir_builder *b, nir_alu_instr *instr, b->cursor = nir_before_instr(&instr->instr); - nir_ssa_def *src = nir_fmov_alu(b, instr->src[0], - instr->dest.dest.ssa.num_components); + nir_ssa_def *src = nir_mov_alu(b, instr->src[0], + instr->dest.dest.ssa.num_components); nir_ssa_def *result; @@ -665,8 +665,8 @@ lower_doubles_instr(nir_builder *b, nir_alu_instr *instr, break; case nir_op_fmod: { - nir_ssa_def *src1 = nir_fmov_alu(b, instr->src[1], - instr->dest.dest.ssa.num_components); + nir_ssa_def *src1 = nir_mov_alu(b, instr->src[1], + instr->dest.dest.ssa.num_components); result = lower_mod(b, src, src1); } break; diff --git a/src/compiler/nir/nir_opt_remove_phis.c b/src/compiler/nir/nir_opt_remove_phis.c index 9efbf422624..3643112d976 100644 --- a/src/compiler/nir/nir_opt_remove_phis.c +++ b/src/compiler/nir/nir_opt_remove_phis.c @@ -124,9 +124,7 @@ remove_phis_block(nir_block *block, nir_builder *b) */ b->cursor = nir_after_phis(block); - def = mov->op == nir_op_imov ? - nir_imov_alu(b, mov->src[0], def->num_components) : - nir_fmov_alu(b, mov->src[0], def->num_components); + def = nir_mov_alu(b, mov->src[0], def->num_components); } assert(phi->dest.is_ssa); diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c index 4838825d7b4..b8bedaa2013 100644 --- a/src/compiler/nir/nir_search.c +++ b/src/compiler/nir/nir_search.c @@ -669,7 +669,7 @@ nir_replace_instr(nir_builder *build, nir_alu_instr *instr, * and rewrite swizzles ourselves. */ nir_ssa_def *ssa_val = - nir_imov_alu(build, val, instr->dest.dest.ssa.num_components); + nir_mov_alu(build, val, instr->dest.dest.ssa.num_components); nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, nir_src_for_ssa(ssa_val)); /* We know this one has no more uses because we just rewrote them all, |