Bug 23985 - [3.4 regression] Memory aliasing information incorrect in inlined memcpy
Summary: [3.4 regression] Memory aliasing information incorrect in inlined memcpy
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.3
: P2 normal
Target Milestone: 3.4.5
Assignee: Richard Earnshaw
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2005-09-20 19:30 UTC by Khem Raj
Modified: 2005-10-01 13:33 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: arm-unknown-linux
Build: i686-pc-linux-gnu
Known to work:
Known to fail: 3.3.1 3.4.3 3.4.5
Last reconfirmed: 2005-09-30 10:13:03


Attachments
Failing testcase (4.85 KB, application/octet-stream)
2005-09-20 19:31 UTC, Khem Raj
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Khem Raj 2005-09-20 19:30:33 UTC
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 1 Khem Raj 2005-09-20 19:31:57 UTC
Created attachment 9782 [details]
Failing testcase
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 6 CVS Commits 2005-10-01 13:31:50 UTC
Subject: Bug 23985

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	rearnsha@gcc.gnu.org	2005-10-01 13:31:39

Modified files:
	gcc            : ChangeLog 
	gcc/config/arm : arm-protos.h arm.c arm.md 

Log message:
	PR target/23985
	Back-port 2004-08-19  Richard Henderson  <rth@redhat.com>
	* config/arm/arm.c (arm_gen_load_multiple): Use
	adjust_automodify_address.  Take base memory and offset instead
	of unchanging/struct/scalar bits.
	(arm_gen_store_multiple): Likewise.
	(arm_gen_movstrqi): Use adjust_automodify_address.
	* config/arm/arm-protos.h: Update decls.
	* config/arm/arm.md (load_multiple): Update arm_gen_load_multiple call.
	(store_multiple): Similarly.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.918&r2=2.2326.2.919
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/arm/arm-protos.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.61.4.1&r2=1.61.4.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/arm/arm.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.317.4.9&r2=1.317.4.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/arm/arm.md.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.154.4.3&r2=1.154.4.4

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