]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix wrong SRA with VIEW_CONVERT_EXPR and reverse SSO
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 13 May 2022 09:15:08 +0000 (11:15 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Fri, 13 May 2022 09:20:04 +0000 (11:20 +0200)
commitf8598704c0bc75a98e0b4a66ebd36f72bfa75334
tree02abbe974204bdaa5e7d14344844b3cda4db2736
parente628690d6333f0cc4d338cd8b796408f35e07ced
Fix wrong SRA with VIEW_CONVERT_EXPR and reverse SSO

Most cases of VIEW_CONVERT_EXPRs involving reverse scalar storage order are
disqualified for SRA because they are storage_order_barrier_p, but you can
still have a VIEW_CONVERT_EXPR to a regular composite type being applied to
a component of a record type with reverse scalar storage order.

In this case the bypass for !useless_type_conversion_p in sra_modify_assign,
albeit already heavily guarded, triggers and may generate wrong code, so the
patch makes sure that it does only when the SSO is the same on both side.

gcc/
* tree-sra.cc (sra_modify_assign): Check that scalar storage order
is the same on the LHS and RHS before rewriting one with the model
of the other.
gcc/testsuite/
* gnat.dg/sso17.adb: New test.
gcc/testsuite/gnat.dg/sso17.adb [new file with mode: 0644]
gcc/tree-sra.cc