[LLVMbugs] [Bug 3216] New: Incorrect codegen with shifting+sign extension ( possibly DAGCombiner?)

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Dec 15 15:17:11 PST 2008


           Summary: Incorrect codegen with shifting+sign extension (possibly
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sharparrow1 at yahoo.com
                CC: llvmbugs at cs.uiuc.edu


; ModuleID = '-'
target datalayout =
target triple = "i386-pc-linux-gnu"
        %struct.Foo = type <{ i8 }>
@foo = global %struct.Foo <{ i8 127 }>, align 1         ; <%struct.Foo*>
@.str = internal constant [17 x i8] c"f->_field2 = %x\0A\00"            ; <[17
x i8]*> [#uses=1]

define i32 @main(...) nounwind {
        %tmp = load i8* getelementptr (%struct.Foo* @foo, i32 0, i32 0)        
; <i8> [#uses=1]
        %bf.lo = lshr i8 %tmp, 5                ; <i8> [#uses=1]
        %bf.lo.cleared = and i8 %bf.lo, 7               ; <i8> [#uses=1]
        %0 = shl i8 %bf.lo.cleared, 5           ; <i8> [#uses=1]
        %bf.val.sext = ashr i8 %0, 5            ; <i8> [#uses=1]
        %conv = sext i8 %bf.val.sext to i32             ; <i32> [#uses=1]
        %call = call i32 (...)* @printf(i8* getelementptr ([17 x i8]* @.str,
i32 0, i32 0), i32 %conv)          ; <i32> [#uses=0]
        ret i32 0

declare i32 @printf(...)

This should print out "f->_field2 = 3"; however, wrong code is generated with
"llc test.bc" on x86.  "llc -fast test.bc", however, appears to generate
correct code, leading me to suspect the DAGCombiner is messing up here.

I'm going to try and see if I can track it down a bit further, but I figured it
was better to file so I don't lose track of it.

(Note: originally reported at

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