Re: [PATCH] match.pd: Canonicalize (X + (X >> (prec - 1))) ^ (X >> (prec - 1)) to abs (X) [PR94783]

2020-05-07 Thread Jeff Law via Gcc-patches
On Thu, 2020-05-07 at 10:12 +0200, Richard Biener wrote: > On Thu, 7 May 2020, Jakub Jelinek wrote: > > > Hi! > > > > The following patch canonicalizes M = X >> (prec - 1); (X + M) ^ M > > for signed integral types into ABS_EXPR (X). For X == min it is already > > UB because M is -1 and min + -1

Re: [PATCH] match.pd: Canonicalize (X + (X >> (prec - 1))) ^ (X >> (prec - 1)) to abs (X) [PR94783]

2020-05-07 Thread Richard Biener
On Thu, 7 May 2020, Jakub Jelinek wrote: > Hi! > > The following patch canonicalizes M = X >> (prec - 1); (X + M) ^ M > for signed integral types into ABS_EXPR (X). For X == min it is already > UB because M is -1 and min + -1 is UB, so we can use ABS_EXPR rather than > say ABSU_EXPR + cast. > >

[PATCH] match.pd: Canonicalize (X + (X >> (prec - 1))) ^ (X >> (prec - 1)) to abs (X) [PR94783]

2020-05-07 Thread Jakub Jelinek via Gcc-patches
Hi! The following patch canonicalizes M = X >> (prec - 1); (X + M) ^ M for signed integral types into ABS_EXPR (X). For X == min it is already UB because M is -1 and min + -1 is UB, so we can use ABS_EXPR rather than say ABSU_EXPR + cast. The backend might then emit the abs code back using the s