[PATCH] D11758: [Unroll] Implement a conservative and monotonically increasing cost tracking system during the full unroll heuristic analysis that avoids counting any instruction cost until that instruction becomes "live" through a side-effect or use outside the...
Michael Zolotukhin via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 17:13:44 PDT 2015
mzolotukhin added a comment.
Hi Chandler,
This patch got stuck, but finally I got some time and investigated it more carefully. I found a bug in current implementation that explains everything, and as a consequence I constructed a simple test-case to demonstrate the problem:
int foo(char *a) {
int i = 0;
for (i = 0; i < 500; i++)
if (a[i] == 0)
return i;
return 0;
}
The problem is that the only instructions we consider live are those having side effects. However, they might have no side effects (by LLVM's definition of side effects: `mayWriteToMemory() || mayThrow() || !mayReturn()`) and still affect program behavior, as in the case above.
Thanks,
Michael
================
Comment at: lib/Transforms/Scalar/LoopUnrollPass.cpp:752-753
@@ -620,1 +751,4 @@
+ // leading up to it.
+ if (I.mayHaveSideEffects())
+ AddCostRecursively(I, Iteration);
----------------
Should we also take into account instructions with out-of-the-loop uses and early-exit instructions? Are there any other cases we want not to miss?
http://reviews.llvm.org/D11758
More information about the llvm-commits
mailing list