nir/algebraic: mark some optimizations with fsat(NaN) as inexact
[mesa.git] / src / compiler / nir / nir_lower_returns.c
index 9c4881112e30ffc29033be9ce316cd052b459f71..56c7656aeafc7412fc7c41781087839c9eb166ca 100644 (file)
@@ -50,7 +50,7 @@ predicate_following(nir_cf_node *node, struct lower_returns_state *state)
    nir_builder *b = &state->builder;
    b->cursor = nir_after_cf_node_and_phis(node);
 
-   if (nir_cursors_equal(b->cursor, nir_after_cf_list(state->cf_list)))
+   if (!state->loop && nir_cursors_equal(b->cursor, nir_after_cf_list(state->cf_list)))
       return; /* Nothing to predicate */
 
    assert(state->return_flag);
@@ -198,11 +198,11 @@ lower_returns_in_block(nir_block *block, struct lower_returns_state *state)
 
       /* 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);
+      nir_store_var(b, state->return_flag, nir_imm_false(b), 1);
    }
 
    b->cursor = nir_after_block(block);
-   nir_store_var(b, state->return_flag, nir_imm_int(b, NIR_TRUE), 1);
+   nir_store_var(b, state->return_flag, nir_imm_true(b), 1);
 
    if (state->loop) {
       /* We're in a loop;  we need to break out of it. */
@@ -274,6 +274,8 @@ nir_lower_returns_impl(nir_function_impl *impl)
    if (progress) {
       nir_metadata_preserve(impl, nir_metadata_none);
       nir_repair_ssa_impl(impl);
+   } else {
+      nir_metadata_preserve(impl, nir_metadata_all);
    }
 
    return progress;