Re: [PATCH] Fix UB in expand_mult_const (PR middle-end/67485)

2016-08-16 Thread Jeff Law
On 08/16/2016 09:57 AM, Jakub Jelinek wrote: Hi! When val_so_far is signed, we can end up in UB in various places, e.g. for the multiplication by 0x7fff, which is done as << 63 shift followed by subtracting one. Fixed by computing this in UHWI instead, and only cast at the end to SH

[PATCH] Fix UB in expand_mult_const (PR middle-end/67485)

2016-08-16 Thread Jakub Jelinek
Hi! When val_so_far is signed, we can end up in UB in various places, e.g. for the multiplication by 0x7fff, which is done as << 63 shift followed by subtracting one. Fixed by computing this in UHWI instead, and only cast at the end to SHWI. Bootstrapped/regtested on x86_64-linux and