nir/lower_idiv: Add 8-bit and 16-bit lowering path

Roundtrip to a larger float and divide there. The extra details for
mod/rem are handled directly in integer space to simplify verification
of rounding details. The one issue is that the mantissa might be
rounded down which will cause issues; adding 1 unconditionally (proposed
by Jonathan Marek) fixes this. The lowerings here were tested
exhaustively on all pairs of 16-bit integers.

v2: Update idiv lowering per Rhys Perry's comment.

v3: Rewrite lowerings.

v4: Remove useless ftrunc, fix 8-bit issue, simplify code.

v5: Remove useless ffloor

Signed-off-by: Alyssa Rosenzweig <>
Reviewed-by: Jason Ekstrand <>
Tested-by: Danylo Piliaiev <>
Tested-by: Jason Ekstrand <>
Part-of: <!8339>
114 jobs for !8339 with idiv-patches in 22 minutes and 55 seconds (queued for 8 seconds)
latest merge request