glsl: fix the type of ir_constant_data::u16
[mesa.git] / src / compiler / glsl / opt_conditional_discard.cpp
index 03665c373648f46e0852056c6d4808bc871eca03..6d8a23460d9a34e9e4d2def40c6f0646c14cbcee 100644 (file)
@@ -72,7 +72,14 @@ opt_conditional_discard_visitor::visit_leave(ir_if *ir)
 
    /* Move the condition and replace the ir_if with the ir_discard. */
    ir_discard *discard = (ir_discard *) ir->then_instructions.get_head_raw();
-   discard->condition = ir->condition;
+   if (!discard->condition)
+      discard->condition = ir->condition;
+   else {
+      void *ctx = ralloc_parent(ir);
+      discard->condition = new(ctx) ir_expression(ir_binop_logic_and,
+                                                  ir->condition,
+                                                  discard->condition);
+   }
    ir->replace_with(discard);
 
    progress = true;