"volatile" seems to have no effect. ReadByte should be called 4 times with results merged in a word, instead it is called once and replicated 4 times. arm-none-eabi-gcc -S -Os -mcpu=arm926ej-s src.c -O0, -O2, -O3 are fine, -O1 and -Os are bad.
Created attachment 21297 [details] Source code
Created attachment 21298 [details] Bad result
Also fine: -Os -fno-ipa-pure-const
Confirmed. I have a patch.
Subject: Bug 45052 Author: rguenth Date: Mon Jul 26 09:26:43 2010 New Revision: 162528 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162528 Log: 2010-07-26 Richard Guenther <rguenther@suse.de> PR tree-optimization/45052 * ipa-pure-const.c (check_stmt): Check volatileness. Modified: trunk/gcc/ChangeLog trunk/gcc/ipa-pure-const.c
GCC 4.5.1 is being released, adjusting target milestone.
Fixed.
Subject: Bug 45052 Author: rguenth Date: Sat Jul 31 12:12:43 2010 New Revision: 162781 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162781 Log: 2010-07-31 Richard Guenther <rguenther@suse.de> PR tree-optimization/45052 * ipa-pure-const.c (check_stmt): Check volatileness. Modified: branches/gcc-4_5-branch/gcc/ChangeLog branches/gcc-4_5-branch/gcc/ipa-pure-const.c