[LLVMbugs] [Bug 2465] New: Invalid register allocation

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Jun 16 06:27:22 PDT 2008


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

           Summary: Invalid register allocation
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Backend: X86
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: asl at math.spbu.ru
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=1750)
 --> (http://llvm.org/bugs/attachment.cgi?id=1750)
Bytecode in questions

Consider the attached .ll file (sorry, I wasn't be able to reduce it).

in bb27.i.i74 we're seeing:

bb27.i.i74:             ; preds = %bb14.i.i
        %tmp30.i.i69 = getelementptr i8* %tmp1097, i32 %x_addr.0.i.i           
; <i8*> [#uses=1]
        %tmp31.i.i70 = load i8* %tmp30.i.i69, align 1           ; <i8>
[#uses=2]
        %tmp34.i.i71 = getelementptr i8* %tmp1094, i32 %y.0.i.i         ; <i8*>
[#uses=1]
        %tmp35.i.i72 = load i8* %tmp34.i.i71, align 1           ; <i8>
[#uses=1]
        %tmp36.i.i73 = icmp eq i8 %tmp31.i.i70, %tmp35.i.i72            ; <i1>
[#uses=1]
        zext i8 %tmp31.i.i70 to i32             ; <i32>:1418 [#uses=2]
        %tmp1.i2918 = and i32 %1418, 1          ; <i32> [#uses=1]
        %tmp2.i2919 = xor i32 %tmp1.i2918, 1            ; <i32> [#uses=1]
        %tmp4.i2920 = sub i32 0, %1418          ; <i32> [#uses=1]
        %tmp.i2921 = icmp ne i32 %tmp2.i2919, %tmp4.i2920               ; <i1>
[#uses=1]
        and i1 %tmp36.i.i73, %tmp.i2921         ; <i1>:1419 [#uses=1]
        br i1 %1419, label %bb9.i.i, label %snake.exit.i

so, two GEPs plus some innocent bit plays.

These are codegen'ed into:

LBB5_811:       # bb27.i.i74
        movl    208(%esp), %ecx
        movb    (%ecx,%ebp), %al
        movzbl  %al, %ecx
        movl    %ecx, %edx
        andl    $1, %edx
        negl    %ecx
        xorl    $1, %edx
        movl    204(%esp), %ebx
        cmpb    (%ebx,%ecx), %al
        jne     LBB5_813        # bb14.i.i.snake.exit.i_crit_edge

Note, that
        %tmp35.i.i72 = load i8* %tmp34.i.i71, align 1           ; <i8>
[#uses=1]
        %tmp36.i.i73 = icmp eq i8 %tmp31.i.i70, %tmp35.i.i72            ; <i1> 

is turned into 

        movl    204(%esp), %ebx
        cmpb    (%ebx,%ecx), %al

which is definitely incorrect, since %ecx was already clobbered by
computations.

If I run opt -std-compile-opts before, result is pretty sane:

LBB5_744:       # bb27.i.i74
        movl    208(%esp), %esi
        movb    (%esi,%edx), %bl
        movzbl  %bl, %esi
        movl    %esi, %ebp
        negl    %ebp
        andl    $1, %esi
        xorl    $1, %esi
        cmpl    %ebp, %esi
        movl    204(%esp), %esi
        movb    (%esi,%eax), %bh
        je      LBB5_746        # bb14.i.i.snake.exit.i_crit_edge

here %eax and %edx are liveins from prev BBs, where GEP indices were
calculated.


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