On Tue, Sep 13, 2022 at 8:37 PM Roger Sayle <ro...@nextmovesoftware.com> wrote:
>
>
> This patch tweaks the match.pd transformation previously added to fold
> (X<<C)+(Y<<C) as (X+Y)<<C that was previously restricted to unsigned
> (wrapping) types, to also allow signed integer types provided that they
> don't trap and the overflow needn't be preserved for sanitization.
> i.e. this should now apply (by default) for "int x,y;", but is disabled
> with -ftrapv.
>
> This unsigned transformation has baked on mainline without problems, so it's
> time to turn up the heat...  LLVM, icc and MSVC perform this optimization.
>
>
> This patch has been tested on x86_64-pc-linux-gnu with make bootstrap and
> make -k check, both with and without --target_board=unix{-m32}, with no
> new failures.  Ok for mainline?

OK.

Thanks,
Richard.

>
>
> 2022-09-13  Roger Sayle  <ro...@nextmovesoftware.com>
>
> gcc/ChangeLog
>         * match.pd (op (lshift @0 @1) (lshift @2 @1)): Optimize the
>         expression (X<<C) + (Y<<C) to (X+Y)<<C for signed types, that
>         may have undefined overflow, provided that they don't trap.
>
> gcc/testsuite/ChangeLog
>         * gcc.dg/pr71343-3.c: New test case.
>
>
> Thanks in advance,
> Roger
> --
>

Reply via email to