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

Reply via email to