expand: Split divisions with near-power-of-two divisors [PR middle-end/125708]
When range info proves that a TRUNC_DIV_EXPR divisor is either N or N
+ 1, and one value is a positive power of two, expand the operation as
two constant divisions selected by a conditional move.
Only do this for speed, when conditional moves are available. Cost
the split sequence against a plain DIV/UDIV and keep the original
expansion unless the split is cheaper.
PR middle-end/125708
gcc/ChangeLog:
* expr.cc: Include gimple-range.h.
(near_pow2_divisor_range_p): New function.
(expand_expr_divmod): Split eligible TRUNC_DIV_EXPRs into two
constant divisions selected by a conditional move.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/pr125708-1.c: New test.
* gcc.target/i386/pr125708-2.c: New test.