[SCEV] Cache ZExt SCEV expressions.
When creating SCEV expressions for ZExt, there's quite a bit of reasoning done and in many places the reasoning in turn will try to create new SCEVs for other ZExts. This can have a huge compile-time impact. The attached test from #58402 takes an excessive amount of compile time; without the patch, the test doesn't complete in 1500+ seconds, but with the patch it completes in 1 second. To speed up this case, cache created ZExt expressions for given (SCEV, Ty) pairs. Caching just ZExts is relatively straight-forward, but it might make sense to extend it to other expressions in the future. This has a slight positive impact on CTMark: * O3: -0.03% * ReleaseThinLTO: -0.03% * ReleaseLTO-g: 0.00% https://llvm-compile-time-tracker.com/compare.php?from=bf9de7464946c65f488fe86ea61bfdecb8c654c1&to=5ac0108553992fb3d58bc27b1518e8cf06658a32&stat=instructions:u The patch also improves compile-time for some internal real-world workloads where time spent in SCEV goes from ~300 seconds to ~3 seconds. There are a few cases where computing & caching the result earlier may return more pessimistic results, but the compile-time savings seem to outweigh that. Fixes #58402. Reviewed By: mkazantsev Differential Revision: https://reviews.llvm.org/D137505
Loading
Please sign in to comment