https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53792

Balakrishnan B <balakrishnan.erode at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |balakrishnan.erode at gmail 
dot co
                   |                            |m

--- Comment #8 from Balakrishnan B <balakrishnan.erode at gmail dot com> ---
Another testcase with c++14 extended constexpr (i.e supports loops and more
than one statement).

Code:

template<class T>
void sink(T);

constexpr unsigned foo(){
  unsigned  i = 1;
  while((i<<1) > i){
    i = i<<1;
  }
  return i;
}
template<unsigned i>
  struct Foo
        {
        };

void bar(){
  sink(foo());
  sink(Foo<foo()>{});
}

Assembly for bar: 
clang3.5.1 -O3 -std=c++14
bar():                                # @bar()
        pushq   %rax
        movl    $-2147483648, %edi      # imm = 0xFFFFFFFF80000000
        callq   void sink<unsigned int>(unsigned int)
        popq    %rax
        jmp     void sink<Foo<2147483648u> >(Foo<2147483648u>) # TAILCALL

gcc5.1.0 -O3 -std=c++14
bar():
        movl    $32, %eax
        movl    $1, %edi
        jmp     .L2
.L3:
        movl    %edx, %edi
.L2:
        subl    $1, %eax
        leal    (%rdi,%rdi), %edx
        jne     .L3
        subq    $8, %rsp
        call    void sink<unsigned int>(unsigned int)
        subq    $8, %rsp
        pushq   $0
        call    void sink<Foo<2147483648u> >(Foo<2147483648u>)
        addq    $24, %rsp
        ret

Live demo: http://goo.gl/b56Q5k

Reply via email to