On FMA, a carry/borrow is required for iaddc/isubb (whereas the ADD
counterparts don't support carrying/borrowing). The trick is to model
this with an extra dummy (ZERO) argument which is free to encode on FMA,
and in the scheduler, "demote" to the non-carried versions if we want to
schedule to ADD.
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6749>
break;
case nir_op_iadd:
alu.op.imath = BI_IMATH_ADD;
+ /* Carry */
+ alu.src[2] = BIR_INDEX_ZERO;
break;
case nir_op_isub:
alu.op.imath = BI_IMATH_SUB;
+ /* Borrow */
+ alu.src[2] = BIR_INDEX_ZERO;
break;
case nir_op_iabs:
alu.op.special = BI_SPECIAL_IABS;
{
bi_instruction ins = bit_ins(BI_IMATH, 2, nir_type_uint, size);
bit_swizzle_identity(&ins, 2, size);
+ ins.src[2] = BIR_INDEX_ZERO; /* carry/borrow for FMA */
for (unsigned op = BI_IMATH_ADD; op <= BI_IMATH_SUB; ++op) {
ins.op.imath = op;