[llvm-bugs] [Bug 51563] New: incorrect conversion of sqrdmulh+sqsub to sqrdmlsh

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 20 10:57:49 PDT 2021


            Bug ID: 51563
           Summary: incorrect conversion of sqrdmulh+sqsub to sqrdmlsh
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jzern at google.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk, sam.parker at arm.com,
                    sjoerd.meijer at arm.com

Created attachment 25180
  --> https://bugs.llvm.org/attachment.cgi?id=25180&action=edit

The sequence of sqrdmulh followed by sqsub is being converted to sqrdmlsh which
shifts the rounding from the first multiply to the result causing an off by one
in some cases. gcc (tested with aarch64-linux-gnu-gcc (Debian 10.2.1-6+build2)
10.2.1 20210110) does not perform this conversion.

Reproduced with llvmorg-14-init-1836-ge4888be74e34 and releases going back to

# repros with -O2/-O3, other levels aside from 0 untested.
$ clang -march=armv8.1-a -target aarch64-pc-linux-gnu -O2 \

See also:

non_opt:                                // @non_opt
        sub     sp, sp, #64                     // =64
        movi    v0.8h, #1, lsl #8
        str     q0, [sp, #48]
        movi    v0.8h, #1
        str     q0, [sp, #32]
        ldr     q0, [sp, #48]
        mov     w8, #42944
        dup     v1.8h, w8
        sqrdmulh        v0.8h, v0.8h, v1.8h
        str     q0, [sp, #16]
        ldr     q0, [sp, #32]
        ldr     q1, [sp, #16]
        sqsub   v0.8h, v0.8h, v1.8h
        str     q0, [sp]
        ldr     q0, [sp]
        add     sp, sp, #64                     // =64
opt:                                    // @opt
        mov     w8, #42944
        movi    v1.8h, #1, lsl #8
        dup     v2.8h, w8
        movi    v0.8h, #1
        sqrdmlsh        v0.8h, v1.8h, v2.8h

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/20210820/4c8113bf/attachment.html>

More information about the llvm-bugs mailing list