Bug 12598 - Invalid size optimization on volatile memory reference
Summary: Invalid size optimization on volatile memory reference
Status: CLOSED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.0
: P3 critical
Target Milestone: 3.3.3
Assignee: Hans-Peter Nilsson
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2003-10-13 14:14 UTC by Hans-Peter Nilsson
Modified: 2005-07-23 22:46 UTC (History)
2 users (show)

See Also:
Host: Any, supposedly
Target: cris-*
Build: Any, supposedly
Known to work:
Known to fail:
Last reconfirmed: 2003-10-13 14:26:10


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hans-Peter Nilsson 2003-10-13 14:14:02 UTC
Compile with e.g. -O2, the following code:

static const unsigned long c = 0x0000FF00;
unsigned long
a1 (void)
{
  unsigned long m;
  m = *(volatile unsigned long*) 0xb00000c8;
  m &= c;
  return m;
}

Note the memory reference is done as a 16-bit, not 32-bit access;
specifically a "movu.w".
Comment 1 Hans-Peter Nilsson 2003-10-13 14:30:41 UTC
Also in at least 3.2 and 3.3.  Note that the peephole patterns
exclude volatile refs; the volatile flag seems to be scrubbed
off at an earlier pass.
Comment 2 GCC Commits 2003-10-15 14:03:18 UTC
Subject: Bug 12598

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	hp@gcc.gnu.org	2003-10-15 14:03:16

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg/torture: cris-volatile-1.c 

Log message:
	PR target/12598
	* gcc.dg/torture/cris-volatile-1.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3123&r2=1.3124
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/torture/cris-volatile-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 3 GCC Commits 2003-10-15 14:08:00 UTC
Subject: Bug 12598

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	hp@gcc.gnu.org	2003-10-15 14:07:57

Modified files:
	gcc            : ChangeLog 
	gcc/config/cris: cris.md cris.h cris.c 

Log message:
	PR target/12598
	* config/cris/cris.md (define_split "*mov_sidesi_biap_mem"+1)
	(define_splits "*mov_sidesi_mem"+1, "casesi"+9, +10, +11, +12):
	Use cris_mem_op and replace_equiv_address, not gen_rtx_MEM.
	("call", "call_value", define_split "*mov_sidesi_mem"+19, +20)
	(define_split "*mov_sidesi_mem"+21, +22, +23, +24, +25, +26, +27)
	(define_split "*mov_sidesi_mem"+28, +29, +30): Use
	replace_equiv_address, not gen_rtx_MEM.
	* config/cris/cris.c (cris_mem_op): New match_operator function.
	* config/cris/cris.h (PREDICATE_CODES): Add cris_mem_op.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1422&r2=2.1423
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/cris/cris.md.diff?cvsroot=gcc&r1=1.9&r2=1.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/cris/cris.h.diff?cvsroot=gcc&r1=1.57&r2=1.58
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/cris/cris.c.diff?cvsroot=gcc&r1=1.45&r2=1.46

Comment 4 Hans-Peter Nilsson 2003-10-15 14:34:15 UTC
.
Comment 5 Hans-Peter Nilsson 2003-10-15 14:35:03 UTC
.
Comment 6 Hans-Peter Nilsson 2003-10-15 14:38:53 UTC
See <URL:http://gcc.gnu.org/ml/gcc-patches/2003-10/msg01214.html> for more.
Comment 7 GCC Commits 2003-12-12 13:48:41 UTC
Subject: Bug 12598

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	hp@gcc.gnu.org	2003-12-12 13:48:38

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg/torture: cris-volatile-1.c dg-torture.exp 
	gcc/testsuite/gcc.c-torture/execute: 20031201-1.c 

Log message:
	PR target/13256
	PR target/12598
	Backport from mainline:
	* gcc.dg/torture/dg-torture.exp: New directory.  New file.
	* gcc.dg/torture/cris-volatile-1.c: New test.
	* gcc.c-torture/execute/20031201-1.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.332&r2=1.2261.2.333
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/torture/cris-volatile-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.12.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/torture/dg-torture.exp.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.20.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20031201-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.4.1

Comment 8 GCC Commits 2003-12-12 13:58:05 UTC
Subject: Bug 12598

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	hp@gcc.gnu.org	2003-12-12 13:58:02

Modified files:
	gcc            : ChangeLog 
	gcc/config/cris: cris.md cris.c cris.h 

Log message:
	PR target/12598
	Backport from mainline:
	* config/cris/cris.md (define_split "*mov_sidesi_biap_mem"+1)
	(define_splits "*mov_sidesi_mem"+1, "casesi"+9, +10, +11, +12):
	Use cris_mem_op and replace_equiv_address, not gen_rtx_MEM.
	("call", "call_value", define_split "*mov_sidesi_mem"+19, +20)
	(define_split "*mov_sidesi_mem"+21, +22, +23, +24, +25, +26, +27)
	(define_split "*mov_sidesi_mem"+28, +29, +30): Use
	replace_equiv_address, not gen_rtx_MEM.
	* config/cris/cris.c (cris_mem_op): New match_operator function.
	(cris_notice_update_cc): Use replace_equiv_address, not
	gen_rtx_MEM.
	* config/cris/cris.h (PREDICATE_CODES): Add cris_mem_op.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.839&r2=1.16114.2.840
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/cris/cris.md.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.6.4.2&r2=1.6.4.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/cris/cris.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.32.4.1&r2=1.32.4.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/cris/cris.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.42.4.2&r2=1.42.4.3