It looks like bug #34020 (reported against IPF Fortran) is also happening with Intel64 Fortran logical ops. The lhs operand is not reloaded if the cmpxchg fails.
Testcase: SUBROUTINE test(lhs, rhs) LOGICAL lhs, rhs !$omp atomic lhs = lhs .or. rhs END % gfortran -fopenmp test.f -S fxedlin09 % head -47 test.s .file "test.f" .text .globl test_ .type test_, @function test_: .LFB2: pushq %rbp .LCFI0: movq %rsp, %rbp .LCFI1: pushq %rbx .LCFI2: movq %rdi, -16(%rbp) movq %rsi, -24(%rbp) movq -24(%rbp), %rax movl (%rax), %eax ; load lhs movl %eax, -28(%rbp) movq -16(%rbp), %rax movl (%rax), %eax ; load rhs testl %eax, %eax jne .L2 cmpl $0, -28(%rbp) je .L3 .L2: movl $1, -32(%rbp) jmp .L4 .L3: movl $0, -32(%rbp) .L4: movq -16(%rbp), %rax movl (%rax), %eax movl %eax, -36(%rbp) .L5: movq -16(%rbp), %rax movq %rax, -48(%rbp) movq -48(%rbp), %rcx movl -36(%rbp), %eax movl -32(%rbp), %ebx lock cmpxchgl %ebx, (%rcx) movl %eax, %edx movl -36(%rbp), %eax movl %edx, -36(%rbp) cmpl %eax, %edx jne .L5 ; need to jump to .LCFI2, not .L5 popq %rbx leave ret gfortran version info: version 4.3.3 20090119 (prerelease) [gcc-4_3-branch revision 143496]. -- Summary: bad codegen for openmp atomics (Intel64 Fortran logical ops) Product: gcc Version: 4.3.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: brian dot e dot bliss at intel dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39354