[LLVMbugs] [Bug 14986] New: LLVM 3.2 opt remove a loop where it should not

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 17 08:06:37 PST 2013


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

             Bug #: 14986
           Summary: LLVM 3.2 opt remove a loop where it should not
           Product: new-bugs
           Version: 3.2
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: babslachem at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


With LLVM opt 3.2 and trunk on following code:

; ModuleID = 'le00bug'
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-n8:16:32"
target triple = "i386-pc-linux-gnu"
@rslts32 = internal global [50 x i32] zeroinitializer, align 4

@expect32 = internal global [36 x i32][ i32 1, i32 2, i32 0, i32 100, i32 3,
i32 4, i32 0, i32 -7, i32 4, i32 4, i32 8, i32 8, i32 1, i32 3, i32 8, i32 3,
i32 4, i32 -2, i32 2, i32 8, i32 83, i32 77, i32 8, i32 17, i32 77, i32 88, i32
22, i32 33, i32 44, i32 88, i32 77, i32 4, i32 4, i32 7, i32 -7, i32 -8] ,
align 4

define void @test32() noinline {
L.entry:
    %p = alloca i32*
    %q = alloca i32*
            ; ilix 0    i0
    %0 = bitcast [50 x i32]* @rslts32 to i8*
    %1 = getelementptr i8* %0, i32 -4
    %2 = bitcast i32** %p to i8**
    store i8* %1, i8** %2, align 4
    %3 = bitcast [36 x i32]* @expect32 to i8*
    %4 = getelementptr i8* %3, i32 -4
    %5 = bitcast i32** %q to i8**
    store i8* %4, i8** %5, align 4
    br label %L.B0000
L.B0000:            ; ilix 142    i0
    %6 = load i32** %p, align 4
    %7 = bitcast i32* %6 to i8*
    %8 = getelementptr i8* %7, i32 4
    %9 = bitcast i32** %p to i8**
    store i8* %8, i8** %9, align 4
    %10 = load i32** %q, align 4
    %11 = bitcast i32* %10 to i8*
    %12 = getelementptr i8* %11, i32 4
    %13 = bitcast i32** %q to i8**
    store i8* %12, i8** %13, align 4
    %14 = load i32** %q, align 4
    %15 = load i32* %14, align 4
    %16 = load i32** %p, align 4
    store i32 %15, i32* %16, align 4
    %17 = icmp ne i32 %15, 0
    br i1 %17, label %L.B0000, label %L.B0002
L.B0002:            ; ilix 155    i0
    %18 = load i32** %q, align 4
    %19 = load i32* %18, align 4
    %20 = add i32 %19, 100
    %21 = load i32** %p, align 4
    %22 = getelementptr i32* %21, i32 1
    store i32 %20, i32* %22, align 4
    ret void
}


Using opt -O2, I've got following code generated, which got rid of loop:

; ModuleID = 'le00bug.ll'
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-n8:16:32"
target triple = "i386-pc-linux-gnu"

@rslts32 = internal unnamed_addr global [50 x i32] zeroinitializer, align 4

define void @test32() nounwind noinline {
L.entry:
  store i32 100, i32* getelementptr inbounds ([50 x i32]* @rslts32, i32 0, i32
3), align 4
  ret void
}

This doesn't happen with LLVM 3.0 and code is thus correct

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