From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21582 invoked by alias); 27 May 2003 08:54:06 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 15777 invoked by uid 48); 27 May 2003 08:51:20 -0000 Date: Tue, 27 May 2003 09:08:00 -0000 From: "rgrosseboerger@dspace.de" To: gcc-bugs@gcc.gnu.org Message-ID: <20030527085118.10992.rgrosseboerger@dspace.de> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug optimization/10992] New: invalid instruction reordering with -O2 / -fschedule-insns2 X-Bugzilla-Reason: CC X-SW-Source: 2003-05/txt/msg03221.txt.bz2 List-Id: PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10992 Summary: invalid instruction reordering with -O2 / -fschedule- insns2 Product: gcc Version: 3.2.1 Status: UNCONFIRMED Severity: major Priority: P2 Component: optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: rgrosseboerger@dspace.de CC: gcc-bugs@gcc.gnu.org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu GCC 3.2.x and 3.3 generate incorrect code for the simple test case below. The problems occurs, if the C code is compiled with -O2, but does not occur at -O1 or "-O2 -fno-schedule-insns2" (->GCC does invalid instruction reordering ?). The problem disappears, if uint_value is declared as volatile. The correct output for the test program is : uint_value : 00570047 , value 00570047 ... uint_value : 006B005B , value 006B005B Whereas the miscompilation with -O2 gives : uint_value : 00570047 , value BFFFF8E8 ... uint_value : 006B005B , value 00660056 I have the same problem on gcc/x86-64, but the code works OK with the Intel compiler. #include typedef unsigned int UInt32; typedef unsigned int UInt16; typedef float Float32; float f_array[25]; UInt32 u32_array[25]; int j = 5; inline void func(UInt32 count, UInt32* address, volatile Float32* float_value) { unsigned int i; UInt16 value_low = 0x42; UInt16 value_high = 0x52; /*volatile*/ UInt32 uint_value; for (i = 0; i < count; i++) { value_high = value_high +5; value_low = value_low +5; uint_value = (((UInt32)value_high) << 16); uint_value |= value_low; float_value[i] = *((volatile float*)(&uint_value)); printf(" uint_value : %08X , value %08X \n", uint_value, *((UInt32 *) &(float_value[i]))); } } int main() { func( j, u32_array , f_array); } ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.