[llvm-bugs] [Bug 50126] New: Codegen regression with sign extensions

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Apr 26 07:05:33 PDT 2021


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

            Bug ID: 50126
           Summary: Codegen regression with sign extensions
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: ARM
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org, smithp352 at googlemail.com,
                    Ties.Stuij at arm.com

struct s {
        short x, y;
};

struct s rot90(struct s p)
{
        return (struct s) { -p.y,  p.x };
}

struct s rot270(struct s p)
{
        return (struct s) {  p.y, -p.x };
}


Trunk:
rot90:                                  // @rot90
        neg     w8, w0, lsr #16
        lsl     w0, w0, #16
        bfxil   x0, x8, #0, #16
        ret
rot270:                                 // @rot270
        neg     w8, w0, lsl #16
        bfxil   x8, x0, #16, #16
        mov     x0, x8
        ret


rot90:                                  // @rot90
        neg     w8, w0, lsr #16
        bfi     w8, w0, #16, #16
        mov     x0, x8
        ret
rot270:                                 // @rot270
        ubfx    x8, x0, #16, #16
        sub     w0, w8, w0, lsl #16
        ret

Maybe ideal codegen?:

rot90:
            mov     w1, w0
            neg     w0, w1, asr 16
            bfi     w0, w1, 16, 16
            ret
rot270:
            neg     w1, w0
            extr    w0, w1, w0, 16
            ret

See it live:
https://gcc.godbolt.org/z/4c4ds58v6

-- 
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/20210426/4cea0a09/attachment.html>


More information about the llvm-bugs mailing list