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 0x7fffffffffffffff, 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 i686-linux, ok for trunk?
2016-08-16 Jakub Jelinek <ja...@redhat.com>
PR middle-end/67485
* expmed.c (expand_mult_const): Change val_so_far's type to UHWI,
only cast it to SHWI for the final comparison.
* gcc.c-torture/compile/pr67485.c: New test.
OK.
jeff