nir/lower_returns: Stop using constant initializers
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 20 Jul 2016 17:37:43 +0000 (10:37 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 5 Dec 2016 23:40:09 +0000 (15:40 -0800)
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
src/compiler/nir/nir_lower_returns.c

index 8dbea6e7179609450ee1d667825cce603a2d98c1..cf49d5b09e35d4d5216090e360418aefddf4fb06 100644 (file)
@@ -147,17 +147,18 @@ lower_returns_in_block(nir_block *block, struct lower_returns_state *state)
    nir_instr_remove(&jump->instr);
 
    nir_builder *b = &state->builder;
-   b->cursor = nir_after_block(block);
 
    /* Set the return flag */
    if (state->return_flag == NULL) {
       state->return_flag =
          nir_local_variable_create(b->impl, glsl_bool_type(), "return");
 
-      /* Set a default value of false */
-      state->return_flag->constant_initializer =
-         rzalloc(state->return_flag, nir_constant);
+      /* Initialize the variable to 0 */
+      b->cursor = nir_before_cf_list(&b->impl->body);
+      nir_store_var(b, state->return_flag, nir_imm_int(b, NIR_FALSE), 1);
    }
+
+   b->cursor = nir_after_block(block);
    nir_store_var(b, state->return_flag, nir_imm_int(b, NIR_TRUE), 1);
 
    if (state->loop) {