Re: [PATCH] Fix UB in prepare_cmp_insn (PR middle-end/89281)

2019-02-13 Thread Eric Botcazou
> The code will do: > size = convert_to_mode (cmp_mode, size, 1); > i.e. convert size from whatever mode it had before to cmp_mode and the > test is whether it can do so without changing the behavior. If size is > non-constant, then that can be obviously (without using range info etc.) >

Re: [PATCH] Fix UB in prepare_cmp_insn (PR middle-end/89281)

2019-02-12 Thread Jakub Jelinek
On Wed, Feb 13, 2019 at 12:51:26AM +0100, Eric Botcazou wrote: > > The following hunk of code results in UB on the recently added testcase, > > because if cmp_mode is SImode or DImode, then 1 << 32 or 1 << 64 is > > undefined. Fixed by using GET_MODE_MASK, plus UINTVAL because size is > > really u

Re: [PATCH] Fix UB in prepare_cmp_insn (PR middle-end/89281)

2019-02-12 Thread Eric Botcazou
> The following hunk of code results in UB on the recently added testcase, > because if cmp_mode is SImode or DImode, then 1 << 32 or 1 << 64 is > undefined. Fixed by using GET_MODE_MASK, plus UINTVAL because size is > really unsigned (code later on uses unsignedp=1 too). Doesn't the current chec

[PATCH] Fix UB in prepare_cmp_insn (PR middle-end/89281)

2019-02-12 Thread Jakub Jelinek
Hi! The following hunk of code results in UB on the recently added testcase, because if cmp_mode is SImode or DImode, then 1 << 32 or 1 << 64 is undefined. Fixed by using GET_MODE_MASK, plus UINTVAL because size is really unsigned (code later on uses unsignedp=1 too). Bootstrapped/regtested on x