[LLVMbugs] [Bug 5979] New: msp430 backend: incorrect conditional jump

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Jan 8 12:24:37 PST 2010


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

           Summary: msp430 backend: incorrect conditional jump
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: ransford at cs.umass.edu
                CC: asl at math.spbu.ru, llvmbugs at cs.uiuc.edu


Created an attachment (id=4014)
 --> (http://llvm.org/bugs/attachment.cgi?id=4014)
Tiny test case

Given this C code:

% cat tiny.c
int main (void) {
    int i;
    for (i = 0; i < 100; ++i) {
        asm("NOP");
    }
}

In LLVM IR, the loop header looks like this:

for.cond:                                         ; preds = %for.inc, %entry
  %tmp = load i16* %i                             ; <i16> [#uses=1]
  %cmp = icmp slt i16 %tmp, 100                   ; <i1> [#uses=1]
  br i1 %cmp, label %for.body, label %for.end

... which says "go to %for.body if %i < 100, else go to %for.end -- this is
correct. However, run that IR through llc -march=msp430 and you get this
incorrect MSP430 code:

main:
; BB#0:                                                     ; %entry
        sub.w   #4, r1
        mov.w   #0, 2(r1)
        mov.w   #0, 0(r1)
.LBB1_1:                                                    ; %for.cond
                                                            ; Loop Depth 1
                                                            ; Loop Header
                                                            ; Inner Loop
        cmp.w   #99, 0(r1)
        jl      .LBB1_3
; BB#2:                                                     ; %for.body
                                                            ; Loop Depth 1
                                                            ; Loop Header is
BB1_1
                                                            ; Inner Loop
        ;APP
        NOP
        ;NO_APP
        add.w   #1, 0(r1)
        jmp     .LBB1_1
.LBB1_3:                                                    ; %for.end
        mov.w   2(r1), r15
        add.w   #4, r1
        ret
        .size   main, .-main

The conditional branch goes the wrong way! Of course 0 < 99, so the loop body
(BB#2) never gets executed.


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