This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Prevent extract_muldiv from introducing an overflow (PR sanitizer/80800)
On Fri, 19 May 2017, Joseph Myers wrote:
> On Fri, 19 May 2017, Alexander Monakov wrote:
> > (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 )
>
> Shouldn't that only be the case if the middle constant was -1 and the
> outer constant was 1? If a * -4 * b is INT_MIN, a * b won't overflow and
> so a * b * -8 should be a safe transformation.
Indeed, I should have considered the situation more carefully. Thank you for
the correction.
Alexander