public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/32412] Passing struct as parameter breaks SRA for stack-allocated struct inside called function
       [not found] <bug-32412-4@http.gcc.gnu.org/bugzilla/>
@ 2012-01-19  5:31 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-19  5:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32412

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.6.0

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-19 05:12:44 UTC ---
Fixed in 4.6.0 and above.  Note you really need to mark foo as static or use
-fwhole-program to get the result you want.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/32412] Passing struct as parameter breaks SRA for stack-allocated struct inside called function
  2007-06-20  8:30 [Bug c++/32412] New: " scovich at gmail dot com
  2007-06-20 12:57 ` [Bug middle-end/32412] " pinskia at gcc dot gnu dot org
  2007-06-20 17:49 ` scovich at gmail dot com
@ 2007-06-20 18:22 ` scovich at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: scovich at gmail dot com @ 2007-06-20 18:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from scovich at gmail dot com  2007-06-20 18:22 -------
(In reply to comment #1)

Sorry for the double post, but I just tried creating a wrapper_foo() that
copies the values out of the struct, then passes them on to foo() as scalars.
The problem only appears if foo() gets inlined into wrapper_foo().


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32412


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/32412] Passing struct as parameter breaks SRA for stack-allocated struct inside called function
  2007-06-20  8:30 [Bug c++/32412] New: " scovich at gmail dot com
  2007-06-20 12:57 ` [Bug middle-end/32412] " pinskia at gcc dot gnu dot org
@ 2007-06-20 17:49 ` scovich at gmail dot com
  2007-06-20 18:22 ` scovich at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: scovich at gmail dot com @ 2007-06-20 17:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from scovich at gmail dot com  2007-06-20 17:49 -------
(In reply to comment #1)
> wrapper const &w
> 
> You are passing via reference which does not break SRA, just changes the ABI
> and such.
> 
> This is a very very hard problem to solve without the whole program.
> 
> I wondering if I should close it as won't fix.
> 

I'm not convinced the ABI change by itself is the culprit:
1. Passing w by value gives the same result. Granted, passing a struct at all
changes the ABI, but the const ref part isn't an issue, at least.
2. You have to actually use the wrapper's 'entries' pointer for the problem to
appear (diff for modified test case below).
3. The problem goes away if you convert Action16 to use scalars instead of
arrays, so SRA for structs is unaffected. 

Why does passing a pointer inside a struct on the stack instead of passing it
in a register suddenly require the whole program to analyze properly? There's
no way stack-allocated arrays can alias with arrays passed into the function. I
would have expected a few extra instructions in the function prologue to load
the values into registers, followed by business as usual. 

$ diff sra-bug.C.orig sra-bug.C
==============================================================
51a52,54
> void foo(__m128i* dest, uint64_t const* values,
>        __m128i const* _entries, int _count, wrapper w)
> {
53d55
< void foo(__m128i* dest, uint64_t const* values, wrapper const &w) {
56c58
< void foo(__m128i* dest, uint64_t const* values, __m128i const* entries, int
co
unt) {
---
>   __m128i const* entries = _entries; int count = _count;
75,79c77
< #ifdef TRIGGER_BUG
<       foo(dest+i, values+i, w);
< #else
<       foo(dest+i, values+i, entries, LIST_SIZE);
< #endif
---
>       foo(dest+i, values+i, entries, LIST_SIZE, w);


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32412


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/32412] Passing struct as parameter breaks SRA for stack-allocated struct inside called function
  2007-06-20  8:30 [Bug c++/32412] New: " scovich at gmail dot com
@ 2007-06-20 12:57 ` pinskia at gcc dot gnu dot org
  2007-06-20 17:49 ` scovich at gmail dot com
  2007-06-20 18:22 ` scovich at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-06-20 12:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-06-20 12:57 -------
wrapper const &w

You are passing via reference which does not break SRA, just changes the ABI
and such.

This is a very very hard problem to solve without the whole program.

I wondering if I should close it as won't fix.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |middle-end


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32412


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-19  5:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-32412-4@http.gcc.gnu.org/bugzilla/>
2012-01-19  5:31 ` [Bug middle-end/32412] Passing struct as parameter breaks SRA for stack-allocated struct inside called function pinskia at gcc dot gnu.org
2007-06-20  8:30 [Bug c++/32412] New: " scovich at gmail dot com
2007-06-20 12:57 ` [Bug middle-end/32412] " pinskia at gcc dot gnu dot org
2007-06-20 17:49 ` scovich at gmail dot com
2007-06-20 18:22 ` scovich at gmail dot com

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).