[polly] speedup compile time for functions with no loops

Tobias Grosser tobias at grosser.es
Thu May 30 09:37:46 PDT 2013


On 05/29/2013 09:58 AM, Sebastian Pop wrote:
> Hi,
>
> when compiling c++ code (or c code with a lot of functions), scop detection
> shows a huge overhead: probably 1/3 of the compile time is spent in scop
> detection trying to find out maximal regions in functions with no loops.
>
> Here is a preliminary patch (does not fix the testsuite) that disables scop
> detection on functions with no loops:

Hi Sebastian,

I see where you are heading. Regarding the patch or the solution you 
propose:

I dislike the idea of adding an option here, as the non-default case may 
become stale. On the other hand I understand that we really do not have 
any use case yet where a scop without a loop could be speed up 
significantly. So adding this heuristic really makes sense.

In an optimal world, I would like to run the scop detection on 
everything just to ensure we do not regress on non-loop scops. However 
for this the overhead needs to be negligible. For now we can probably
add the above patch, enable it by default and add an option that keeps
the original functionality. As we have tests to cover this functionality
the risk of the code getting stale is hopefully not as high.

As Star Tan was accepted to his summer of code to work on exactly this 
issue, I would like him to investigate this closer. Do you happen to 
have test cases that show the above slowness? Could you point him to 
those test cases?

Regarding the patch you propose and the one Star Tan sent. I would go 
for an option that explicitly disables loops, not not for a 
-polly-fast-detection. A generic option does not seem to make sense, as 
we want the detection to always be fast. ;-)

If we agree on the above a patch along this lines is OK to commit.

Cheers,
Tobias


> diff --git a/lib/Analysis/ScopDetection.cpp b/lib/Analysis/ScopDetection.cpp
> index ab323fd..ee2721d 100644
> --- a/lib/Analysis/ScopDetection.cpp
> +++ b/lib/Analysis/ScopDetection.cpp
> @@ -785,9 +785,12 @@ void
> ScopDetection::printInvalidLocations(llvm::Function &F) {
>
>   }
>   bool ScopDetection::runOnFunction(llvm::Function &F) {
> +  LI = &getAnalysisID<LoopInfo>(LoopInfo::getClassPassID());
> +  if (LI->empty())
> +    return false;
> +
>     AA = &getAnalysisID<AliasAnalysis>(AliasAnalysis::getClassPassID());
>     SE = &getAnalysisID<ScalarEvolution>(ScalarEvolution::getClassPassID());
> -  LI = &getAnalysisID<LoopInfo>(LoopInfo::getClassPassID());
>     RI = &getAnalysisID<RegionInfo>(RegionInfo::getClassPassID());
>     Region *TopRegion = RI->getTopLevelRegion();
>
>
> My question is how do you want to fix the testsuite? Do you want to remove or
> rewrite the files that check for patterns in functions with no loops, or do you
> want to add a flag to enable scop detection even with no loops in a function?
>
> I would prefer the flag solution: it's the easiest way for me to fix
> the testsuite.
>
> Thanks,
> Sebastian
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by The Linux Foundation
>




More information about the llvm-commits mailing list