Re: [PATCH] Bad code generation: incorrect folding of TARGET_MEM_REF into a constant

2012-06-19 Thread Jiří Hruška
On Tue, Jun 19, 2012 at 8:59 PM, Andreas Schwab wrote: > Declare them as arrays. > extern const int __start_foo[], __stop_foo[]; Thanks, that's a good suggestion, cleans the code nicely! (Though, of course, both ways work here and the strange things happen only in the 3rd testcase, which does not

Re: [PATCH] Bad code generation: incorrect folding of TARGET_MEM_REF into a constant

2012-06-19 Thread Jiří Hruška
On Tue, Jun 19, 2012 at 10:54 AM, Richard Guenther wrote: > The issue is that your testcase is invalid. >    int x = ret(*(&fooS + i)); > this access is only ever valid for i == 0 as otherwise you are creating > a pointer that points outside of the object fooS. Richard, thanks for your reply. T

[PATCH] Bad code generation: incorrect folding of TARGET_MEM_REF into a constant

2012-06-18 Thread Jiří Hruška
Hi all, I have tracked down a bug which results in invalid code being generated for indexed TARGET_MEM_REF expressions during dominator optimization. The conditions are: accessing objects adjacent in memory in a loop (in order to generate the TARGET_MEM_REF gimple) and optimizing this tree item d