Invariant load equivalence classes had some problems during the code generation as well as the modeling. The latter was due to the complicated sorting that did not always yield the simple code generation order we wanted, the former was mainly due to type problems. This patch will fix these problems and add a couple of test cases from the test suite. 1) Sorting is replaced by a demand driven code generation that will preload a value when it is needed or, if it was not needed before, at some point determined by the order of invariant accesses in the program. Only in very little cases this demand driven preloading will kick in, though it will prevent us from generating faulty code. An example where it is needed is shown in test/ScopInfo/invariant_loads_complicated_dependences.ll . 2) Invariant loads that appear in parameters but are not on the top-level (e.g., the parameter is not a SCEVUnknown) will not be treated correctly. 3) Preloaded values will no be casted to the type of the original load, though we will not distinguish values loaded from the same pointer address with different types. -------------------------- NOTE -------------------------- This patch is not yet 100% ready and will be splitted once it is, though it might be usefull to discuss it first and even use it if the current head makes you problems.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Hi Johannes,
thanks for working on this. This fixes PR25150 for me and also makes the boost::ublas test case work again. Very nice! PR25137 has not been reproducible anymore.
Most of these changes are in equivalence class code. This means, even thought the patch is large, it should have little impact on the remainder of Polly. This is good. However, if there are possibilities to split this patch into smaller pieces this would be very much appreciated. This does not only make it easier for other people to understand the changes, but also will help in case we need to bisect bugs in the future. Maybe you could split off the type casting stuff?
Also, a couple of the test cases you added are super large. I understand these are only regression tests, but I believe we should still bugpoint reduce them. A 1000 line is unlikely to give a lot of benefits.
Besides this just a couple of minor typos/grammar items I pointed out.
Feel free to commit, if possible in pieces.
include/polly/CodeGen/IslNodeBuilder.h | ||
---|---|---|
18 ↗ | (On Diff #37636) | Why do you add an empty line? |
include/polly/ScopInfo.h | ||
682 ↗ | (On Diff #37684) | Could you describe what the different elements stand for / describe? I know this was not here before, but reading through this would like to understand what the isl_set * is e.g. supposed to represent. |
1138 ↗ | (On Diff #37684) | equvalence |
1226 ↗ | (On Diff #37684) | invariant |
lib/Analysis/ScopInfo.cpp | ||
1485 ↗ | (On Diff #37684) | Great to have less functionality in this function. It was really a little long before. |
2454 ↗ | (On Diff #37684) | Evtl? "auto *Load =" |
2457 ↗ | (On Diff #37684) | If this map is known to only contain elements of type LoadInst, could we change the type of the map accordingly? |
2475 ↗ | (On Diff #37684) | this statement -> the statement |
2493 ↗ | (On Diff #37684) | Why an empty line here? |
2680 ↗ | (On Diff #37684) | Nice to see this go away. |
test/Isl/CodeGen/inv-load-lnt-crash-cyclic-dependences.ll | ||
2 ↗ | (On Diff #37684) | Some of these test cases are very big. Are these minimal test cases as produced by bugpoint? |
test/Isl/CodeGen/inv-load-lnt-crash-wrong-order-2.ll | ||
1089 ↗ | (On Diff #37684) | A one thousand line test case? Was this bugpoint reduced? |