Mesa (main): llvmpipe: replace if/then with switch in llvmpipe_nir_fn_is_linear_compat()
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jul 14 20:00:36 UTC 2022
Module: Mesa
Branch: main
Commit: 2d4473c2ac7556f8d233eff08d301d1ba81e277a
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2d4473c2ac7556f8d233eff08d301d1ba81e277a
Author: Brian Paul <brianp at vmware.com>
Date: Thu Jun 2 12:38:41 2022 -0600
llvmpipe: replace if/then with switch in llvmpipe_nir_fn_is_linear_compat()
To simplify the logic a bit.
Signed-off-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17062>
---
src/gallium/drivers/llvmpipe/lp_state_fs_analysis.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs_analysis.c b/src/gallium/drivers/llvmpipe/lp_state_fs_analysis.c
index c36fe3c2385..69f9af84a72 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs_analysis.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs_analysis.c
@@ -259,13 +259,13 @@ llvmpipe_nir_fn_is_linear_compat(const struct nir_shader *shader,
}
case nir_instr_type_alu: {
const nir_alu_instr *alu = nir_instr_as_alu(instr);
- if (alu->op != nir_op_mov &&
- alu->op != nir_op_vec2 &&
- alu->op != nir_op_vec4 &&
- alu->op != nir_op_fmul)
- return false;
-
- if (alu->op == nir_op_fmul) {
+ switch (alu->op) {
+ case nir_op_mov:
+ case nir_op_vec2:
+ case nir_op_vec4:
+ // these instructions are OK
+ break;
+ case nir_op_fmul: {
unsigned num_src = nir_op_infos[alu->op].num_inputs;;
for (unsigned s = 0; s < num_src; s++) {
/* If the MUL uses immediate values, the values must
@@ -285,6 +285,11 @@ llvmpipe_nir_fn_is_linear_compat(const struct nir_shader *shader,
}
}
}
+ break;
+ }
+ default:
+ // disallowed instruction
+ return false;
}
break;
}
More information about the mesa-commit
mailing list