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: unassignedb...@nondot.org
          Reporter: simon.ho...@arm.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to