[LLVMbugs] [Bug 2831] New: instcombine complicates expression, and also gets it wrong!

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Sep 26 06:51:34 PDT 2008


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

           Summary: instcombine complicates expression, and also gets it
                    wrong!
           Product: new-bugs
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: baldrick at free.fr
                CC: llvmbugs at cs.uiuc.edu


Running "opt -instcombine" on this testcase:

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"

define i32 @main(i32 %argc, i8** %argv) nounwind {
entry:
        %0 = ptrtoint i8** %argv to i32         ; <i32> [#uses=1]
        %1 = add i32 %0, 1              ; <i32> [#uses=1]
        ret i32 %1
}

Turns it into:

define i32 @main(i32 %argc, i8** %argv) nounwind {
entry:
        %argv1 = bitcast i8** %argv to i8*              ; <i8*> [#uses=1]
        %ctg2 = getelementptr i8* %argv1, i32 1         ; <i8*> [#uses=1]
        %0 = ptrtoint i8* %ctg2 to i32          ; <i32> [#uses=1]
        ret i32 %0
}

Not only is this more complicated, but overflow behaviour
is different: i32 overflow is well-defined, while gep overflow
is not (at least, I don't think it is...).  So this transform
is wrong as well as silly.


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