On 12/03/14 10:10, Jakub Jelinek wrote:
Hi!

While expand_mult correctly checks for multiplication by zero,
expand_widening_mult does not and as floor_log2 (0) returns -1,
it attempts to expand a double-word shift by -1 and on ppc32
happens to return 2 w* 0 = 1.  Usually earlier optimizations
just ensure that w* 0 isn't expanded using expand_widening_mult,
e.g. expand_mul_overflow which expands widening multiply separately
on highpart and lowpart of some value can end up with this.
I think it is better to fix this on the expand_widening_mult side
rather than having to bother with those special cases in every caller.
In 4.9, I think ubsan_expand_si_overflow_mul_check can trigger the
same thing.

Testcase for this is builtin-arith-overflow-14.c on ppc32.
Bootstrapped/regtested on x86_64-linux and i686-linux, tested on
the testcase with ppc cross.  Ok for trunk/4.9?

2014-12-03  Jakub Jelinek  <ja...@redhat.com>

        PR c/59708
        * expmed.c (expand_widening_mult): Return const0_rtx if
        coeff is 0.
OK.
Jeff

Reply via email to