[LLVMbugs] [Bug 10317] New: Thumb 2 : Overflow intrinsic generates horrible code

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jul 9 09:52:57 PDT 2011


           Summary: Thumb 2 : Overflow intrinsic generates horrible code
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: ARM
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: xocotl at gmail.com
                CC: llvmbugs at cs.uiuc.edu

This test:

; ModuleID = 'test.c'
target datalayout =
target triple = "thumb-none--eabi"

declare {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)

define i32 @add32_test(i32 %a, i32 %b) nounwind readnone {
  %res = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
  %1 = extractvalue {i32, i1} %res, 0
  %2 = extractvalue {i32, i1} %res, 1
  %. = select i1 %2, i32 4294967295, i32 %1
  ret i32 %.

generates this:

@ BB#0:
    push    {r4, r5, r7, lr}
    movs    r2, #1
    movs    r3, #0
    cmp    r1, #0
    mov    r4, r2
    bge    .LBB0_2
@ BB#1:
    mov    r4, r3
    cmp    r0, #0
    mov    r5, r2
    bge    .LBB0_4
@ BB#3:
    mov    r5, r3
    cmp    r5, r4
    mov    r4, r2
    beq    .LBB0_6
@ BB#5:
    mov    r4, r3
    adds    r1, r0, r1
    cmp    r1, #0
    mov    r0, r2
    bge    .LBB0_8
@ BB#7:
    mov    r0, r3
    cmp    r5, r0
    bne    .LBB0_10
@ BB#9:
    mov    r2, r3
    mvns    r0, r3
    tst    r4, r2
    bne    .LBB0_12
@ BB#11:
    mov    r0, r1
    pop    {r4, r5, r7, pc}

It could just check the overflow flag.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list