Re: [Mpi3-rma] MPI-3 UNIFIED model clarification
Pavan Balaji <[email protected]> writes:
Of course, while(flag) will be optimized away by a lot of compilers without some magic annotation that would prevent the read from crossing it...
I can't get any compiler to optimize it away.
What did you try? Gcc and clang both elide the conditional from the loop body. a.c: extern void bar(int*); int foo() { int flag; bar(&flag); while (flag); return 1; } $ gcc -Os -c -S a.c -o - # infinite loop at .L4 .file "a.c" .text .globl foo .type foo, @function foo: .LFB0: .cfi_startproc subq $24, %rsp .cfi_def_cfa_offset 32 leaq 12(%rsp), %rdi call bar cmpl $0, 12(%rsp) je .L5 .L4: jmp .L4 .L5: movl $1, %eax addq $24, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE0: .size foo, .-foo .ident "GCC: (GNU) 4.8.1" .section .note.GNU-stack,"",@progbits $ clang -Os -c -S a.c -o - # infinite loop at .LBB0_1 .file "a.c" .text .globl foo .type foo,@function foo: # @foo .cfi_startproc # BB#0: pushq %rax .Ltmp1: .cfi_def_cfa_offset 16 leaq 4(%rsp), %rdi callq bar cmpl $0, 4(%rsp) je .LBB0_2 .LBB0_1: # %..split_crit_edge # =>This Inner Loop Header: Depth=1 jmp .LBB0_1 .LBB0_2: # %.split1 movl $1, %eax popq %rdx ret .Ltmp2: .size foo, .Ltmp2-foo .cfi_endproc .section ".note.GNU-stack","",@progbits
participants (1)
-
Jed Brown