This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/15850] New: extra load with volatilable variables
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Jun 2004 15:12:33 -0000
- Subject: [Bug c/15850] New: extra load with volatilable variables
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
#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