Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LICM missing hoist of calls due to missing loop rotation #1526

Closed
lattner opened this issue Feb 1, 2007 · 10 comments
Closed

LICM missing hoist of calls due to missing loop rotation #1526

lattner opened this issue Feb 1, 2007 · 10 comments
Labels
bugzilla Issues migrated from bugzilla code-quality loopoptim

Comments

@lattner
Copy link
Collaborator

lattner commented Feb 1, 2007

Bugzilla Link 1154
Resolution FIXED
Resolved on Feb 22, 2010 12:51
Version trunk
OS All

Extended Description

In this example code:

#include <stdlib.h>
#include <string.h>
#define TESTSTRING2 "Dot. date. datum. 123. Some more doubtful demonstration dummy data."
int stringSearch_Clib (long count) {
int i, c = 0;long j;char * p;
char b[sizeof(TESTSTRING2)];

strcpy (b, TESTSTRING2);
for (j=0; j < count; j++) {
for (c=i=0; i < 250; i++) {
if (NULL != (p = strstr (b, "ummy"))) c += (int) (p - b);
if (NULL != (p = strstr (b, " data"))) c += (int) (p - b);
c += (int) strcspn (b, "by");
}
}
return c;
}

The calls to strstr and strcspn are loop invariant and should be hoisted. They aren't though, because
the inner loop isn't getting rotated. This can easily be seen with:

$ llvm-gcc t.c -emit-llvm -O3 -o - -S | llvm-as | opt -print-cfg

and then viewing cfg.stringSearch_Clib.dot.

-Chris

@lattner
Copy link
Collaborator Author

lattner commented Feb 1, 2007

This should be straight-forward to implement when the LoopPassMgr stuff comes up.

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 9, 2007

We now have a LoopPassManager and a LoopRotation pass. Is this now fixed or is
fixing it now possible?

@lattner
Copy link
Collaborator Author

lattner commented Apr 9, 2007

Loop rotation isn't on by default yet. Devang, please use this as a testcase when it goes in.

-Chris

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 9, 2007

ok

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 10, 2007

This is fixed.

How do I write a test case ?

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 10, 2007

Isn't the test case in the first comment in this bug sufficient?

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 10, 2007

No :)

I verified CFG. My question is : How to write dejagnu test ?

@lattner
Copy link
Collaborator Author

lattner commented Apr 10, 2007

I'd suggest using prcontext like test/Transforms/LICM/sink_inst.ll does. This will allow you to grep for
one of the calls and the loop header label. The test should invoke both loop-rotate and licm.

Thanks Devang!

-Chris

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 10, 2007

Thanks!

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
kitano-metro pushed a commit to RIKEN-RCCS/llvm-project that referenced this issue Feb 14, 2023
kitano-metro pushed a commit to RIKEN-RCCS/llvm-project that referenced this issue Feb 14, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla code-quality loopoptim
Projects
None yet
Development

No branches or pull requests

2 participants