]> git.ipfire.org Git - thirdparty/gcc.git/commit
ssa: Fix up maybe_rewrite_mem_ref_base complex type handling [PR116034]
authorJakub Jelinek <jakub@redhat.com>
Tue, 23 Jul 2024 08:50:29 +0000 (10:50 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 13 Jun 2025 09:01:16 +0000 (11:01 +0200)
commitaa586d79f653e1ed43e7d83c8b2fc969fbb7df63
treee915c151905bf2f660b6802856b4dc9e2dbe04ef
parent45a1901763c03ef13d5906f9ce25ab69d7e840d0
ssa: Fix up maybe_rewrite_mem_ref_base complex type handling [PR116034]

The folding into REALPART_EXPR is correct, used only when the mem_offset
is zero, but for IMAGPART_EXPR it didn't check the exact offset value (just
that it is not 0).
The following patch fixes that by using IMAGPART_EXPR only if the offset
is right and using BITFIELD_REF or whatever else otherwise.

2024-07-23  Jakub Jelinek  <jakub@redhat.com>
    Andrew Pinski  <quic_apinski@quicinc.com>

PR tree-optimization/116034
* tree-ssa.cc (maybe_rewrite_mem_ref_base): Only use IMAGPART_EXPR
if MEM_REF offset is equal to element type size.

* gcc.dg/pr116034.c: New test.

(cherry picked from commit b9cefd67a2a464a3c9413e6b3f28e7dc7a9ef162)
gcc/testsuite/gcc.dg/pr116034.c [new file with mode: 0644]
gcc/tree-ssa.cc