From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5819 invoked by alias); 6 May 2015 15:03:55 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 125681 invoked by uid 48); 6 May 2015 15:03:47 -0000 From: "balakrishnan.erode at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/53792] [C++11] improving compiler-time constexpr evaluation Date: Wed, 06 May 2015 15:03:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: balakrishnan.erode at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-05/txt/msg00494.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53792 Balakrishnan B changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |balakrishnan.erode at gmail dot co | |m --- Comment #8 from Balakrishnan B --- Another testcase with c++14 extended constexpr (i.e supports loops and more than one statement). Code: template void sink(T); constexpr unsigned foo(){ unsigned i = 1; while((i<<1) > i){ i = i<<1; } return i; } template struct Foo { }; void bar(){ sink(foo()); sink(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) popq %rax jmp void sink >(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) subq $8, %rsp pushq $0 call void sink >(Foo<2147483648u>) addq $24, %rsp ret Live demo: http://goo.gl/b56Q5k