[LLVMbugs] [Bug 5443] New: missed x86 optimization for flags

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Nov 9 13:31:58 PST 2009


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

           Summary: missed x86 optimization for flags
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Backend: X86
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: clattner at apple.com
                CC: llvmbugs at cs.uiuc.edu


X86-64 compiles this code:

define {i64, i1} @addo.apint.i64 ( i64 %left, i64 %right )
{
entry:
        %extleft = zext i64 %left to i65
        %extright = zext i64 %right to i65
        %sum = add i65 %extleft, %extright
        %res.0 = trunc i65 %sum to i64
        %overflow = and i65 %sum, -18446744073709551616
        %res.1 = icmp ne i65 %overflow, 0
        %final0 = insertvalue {i64, i1} undef, i64 %res.0, 0
        %final1 = insertvalue {i64, i1} %final0, i1 %res.1, 1
        ret {i64, i1} %final1
}

define {i64, i1} @addo.intrinsics.i64 ( i64 %left, i64 %right )
{
entry:
        %call = call {i64, i1} @llvm.uadd.with.overflow.i64 ( i64 %left, i64
%right )
        ret {i64, i1} %call
}

declare {i64, i1} @llvm.uadd.with.overflow.i64 ( i64 %left, i64 %right )
nounwind readnone

to:

_addo.apint.i64:                                            ## @addo.apint.i64
        xorl    %ecx, %ecx
        movq    %rdi, %rax
        addq    %rsi, %rax
        adcq    $0, %rcx
        testb   $1, %cl
        setne   %dl
        ret

_addo.intrinsics.i64:                                       ##
@addo.intrinsics.i64
        movq    %rdi, %rax
        addq    %rsi, %rax
        setb    %dl
        ret

They should be equivalent and we're probably only a dag combine away from
getting the former case to compile to the latter code.


-- 
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