[llvm-bugs] [Bug 28674] New: Failure to re-use immediate shared between compare and subtract

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jul 22 14:23:55 PDT 2016


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

            Bug ID: 28674
           Summary: Failure to re-use immediate shared between compare and
                    subtract
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: simon.hosie at arm.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Given:

    uint32_t f(uint32_t x) { x++; return x < 4000569407 ? x : x - 4000569407; }

Compiling with:

    clang --target=arm-linux-gnueabihf -O3 -S -o- p1modk.c

I get:

        ldr     r2, .LCPI2_0  // =294397890
        ldr     r3, .LCPI2_1  // =4000569407
        add     r1, r0, #1
        cmp     r1, r3
        addhs   r1, r0, r2
        mov     r0, r1

I expect:

        ldr     r1, .LCPI2_1  // =4000569407
        add     r0, r0, #1
        cmp     r0, r1
        subhs   r0, r0, r1

Or possibly (unless I made a mistake):

        ldr     r1, .LCPI2_1  // =(4000569407 - 1)
        subs    r1, r0, r1
        addlo   r1, r0, #1
        mov     r0, r1

Seems to affect at least x86, ARM, and AArch64.

-- 
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/20160722/dcd75baa/attachment-0001.html>


More information about the llvm-bugs mailing list