diff options
author | Jason Ekstrand <[email protected]> | 2019-05-06 15:30:36 -0500 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-05-24 08:38:11 -0500 |
commit | 2a39788d03789af643a957da8b8ebd2d5f0218aa (patch) | |
tree | 50b5847623aa860a1d326e84f25275724f1356e3 /src/compiler | |
parent | 8ffbb5440564f6a6c00a73997f554e6c4005783f (diff) |
nir/source_mods: Add a helpers for setting source modifiers
It's potentially a tiny bit less efficient but the helpers make it much
easier to sort out the rules for updating source modifiers.
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_lower_to_source_mods.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/compiler/nir/nir_lower_to_source_mods.c b/src/compiler/nir/nir_lower_to_source_mods.c index 3ca53c34afc..3315a18670b 100644 --- a/src/compiler/nir/nir_lower_to_source_mods.c +++ b/src/compiler/nir/nir_lower_to_source_mods.c @@ -33,6 +33,20 @@ * easier to not have them when we're doing optimizations. */ +static void +alu_src_consume_abs(nir_alu_src *src) +{ + src->abs = true; +} + +static void +alu_src_consume_negate(nir_alu_src *src) +{ + /* If abs is set on the source, the negate goes away */ + if (!src->abs) + src->negate = !src->negate; +} + static bool nir_lower_to_source_mods_block(nir_block *block, nir_lower_to_source_mods_flags options) @@ -88,12 +102,10 @@ nir_lower_to_source_mods_block(nir_block *block, continue; nir_instr_rewrite_src(instr, &alu->src[i].src, parent->src[0].src); - if (alu->src[i].abs) { - /* abs trumps both neg and abs, do nothing */ - } else { - alu->src[i].negate = (alu->src[i].negate != parent->src[0].negate); - alu->src[i].abs |= parent->src[0].abs; - } + if (parent->src[0].negate) + alu_src_consume_negate(&alu->src[i]); + if (parent->src[0].abs) + alu_src_consume_abs(&alu->src[i]); for (int j = 0; j < 4; ++j) { if (!nir_alu_instr_channel_used(alu, i, j)) |