Re: [PATCH v2] tree-optimization/94899: Remove "+ 0x80000000" in int comparisons

2022-02-04 Thread Richard Biener via Gcc-patches
On Fri, Feb 4, 2022 at 12:50 PM Jakub Jelinek wrote: > > On Fri, Feb 04, 2022 at 12:14:33PM +0100, Richard Biener via Gcc-patches > wrote: > > +#define MAGIC 0x8000 > > > > I _think_ writing the constant this way requires > > Perhaps use (~(uint32_t)0 / 2 + 1) as MAGIC instead? > Then it does

Re: [PATCH v2] tree-optimization/94899: Remove "+ 0x80000000" in int comparisons

2022-02-04 Thread Jakub Jelinek via Gcc-patches
On Fri, Feb 04, 2022 at 12:14:33PM +0100, Richard Biener via Gcc-patches wrote: > +#define MAGIC 0x8000 > > I _think_ writing the constant this way requires Perhaps use (~(uint32_t)0 / 2 + 1) as MAGIC instead? Then it doesn't actually require that uint32_t actually is exactly 32 bits. On the

Re: [PATCH v2] tree-optimization/94899: Remove "+ 0x80000000" in int comparisons

2022-02-04 Thread Richard Biener via Gcc-patches
On Thu, Feb 3, 2022 at 4:50 AM Arjun Shankar wrote: > > Expressions of the form "X + CST < Y + CST" where: > > * CST is an unsigned integer constant with only the MSB set, and > * X and Y's types have integer conversion ranks <= CST's > > can be simplified to "(signed) X < (signed) Y". > > This is

[PATCH v2] tree-optimization/94899: Remove "+ 0x80000000" in int comparisons

2022-02-02 Thread Arjun Shankar via Gcc-patches
Expressions of the form "X + CST < Y + CST" where: * CST is an unsigned integer constant with only the MSB set, and * X and Y's types have integer conversion ranks <= CST's can be simplified to "(signed) X < (signed) Y". This is because, assuming a 32-bit signed numbers, (unsigned) INT_MIN + 0x8