[LLVMbugs] [Bug 3328] New: LLVM optmization loop optimization

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu Jan 15 02:47:20 PST 2009


           Summary: LLVM optmization loop optimization
           Product: libraries
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Loop Optimizer
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: manoel at fonetica.com.br
                CC: llvmbugs at cs.uiuc.edu

#include <stdio.h>
#include <stdlib.h>
int  TESTE ( int  parami ,int  paraml   ) 
  int varx=0;
  int nI =0;

  if( parami  > 0 )
    varx = parami;
    varx = 1;

  for( nI = 1 ;   nI <=  paraml; nI++) //here
    varx =  varx +  parami+ 1;

return varx ;

int main(int argc, char **argv)
   if( argc < 3 )
     return 0;
   return TESTE(atoi(argv[1]),atoi(argv[2]));

LLVM should eliminate the loop and do a direct calculation instead.
The MSVC is great in this example and gcc-4.3 also eliminates the loop entirely
and directly calculates the value of varx.
It looks like LLVM's scalar evolution code isn't handling your testcase well.

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