23985 – [3.4 regression] Memory aliasing information incorrect in inlined memcpy (original) (raw)

GCC 3.4.3 and 3.4.4 generated wrong code at -O2 and -Os opt level for the attached testcase. If I user -O1 the test case works fine.

Secondly it also works fine if I specify -O2 -fno-if-convertion2

Thirdly If I comment out

newinfo->fig->shape = *&shape;

line in the testcase it works fine agains.

The testcase can be compile and linked and runtime outputs should match

correct output should be 1 alpha.style = 1 correct output should be 2 alpha.style = 2

in wrong code case. It prints.

correct output should be 1 alpha.style = 254 correct output should be 2 alpha.style = 2

The testcase works fine with GCC 4.0 and CVS Trunk GCC

Comment 2 Khem Raj 2005-09-20 19:37:17 UTC

It fails on GCC 3.3.1 similarily.

Comment 3 Richard Earnshaw 2005-09-30 10:13:02 UTC

Confirmed by visual inspection of the assembly code.

What seems to be happening is this:

After if conversion we have (pseudo code)

a ? alpha.style = 1 a ? ... !a ? alpha.style = 2 !a ? ...

inlined_memcpy(newinfo->fig->alpha, alpha, sizeof (alpha)

and this is transformed by the scheduler into

a ? alpha.style = 1 a ? ... !a ? ... inlined_memcpy(newinfo->fig->alpha, alpha, sizeof (alpha)) !a ? alpha.style = 2

That is, alpha.style is only set to 2 after alpha has been copied elsewhere.

Disabling sched-2 also avoids the problem.

Comment 4 Richard Earnshaw 2005-09-30 10:58:10 UTC

testing a fix

Comment 5 Richard Earnshaw 2005-09-30 10:59:18 UTC

This is a bug in the arm backend.

Comment 7 Richard Earnshaw 2005-10-01 13:33:37 UTC

Fixed.