gallivm: fix nested break statemants
authorZack Rusin <zackr@vmware.com>
Thu, 22 Apr 2010 17:43:37 +0000 (13:43 -0400)
committerZack Rusin <zackr@vmware.com>
Thu, 22 Apr 2010 17:57:18 +0000 (13:57 -0400)
src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c

index 44f8aec1bf0a6b12db86289551522d4ef5222bdb..b87817dd0d49786f77c9a2d3bf894fc0def3092d 100644 (file)
@@ -232,6 +232,8 @@ static void lp_exec_bgnloop(struct lp_exec_mask *mask)
       mask->break_mask = LLVMConstAllOnes(mask->int_vec_type);
    if (mask->cond_stack_size == 0)
       mask->cond_mask = LLVMConstAllOnes(mask->int_vec_type);
+
+   mask->break_stack[mask->break_stack_size++] = mask->break_mask;
    mask->loop_stack[mask->loop_stack_size++] = mask->loop_block;
    mask->loop_block = lp_build_insert_new_block(mask->bld->builder, "bgnloop");
    LLVMBuildBr(mask->bld->builder, mask->loop_block);
@@ -246,7 +248,6 @@ static void lp_exec_break(struct lp_exec_mask *mask)
                                          mask->exec_mask,
                                          "break");
 
-   mask->break_stack[mask->break_stack_size++] = mask->break_mask;
    if (mask->break_stack_size > 1) {
       mask->break_mask = LLVMBuildAnd(mask->bld->builder,
                                       mask->break_mask,
@@ -304,7 +305,7 @@ static void lp_exec_endloop(struct lp_exec_mask *mask)
       mask->cont_mask = mask->cont_stack[--mask->cont_stack_size];
    }
    if (mask->break_stack_size) {
-      mask->break_mask = mask->cont_stack[--mask->break_stack_size];
+      mask->break_mask = mask->break_stack[--mask->break_stack_size];
    }
 
    lp_exec_mask_update(mask);