[Bug c/15850] New: extra load with volatilable variables
pinskia at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Sun Jun 6 15:12:00 GMT 2004
#include <stdio.h>
volatile int v1 = 0;
volatile int v2 = 1;
int main() {
if(v1 = v2) {
printf("v1 = v2\n");
}
}
This generates the following code sequence:
movl v2, %eax
movl %eax, v1
movl v1, %eax
testl %eax, %eax
je .L2
or the tree version:
v2.0 = v2;
v1 = v2.0;
v1.1 = v1;
if (v1.1 != 0)
Which is obvoiusly wrong as it is storing and then loading back from v1 which is wrong for volatile
variables
--
Summary: extra load with volatilable variables
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15850
More information about the Gcc-bugs
mailing list