[Mpi3-rma] MPI-3 UNIFIED model clarification

Jed Brown jedbrown at mcs.anl.gov
Tue Jul 30 01:03:34 CDT 2013


Pavan Balaji <balaji at mcs.anl.gov> 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,"", at progbits
$ clang -Os -c -S a.c -o -     # infinite loop at .LBB0_1
        .file   "a.c"
        .text
        .globl  foo
        .type   foo, at 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","", at progbits
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mpi-forum.org/pipermail/mpiwg-rma/attachments/20130730/b5a84891/attachment-0001.pgp>


More information about the mpiwg-rma mailing list