]> git.ipfire.org Git - thirdparty/gcc.git/commit
phiopt: Simplify (X & Y) == X -> (X & ~Y) == 0 even in presence of integral conversio...
authorJakub Jelinek <jakub@redhat.com>
Thu, 20 May 2021 07:10:38 +0000 (09:10 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 20 May 2021 07:10:38 +0000 (09:10 +0200)
commit2b536797f7e43c55072a3215735f5833f1d6d218
treeed90c10a928ec8e34b4937a84827804a7cf7c38a
parentd15a2d261b24adcbfe5e663b15dde3df5d2b3486
phiopt: Simplify (X & Y) == X -> (X & ~Y) == 0 even in presence of integral conversions [PR94589]

On Wed, May 19, 2021 at 10:15:53AM +0200, Christophe Lyon via Gcc-patches wrote:
> After this update, the test fails on arm and aarch64: according to the
> logs, the optimization is still performed 14 times.

Seems this is because
              if (change
                  && !flag_syntax_only
                  && (load_extend_op (TYPE_MODE (TREE_TYPE (and0)))
                      == ZERO_EXTEND))
                {
                  tree uns = unsigned_type_for (TREE_TYPE (and0));
                  and0 = fold_convert_loc (loc, uns, and0);
                  and1 = fold_convert_loc (loc, uns, and1);
                }
in fold-const.c adds on these targets extra casts that prevent the
optimizations.

2021-05-20  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/94589
* match.pd ((X & Y) == X -> (X & ~Y) == 0): Simplify even in presence
of integral conversions.
gcc/match.pd