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
This should be straight-forward to implement when the LoopPassMgr stuff comes up.
We now have a LoopPassManager and a LoopRotation pass. Is this now fixed or is fixing it now possible?
Loop rotation isn't on by default yet. Devang, please use this as a testcase when it goes in. -Chris
ok
This is fixed. How do I write a test case ?
Isn't the test case in the first comment in this bug sufficient?
No :) I verified CFG. My question is : How to write dejagnu test ?
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
Thanks!
Fixed: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070402/046911.html http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070409/047158.html http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070409/047160.html