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 Andreas Schwab
Jiří Hruška writes: > #include > > __attribute__((section("foo"))) const int foo1 = 1; > __attribute__((section("foo"))) const int foo2 = 2; > __attribute__((section("foo"))) const int foo3 = 3; > > extern const int __start_foo, __stop_foo; Declare them as arrays. extern const int __start_foo[

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

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

2012-06-19 Thread Richard Guenther
On Mon, Jun 18, 2012 at 9:51 PM, Jiří Hruška wrote: > 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