[LLVMbugs] [Bug 4244] New: IndVarSimplify breaks float loops

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri May 22 07:24:40 PDT 2009


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

           Summary: IndVarSimplify breaks float loops
           Product: libraries
           Version: 2.5
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: jay.foad at antixlabs.com
                CC: llvmbugs at cs.uiuc.edu


If I compile this code with -O2:

$ cat x.cpp
void f(float *p) {
  int n = 0;
  for (float j = 0.0f; j <= 2.0f; j++)
    for (float i = 0.0f; i <= 13.0f; i++)
      p[n++] += i/10;
}
$ .../llvm-gcc4.2-2.5-x86-linux-RHEL4/bin/llvm-g++ -O2 -S -emit-llvm x.cpp

I get this LLVM output:

define void @_Z1fPf(float* nocapture %p) nounwind {
bb4.thread:
        br label %bb2

bb2:            ; preds = %bb2, %bb4.thread
        %i.0.reg2mem.0.int = phi i32 [ 0, %bb4.thread ], [ %indvar.next, %bb2 ]
        %indvar.conv = sitofp i32 %i.0.reg2mem.0.int to float
        %0 = getelementptr float* %p, i32 %i.0.reg2mem.0.int
        %1 = load float* %0, align 4
        %2 = fdiv float %indvar.conv, 1.000000e+01
        %3 = add float %1, %2
        store float %3, float* %0, align 4
        %indvar.next = add i32 %i.0.reg2mem.0.int, 1
        br label %bb2
}

The original code clearly has a bounded number of iterations, but this LLVM
code clearly loops forever.


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