[llvm-bugs] [Bug 35800] New: AArch64 GlobalISel miscompiles llvm.smul.with.overflow

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 2 15:37:39 PST 2018


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

            Bug ID: 35800
           Summary: AArch64 GlobalISel miscompiles llvm.smul.with.overflow
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: GlobalISel
          Assignee: unassignedbugs at nondot.org
          Reporter: eugeni.stepanov at gmail.com
                CC: llvm-bugs at lists.llvm.org

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

With global-isel, the following function returns 1 when %idx is -1.

define i8 @g(i64 %idx) {
entry:
  %a2 = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 1, i64 %idx)
  %a3 = extractvalue { i64, i1 } %a2, 1
  %a4 = zext i1 %a3 to i8
  ret i8 %a4
}

To reproduce, build & run the attached repro.ll. It outputs "0" with -mllvm
-fast-isel and "1" otherwise.

Assembly, fast-isel (good):

g():
 5fc:   d10043ff        sub     sp, sp, #0x10
 600:   937ffc00        asr     x0, x0, #63
 604:   eb000000        subs    x0, x0, x0
 608:   1a9f07e8        cset    w8, ne
 60c:   2a0803e1        mov     w1, w8
 610:   f90007e0        str     x0, [sp,#8]
 614:   2a0803e0        mov     w0, w8
 618:   b90007e1        str     w1, [sp,#4]
 61c:   910043ff        add     sp, sp, #0x10
 620:   d65f03c0        ret

Assembly, global-isel (bad):
g():
 608:   b24003e8        orr     x8, xzr, #0x1
 60c:   9b407d08        smulh   x8, x8, x0
 610:   d2800000        mov     x0, #0x0                        // #0
 614:   eb00011f        cmp     x8, x0
 618:   1a9f07e9        cset    w9, ne
 61c:   2a0903e0        mov     w0, w9
 620:   b3400008        bfxil   x8, x0, #0, #1
 624:   d3400108        ubfx    x8, x8, #0, #1
 628:   2a0803e9        mov     w9, w8
 62c:   53000129        ubfx    w9, w9, #0, #1
 630:   2a0903e0        mov     w0, w9
 634:   d65f03c0        ret

-- 
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/20180102/0ef66e2c/attachment-0001.html>


More information about the llvm-bugs mailing list