[llvm-bugs] [Bug 36730] New: __builtin_constant_p does not work on powerpc

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 14 07:48:03 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=36730

            Bug ID: 36730
           Summary: __builtin_constant_p does not work on powerpc
           Product: libraries
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: nruslan_devel at yahoo.com
                CC: llvm-bugs at lists.llvm.org

Found that at least for 64-bit and 128-bit types, clang/llvm does not seem to
detect that the specified value is a constant (PPC64 target).

(GCC seems to work fine for both types.)

Example:

static inline unsigned char func1(__uint128_t a)
{
        if (__builtin_constant_p(a)) {
                return 1;
        }
        return 0;
}

unsigned char test_func1()
{
        return func1(0);
}

static inline unsigned char func2(unsigned long long a)
{
        if (__builtin_constant_p(a)) {
                return 1;
        }
        return 0;
}

unsigned char test_func2()
{
        return func2(0);
}


Generated code:
(clang -Wall -O2 -target powerpc64-linux-gnu -S test.c)

test_func1:                             # @test_func1
        .p2align        3
        .quad   .Lfunc_begin0
        .quad   .TOC. at tocbase
        .quad   0
        .text
.Lfunc_begin0:
# %bb.0:
        li 3, 0
        blr

...


test_func2:                             # @test_func2
        .p2align        3
        .quad   .Lfunc_begin1
        .quad   .TOC. at tocbase
        .quad   0
        .text
.Lfunc_begin1:
# %bb.0:
        li 3, 0
        blr

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180314/63417471/attachment.html>


More information about the llvm-bugs mailing list