* Fix PR tree-optimization/101626
@ 2021-08-05 8:25 Eric Botcazou
0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2021-08-05 8:25 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 529 bytes --]
This is a regression present on the mainline, caused by an oversight of mine
in an earlier fix for SRA, whereby I forgot to exclude cases for reverse SSO.
Tested on x86-64/Linux, applied on the mainline as obvious.
2021-08-05 Eric Botcazuo <ebotcazou@adacore.com>
PR tree-optimization/101626
* tree-sra.c (propagate_subaccesses_from_rhs): Do not set the
reverse scalar storage order on a pointer or vector component.
2021-08-05 Eric Botcazuo <ebotcazou@adacore.com>
* gcc.dg/sso-15.c: New test.
--
Eric Botcazou
[-- Attachment #2: pr101626.diff --]
[-- Type: text/x-patch, Size: 642 bytes --]
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index c05d22f3e8f..3a9e14f50a0 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -2790,7 +2790,10 @@ propagate_subaccesses_from_rhs (struct access *lacc, struct access *racc)
{
/* We are about to change the access type from aggregate to scalar,
so we need to put the reverse flag onto the access, if any. */
- const bool reverse = TYPE_REVERSE_STORAGE_ORDER (lacc->type);
+ const bool reverse
+ = TYPE_REVERSE_STORAGE_ORDER (lacc->type)
+ && !POINTER_TYPE_P (racc->type)
+ && !VECTOR_TYPE_P (racc->type);
tree t = lacc->base;
lacc->type = racc->type;
[-- Attachment #3: sso-15.c --]
[-- Type: text/x-csrc, Size: 587 bytes --]
/* { dg-do compile } */
/* { dg-options "-O2" } */
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define REV_ENDIANNESS __attribute__((scalar_storage_order("big-endian")))
#else
#define REV_ENDIANNESS __attribute__((scalar_storage_order("little-endian")))
#endif
struct X { int *p; } REV_ENDIANNESS;
struct X x;
struct X __attribute__((noinline)) foo (int *p)
{
struct X x;
x.p = p;
return x;
}
void __attribute((noinline)) bar (void)
{
*x.p = 1;
}
extern void abort (void);
int main (void)
{
int i = 0;
x = foo(&i);
bar();
if (i != 1)
abort ();
return 0;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-08-05 8:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-05 8:25 Fix PR tree-optimization/101626 Eric Botcazou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).