Mesa (master): nir/source_mods: Add a helpers for setting source modifiers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri May 24 13:46:44 UTC 2019
Module: Mesa
Branch: master
Commit: 2a39788d03789af643a957da8b8ebd2d5f0218aa
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2a39788d03789af643a957da8b8ebd2d5f0218aa
Author: Jason Ekstrand <jason at jlekstrand.net>
Date: Mon May 6 15:30:36 2019 -0500
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 <hoegsberg at google.com>
Acked-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>
---
src/compiler/nir/nir_lower_to_source_mods.c | 24 ++++++++++++++++++------
1 file 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))
More information about the mesa-commit
mailing list