Hello,
this kind of simplification is already handled by fold_comparison, but the
code is common with TRUNC_DIV_EXPR, which yields suboptimal code. In
particular, for an unsigned number, X/8==0 means x<=7, while X/[ex]8==0 can
be turned into X==0.
When we have an explicit division by 0, there is a better optimisation
possible (insert __builtin_unreachable() or __builtin_trap() after that
statement, as in find_explicit_erroneous_behavior), so I don't touch it.
For the overflow inequality case, it would have been a bit clearer to
generate
(cmp { build_zero_cst (TREE_TYPE (@0)); } @2)
and let that be constant folded instead of having that ugly and error-prone
test in constant_boolean_node, but I saved one tree ;-)
Bootstrap+regtest on powerpc64le-unknown-linux-gnu, all the regressions are
in the libitm part of the testsuite, they should be fixed by
https://gcc.gnu.org/ml/gcc-patches/2016-10/msg02220.html , I'll rerun the
testsuite when that patch is in.