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

2017-05-24 Thread Richard Biener
On Fri, 19 May 2017, Alexander Monakov wrote: > 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 ne

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

2017-05-19 Thread Alexander Monakov
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

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

2017-05-19 Thread Joseph Myers
On Fri, 19 May 2017, Alexander Monakov wrote: > 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) * 50 > > > > > > (i.e. accumulate multiplications on the outermost factor) > >

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

2017-05-19 Thread Richard Biener
On May 19, 2017 5:47:10 PM GMT+02:00, Alexander Monakov wrote: >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) * 50 >> > >> > (i.e. accumulate multiplications on the outermost factor)

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

2017-05-19 Thread Alexander Monakov
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) * 50 > > > > (i.e. accumulate multiplications on the outermost factor) (to be precise, if the multiplication is done in a signed type an

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

2017-05-19 Thread Marek Polacek
On Fri, May 19, 2017 at 01:57:24PM +0300, Alexander Monakov wrote: > On Fri, 19 May 2017, Richard Biener wrote: > > > On Fri, 19 May 2017, Marek Polacek wrote: > > > > > On Fri, May 19, 2017 at 09:58:45AM +0200, Richard Biener wrote: > > > > On Fri, 19 May 2017, Marek Polacek wrote: > > > > > >

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

2017-05-19 Thread Alexander Monakov
On Fri, 19 May 2017, Richard Biener wrote: > On Fri, 19 May 2017, Marek Polacek wrote: > > > On Fri, May 19, 2017 at 09:58:45AM +0200, Richard Biener wrote: > > > On Fri, 19 May 2017, Marek Polacek wrote: > > > > > > > extract_muldiv folds > > > > > > > > (n * 1 * z) * 50 > > > > > > >

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

2017-05-19 Thread Richard Biener
On Fri, 19 May 2017, Marek Polacek wrote: > On Fri, May 19, 2017 at 09:58:45AM +0200, Richard Biener wrote: > > On Fri, 19 May 2017, Marek Polacek wrote: > > > > > extract_muldiv folds > > > > > > (n * 1 * z) * 50 > > > > > > to > > > > > > (n * 50) * z > > > > > > which is a wro

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

2017-05-19 Thread Marek Polacek
On Fri, May 19, 2017 at 09:58:45AM +0200, Richard Biener wrote: > On Fri, 19 May 2017, Marek Polacek wrote: > > > extract_muldiv folds > > > > (n * 1 * z) * 50 > > > > to > > > > (n * 50) * z > > > > which is a wrong transformation to do, because it may introduce an overflow. > >

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

2017-05-19 Thread Richard Biener
On Fri, 19 May 2017, Marek Polacek wrote: > extract_muldiv folds > > (n * 1 * z) * 50 > > to > > (n * 50) * z > > which is a wrong transformation to do, because it may introduce an overflow. > This resulted in a ubsan false positive. So we should just disable this > folding altog

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

2017-05-18 Thread Marek Polacek
extract_muldiv folds (n * 1 * z) * 50 to (n * 50) * z which is a wrong transformation to do, because it may introduce an overflow. This resulted in a ubsan false positive. So we should just disable this folding altogether. Does the approach I took make sense? Bootstrapped/regtes