[Mesa-dev] [PATCH 2/3] ac/nir: convert several ifs to a switch
Grazvydas Ignotas
notasas at gmail.com
Tue Jun 6 23:31:27 UTC 2017
Also solve "outinfo may be used uninitialized" warning by putting in an
unreachable().
Signed-off-by: Grazvydas Ignotas <notasas at gmail.com>
---
src/amd/common/ac_nir_to_llvm.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 5f62769..005e2be 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -5802,27 +5802,29 @@ static void ac_llvm_finalize_module(struct nir_to_llvm_context * ctx)
static void
ac_nir_eliminate_const_vs_outputs(struct nir_to_llvm_context *ctx)
{
struct ac_vs_output_info *outinfo;
- if (ctx->stage == MESA_SHADER_FRAGMENT ||
- ctx->stage == MESA_SHADER_COMPUTE ||
- ctx->stage == MESA_SHADER_TESS_CTRL ||
- ctx->stage == MESA_SHADER_GEOMETRY)
+ switch (ctx->stage) {
+ case MESA_SHADER_FRAGMENT:
+ case MESA_SHADER_COMPUTE:
+ case MESA_SHADER_TESS_CTRL:
+ case MESA_SHADER_GEOMETRY:
return;
-
- if (ctx->stage == MESA_SHADER_VERTEX) {
+ case MESA_SHADER_VERTEX:
if (ctx->options->key.vs.as_ls ||
ctx->options->key.vs.as_es)
return;
outinfo = &ctx->shader_info->vs.outinfo;
- }
-
- if (ctx->stage == MESA_SHADER_TESS_EVAL) {
+ break;
+ case MESA_SHADER_TESS_EVAL:
if (ctx->options->key.vs.as_es)
return;
outinfo = &ctx->shader_info->tes.outinfo;
+ break;
+ default:
+ unreachable("Unhandled shader type");
}
ac_optimize_vs_outputs(&ctx->ac,
ctx->main_function,
outinfo->vs_output_param_offset,
--
2.7.4
More information about the mesa-dev
mailing list