[LLVMbugs] [Bug 19700] New: [ARM64] Miscompile possibly due to incorrect fcsel

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri May 9 12:06:31 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19700

            Bug ID: 19700
           Summary: [ARM64] Miscompile possibly due to incorrect fcsel
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: AArch64
          Assignee: unassignedbugs at nondot.org
          Reporter: mcrosier at codeaurora.org
                CC: apazos at codeaurora.org, llvmbugs at cs.uiuc.edu,
                    t.p.northover at gmail.com
    Classification: Unclassified

Given the below IR the AArch64 backend produces the expected result, while the
ARM64 does not.

linux{169}> more bad.ll
target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
target triple = "arm64-none-linux-gnu"

@foo.b = internal unnamed_addr global float -1.000000e+00, align 4

define float @foo(float %a) noinline {
entry:
  %cmp = fcmp olt float %a, 1.000000e+00
  %selv = select i1 %cmp, float 1.000000e+00, float %a
  %0 = load float* @foo.b, align 4
  %cmp2 = fcmp une float %0, %selv
  %selv7 = select i1 %cmp2, float %selv, float %0
  store float %selv7, float* @foo.b, align 4
  ret float %selv7
}

define i32 @main() {
entry:
  %call = tail call float @foo(float 0.000000e+00)
  %not.cmp = fcmp une float %call, 1.000000e+00
  %cond = zext i1 %not.cmp to i32
  ret i32 %cond
}

linux{170}> clang-arm64-x bad.ll -mcpu=cortex-a53 -O3 -ffast-math -o bad
-static
linux{171}> ./qemu-aarch64 bad
linux{172}> echo $?
1

linux{173}> clang-aarch64-x bad.ll -mcpu=cortex-a53 -O3 -ffast-math -o bad
-static
linux{174}> ./qemu-aarch64 bad
linux{175}> echo $?
0

Looking at the generated assembly,

linux{176}> clang-arm64-x bad.ll -mcpu=cortex-a53 -O3 -ffast-math -o - -S
        .text
        .file   "bad.ll"
        .globl  foo
        .align  2
        .type   foo, at function
foo:                                    // @foo
// BB#0:                                // %entry
        fmov    s1, #1.00000000
        fmax    s0, s0, s1
        adrp    x8, foo.b
        ldr     s1, [x8, :lo12:foo.b]
        fcmp    s1, s0
        fcsel   s0, s1, s0, ne  <==========
        str     s0, [x8, :lo12:foo.b]
        ret
.Ltmp1:
        .size   foo, .Ltmp1-foo

The marked fcsel seems incorrect, I believe it should be fcsel s0, s0, s1, ne.

-- 
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/20140509/95257b6e/attachment.html>


More information about the llvm-bugs mailing list