This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/15850] New: extra load with volatilable variables


#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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]