[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


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

           Summary: Incorrect codegen with shifting+sign extension (possibly
                    DAGCombiner?)
           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


Testcase:

; ModuleID = '-'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i386-pc-linux-gnu"
        %struct.Foo = type <{ i8 }>
@foo = global %struct.Foo <{ i8 127 }>, align 1         ; <%struct.Foo*>
[#uses=1]
@.str = internal constant [17 x i8] c"f->_field2 = %x\0A\00"            ; <[17
x i8]*> [#uses=1]

define i32 @main(...) nounwind {
entry:
        %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
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20081215/010225.html.)


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