tree-optimization/113727 - bogus SRA with BIT_FIELD_REF
commit9d6ff6f1ea2ae7fc32ec9fbd0554fb06238ed045
authorRichard Biener <rguenther@suse.de>
Tue, 19 Mar 2024 13:50:06 +0000 (19 14:50 +0100)
committerRichard Biener <rguenther@suse.de>
Thu, 21 Mar 2024 07:33:25 +0000 (21 08:33 +0100)
treeb5ddd708241bd71650d36fbd4477ec9e3273ac87
parent415091f09096a0ebba1fdcd4af8c2fda24cfd411
tree-optimization/113727 - bogus SRA with BIT_FIELD_REF

When SRA analyzes BIT_FIELD_REFs it handles writes and not byte
aligned reads differently from byte aligned reads.  Instead of
trying to create replacements for the loaded portion the former
cases try to replace the base object while keeping the wrapping
BIT_FIELD_REFs.  This breaks when we have both kinds operating
on the same base object if there's no appearant overlap conflict
as the conflict that then nevertheless exists isn't handled with.
The fix is to enforce what I think is part of the design handling
the former case - that only the full base object gets replaced
and no further sub-objects are created within as otherwise
keeping the wrapping BIT_FIELD_REF cannot work.  The patch
enforces this within analyze_access_subtree.

PR tree-optimization/113727
* tree-sra.cc (analyze_access_subtree): Do not allow
replacements in subtrees when grp_partial_lhs.

* gcc.dg/torture/pr113727.c: New testcase.
gcc/testsuite/gcc.dg/torture/pr113727.c [new file with mode: 0644]
gcc/tree-sra.cc