[PATCH] Prevent extract_muldiv from introducing an overflow (PR sanitizer/80800)

Alexander Monakov amonakov@ispras.ru
Fri May 19 15:51:00 GMT 2017


On Fri, 19 May 2017, Marek Polacek wrote:
> > I think it's possible to keep this folding, note that it's valid to transform to
> > 
> >     (n * 1 * z) * 500000
> > 
> > (i.e. accumulate multiplications on the outermost factor)

(to be precise, if the multiplication is done in a signed type and the middle
constant factor was a negated power of two, the sign change needs to remain:

    a * -4 * b * 2

needs to be transformed to

    a * -1 * b * 8 )

> > so would it be possible to adjust things here to remove the innermost
> > multiplication instead?
> 
> I think I'd rather not expand this function any more, sorry.

I'd be happy to look into that myself, if the idea sounds feasible and desirable.
I've never looked at this code before, so I'd appreciate a quick yay-or-nay
before diving in.  Richard, can you share your opinion on this point?

Thanks.
Alexander



More information about the Gcc-patches mailing list