]> git.ipfire.org Git - thirdparty/gcc.git/commit
bswap: Improve perform_symbolic_merge [PR103376]
authorJakub Jelinek <jakub@redhat.com>
Thu, 25 Nov 2021 09:38:33 +0000 (10:38 +0100)
committerJakub Jelinek <jakub@redhat.com>
Thu, 25 Nov 2021 09:38:33 +0000 (10:38 +0100)
commit531dae29a67e915a145d908bd2f46d22bc369c11
tree00facf0d77fa803ed9184eae5a0e4e29d3c89d87
parent8e86218f05c1a866b43ae5af3e303f91fb6d7ff0
bswap: Improve perform_symbolic_merge [PR103376]

Thinking more about it, perhaps we could do more for BIT_XOR_EXPR.
We could allow masked1 == masked2 case for it, but would need to
do something different than the
  n->n = n1->n | n2->n;
we do on all the bytes together.
In particular, for masked1 == masked2 if masked1 != 0 (well, for 0
both variants are the same) and masked1 != 0xff we would need to
clear corresponding n->n byte instead of setting it to the input
as x ^ x = 0 (but if we don't know what x and y are, the result is
also don't know).  Now, for plus it is much harder, because not only
for non-zero operands we don't know what the result is, but it can
modify upper bytes as well.  So perhaps only if current's byte
masked1 && masked2 set the resulting byte to 0xff (unknown) iff
the byte above it is 0 and 0, and set that resulting byte to 0xff too.
Also, even for | we could instead of return NULL just set the resulting
byte to 0xff if it is different, perhaps it will be masked off later on.

This patch just punts on plus if both corresponding bytes are non-zero,
otherwise implements the above.

2021-11-25  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/103376
* gimple-ssa-store-merging.c (perform_symbolic_merge): For
BIT_IOR_EXPR, if masked1 && masked2 && masked1 != masked2, don't
punt, but set the corresponding result byte to MARKER_BYTE_UNKNOWN.
For BIT_XOR_EXPR similarly and if masked1 == masked2 and the
byte isn't MARKER_BYTE_UNKNOWN, set the corresponding result byte to
0.

* gcc.dg/optimize-bswapsi-7.c: New test.
gcc/gimple-ssa-store-merging.c
gcc/testsuite/gcc.dg/optimize-bswapsi-7.c [new file with mode: 0644]