diff options
-rw-r--r-- | src/compiler/glsl/lower_instructions.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/compiler/glsl/lower_instructions.cpp b/src/compiler/glsl/lower_instructions.cpp index a9720f21638..372ded180a5 100644 --- a/src/compiler/glsl/lower_instructions.cpp +++ b/src/compiler/glsl/lower_instructions.cpp @@ -166,6 +166,8 @@ private: void find_lsb_to_float_cast(ir_expression *ir); void find_msb_to_float_cast(ir_expression *ir); void imul_high_to_mul(ir_expression *ir); + + ir_expression *_carry(operand a, operand b); }; } /* anonymous namespace */ @@ -1413,6 +1415,16 @@ lower_instructions_visitor::find_msb_to_float_cast(ir_expression *ir) this->progress = true; } +ir_expression * +lower_instructions_visitor::_carry(operand a, operand b) +{ + if (lowering(CARRY_TO_ARITH)) + return i2u(b2i(less(add(a, b), + a.val->clone(ralloc_parent(a.val), NULL)))); + else + return carry(a, b); +} + void lower_instructions_visitor::imul_high_to_mul(ir_expression *ir) { @@ -1518,11 +1530,11 @@ lower_instructions_visitor::imul_high_to_mul(ir_expression *ir) i.insert_before(assign(t2, mul(src1h, src2l))); i.insert_before(assign(hi, mul(src1h, src2h))); - i.insert_before(assign(hi, add(hi, carry(lo, lshift(t1, c16->clone(ir, NULL)))))); - i.insert_before(assign(lo, add(lo, lshift(t1, c16->clone(ir, NULL))))); + i.insert_before(assign(hi, add(hi, _carry(lo, lshift(t1, c16->clone(ir, NULL)))))); + i.insert_before(assign(lo, add(lo, lshift(t1, c16->clone(ir, NULL))))); - i.insert_before(assign(hi, add(hi, carry(lo, lshift(t2, c16->clone(ir, NULL)))))); - i.insert_before(assign(lo, add(lo, lshift(t2, c16->clone(ir, NULL))))); + i.insert_before(assign(hi, add(hi, _carry(lo, lshift(t2, c16->clone(ir, NULL)))))); + i.insert_before(assign(lo, add(lo, lshift(t2, c16->clone(ir, NULL))))); if (different_signs == NULL) { assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT); @@ -1547,7 +1559,7 @@ lower_instructions_visitor::imul_high_to_mul(ir_expression *ir) i.insert_before(neg_hi); i.insert_before(assign(neg_hi, add(bit_not(u2i(hi)), - u2i(carry(bit_not(lo), c1))))); + u2i(_carry(bit_not(lo), c1))))); ir->operation = ir_triop_csel; ir->operands[0] = new(ir) ir_dereference_variable(different_signs); |