[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


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

           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 =
"e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:32-n32"
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:

add32_test:
@ 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
.LBB0_2:
    cmp    r0, #0
    mov    r5, r2
    bge    .LBB0_4
@ BB#3:
    mov    r5, r3
.LBB0_4:
    cmp    r5, r4
    mov    r4, r2
    beq    .LBB0_6
@ BB#5:
    mov    r4, r3
.LBB0_6:
    adds    r1, r0, r1
    cmp    r1, #0
    mov    r0, r2
    bge    .LBB0_8
@ BB#7:
    mov    r0, r3
.LBB0_8:
    cmp    r5, r0
    bne    .LBB0_10
@ BB#9:
    mov    r2, r3
.LBB0_10:
    mvns    r0, r3
    tst    r4, r2
    bne    .LBB0_12
@ BB#11:
    mov    r0, r1
.LBB0_12:
    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