Apply loop guards to AddRec's start in range computation for
non-self-wrapping AddRecs
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
6736 | Do we also need getRangeViaFactoring? |
This is too expensive in terms of compile-time: http://llvm-compile-time-tracker.com/compare.php?from=712dfec1781db8aa92782b98cac5517db548b7f9&to=2a04edbcecc77f3d80597662a4ba19f521874d62&stat=instructions:u You're probably forcing an extra invalidation cycle here or something.
I'm also not sure whether the overall approach really makes sense. We shouldn't really get more information from the exit value than we already get from the addrec and the BE count. From what I can tell based on the test changes, the primary benefit here seems to be that we now take into account guard information on the addrec start value -- so a possible alternative would be to apply guards to the start value when calculating addrec ranges, or something along those lines?
Yeah. Why exactly getRangeForAffineAR could not infer the same facts? Maybe it's doing something over-conservative? I think we could do more in terms of symbolic computations and not range computations in there.
@nikic Thanks for the advice, I've applied loop guards to the AddRec's start value in the getRangeForAffineNoSelfWrappingAR and now symbolic computations work for the example from decrementing_addrecs.ll
llvm/test/Analysis/ScalarEvolution/decrementing_addrecs.ll | ||
---|---|---|
2–3 | Let's have 2 run commands - with and without expensive checks, to highlight the difference. |
Code change LG, I'll update this test with two different run commands to see what change comes from expensive sharpening and what from your patch.
Also please wait for Nikita to take a look.
LG, but let's wait few days in case if anyone else has concerns/objections.
It would also be great if we could find a way to do it w/o expensive sharpening. There are usually several ways to achieving the same effect.
@aleksandr.popov during this chill period, could you please try to construct a test that shows benefit from your patch w/o expensive sharpening?
The changed code is only used by expensive sharpening, so no :)
I tried applying loop guards to other places like getRangeForAffineAR() as well, but this again had very bad compile-time impact: https://llvm-compile-time-tracker.com/compare.php?from=2caaec65c04ea7d0e9568b7895b7a46d6100cb75&to=87d1063758a038ffa7a0e358dc97c16ef6297aa3&stat=instructions:u Here's the corresponding diff: https://github.com/llvm/llvm-project/commit/87d1063758a038ffa7a0e358dc97c16ef6297aa3 I was hoping that doing this is pretty cheap, but apparently it isn't.
Ah ok, since it's only in expensive sharpening, then it should be fine.
Nikita, what's overall impact of expensive range sharpening together with this patch? It's sad for me that it is switched off by default. I'll maybe need to investigate why exactly it's so expensive and fix it.
Here are the compile-time results for just flipping the flag to true: http://llvm-compile-time-tracker.com/compare.php?from=b8917ac62ad49a0ce6de026c086599fc5fa35566&to=f0c3b441b6b01bb09c28c8608c5904d1910cd6d1&stat=instructions:u
Refactor with moving const Loop *L = AddRec->getLoop(); earlier?