[LLVMbugs] [Bug 22373] New: ARM: (sub ; trivial unsigned icmp ; branch) picks wrong trivial cmp result

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jan 28 13:19:40 PST 2015


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

            Bug ID: 22373
           Summary: ARM: (sub ; trivial unsigned icmp ; branch) picks
                    wrong trivial cmp result
           Product: tools
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: llc
          Assignee: unassignedbugs at nondot.org
          Reporter: jvoung at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Given the following .ll

===

$ cat temp.repro2.ll 
; ModuleID = '/tmp/temp.repro2.ll'
target datalayout = "e-p:32:32-i64:64-n32"

@x = internal global i32 zeroinitializer, align 4

define i32 @main() {
entry:
  %bf.load = load i32* @x, align 1
  %sub = sub i32 %bf.load, 2
  %cmp = icmp ult i32 %sub, 0
  br i1 %cmp, label %if.then, label %if.end

if.then:                                          ; preds = %entry
  call void @abort()
  unreachable

if.end:                                           ; preds = %entry
  call void @exit(i32 0)
  unreachable
}

declare void @abort()

declare void @exit(i32)

====

The icmp ult i32 %sub, 0, should always be false, so that the if.end branch is
taken.

In LLVM 3.5 we would get:
$ llc -mtriple armv7a-none-linux-gnueabihf /tmp/temp.repro2.ll -o -

main:                                   @ @main
    .fnstart
.Leh_func_begin0:
@ BB#0:                                 @ %entry
    .save    {r11, lr}
    push    {r11, lr}
    mov    r0, #1
    cmp    r0, #0
    bne    .LBB0_2
@ BB#1:                                 @ %if.then
    bl    abort
.LBB0_2:                                @ %if.end
    mov    r0, #0
    bl    exit

This correctly goes to the if.end branch.

I tried LLVM 3.7 @ 227294 and get:

main:                                   @ @main
    .fnstart
.Leh_func_begin0:
@ BB#0:                                 @ %entry
    .save    {r11, lr}
    push    {r11, lr}
    movw    r0, :lower16:x
    movt    r0, :upper16:x
    ldr    r0, [r0]
    subs    r0, r0, #2
    bhs    .LBB0_2
@ BB#1:                                 @ %if.then
    bl    abort
.LBB0_2:                                @ %if.end
    mov    r0, #0
    bl    exit


The subs will not actually set the carry bit, so this no longer goes to the
if.end branch.

====


Currently still bisecting to figure out when this started happening.

-- 
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/20150128/e4188c5e/attachment.html>


More information about the llvm-bugs mailing list