[Mesa-dev] [PATCH] st_glsl_to_tgsi: check for the tail sentinel in merge_two_dsts

Nicolai Hähnle nhaehnle at gmail.com
Mon Nov 20 15:36:20 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

This fixes yet another case where DFRACEXP has only one destination. Found
by address sanitizer.

Fixes tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-frexp-dvec4-only-mantissa.shader_test

Fixes: 3b666aa74795 ("st/glsl_to_tgsi: fix DFRACEXP with only one destination")
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 0772b736275..fa51fef343b 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5245,32 +5245,32 @@ glsl_to_tgsi_visitor::merge_two_dsts(void)
 
       assert(inst->dst[0].file != PROGRAM_UNDEFINED ||
              inst->dst[1].file != PROGRAM_UNDEFINED);
 
       if (inst->dst[0].file == PROGRAM_UNDEFINED)
          defined = 1;
       else
          defined = 0;
 
       inst2 = (glsl_to_tgsi_instruction *) inst->next;
-      do {
+      while (!inst2->is_tail_sentinel()) {
          if (inst->op == inst2->op &&
              inst2->dst[defined].file == PROGRAM_UNDEFINED &&
              inst->src[0].file == inst2->src[0].file &&
              inst->src[0].index == inst2->src[0].index &&
              inst->src[0].type == inst2->src[0].type &&
              inst->src[0].swizzle == inst2->src[0].swizzle)
             break;
          inst2 = (glsl_to_tgsi_instruction *) inst2->next;
-      } while (inst2);
+      }
 
-      if (!inst2) {
+      if (inst2->is_tail_sentinel()) {
          /* Undefined destinations are not allowed, substitute with an unused
           * temporary register.
           */
          st_src_reg tmp = get_temp(glsl_type::vec4_type);
          inst->dst[defined ^ 1] = st_dst_reg(tmp);
          inst->dst[defined ^ 1].writemask = 0;
          continue;
       }
 
       inst->dst[defined ^ 1] = inst2->dst[defined ^ 1];
-- 
2.11.0



More information about the mesa-dev mailing list