Skip to content

analyze <= and >= loops #3700

@llvmbot

Description

@llvmbot
Bugzilla Link 3328
Resolution FIXED
Resolved on May 03, 2010 09:50
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @sunfishcode,@nlewycky

Extended Description

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

if( parami > 0 )
{
varx = parami;
}
else
{
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions