[llvm-dev] Saving Compile Time in InstCombine
Mikhail Zolotukhin via llvm-dev
llvm-dev at lists.llvm.org
Fri Mar 17 14:22:59 PDT 2017
> On Mar 17, 2017, at 2:02 PM, Vedant Kumar <vsk at apple.com> wrote:
>
>>
>> On Mar 17, 2017, at 11:50 AM, Mikhail Zolotukhin via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
>>
>> Hi,
>>
>> One of the most time-consuming passes in LLVM middle-end is InstCombine (see e.g. [1]). It is a very powerful pass capable of doing all the crazy stuff, and new patterns are being constantly introduced there. The problem is that we often use it just as a clean-up pass: it's scheduled 6 times in the current pass pipeline, and each time it's invoked it checks all known patterns. It sounds ok for O3, where we try to squeeze as much performance as possible, but it is too excessive for other opt-levels. InstCombine has an ExpensiveCombines parameter to address that - but I think it's underused at the moment.
>>
>> Trying to find out, which patterns are important, and which are rare, I profiled clang using CTMark and got the following coverage report:
>> <InstCombine_covreport.html>
>> (beware, the file is ~6MB).
>>
>> Guided by this profile I moved some patterns under the "if (ExpensiveCombines)" check, which expectedly happened to be neutral for runtime performance, but improved compile-time. The testing results are below (measured for Os).
>
> It'd be nice to double-check that any runtime performance loss at -O2 is negligible. But this sounds like a great idea!
I forgot to mention that I ran SPEC2006/INT with "-Os" on ARM64 and didn't see any changes in runtime performance. I can run O2 testing as well over the weekend.
Michael
>
> vedant
>
>> Performance Improvements - Compile Time Δ Previous Current σ
>> CTMark/sqlite3/sqlite3 -1.55% 6.8155 6.7102 0.0081
>> CTMark/mafft/pairlocalalign -1.05% 8.0407 7.9559 0.0193
>> CTMark/ClamAV/clamscan -1.02% 11.3893 11.2734 0.0081
>> CTMark/lencod/lencod -1.01% 12.8763 12.7461 0.0244
>> CTMark/SPASS/SPASS -1.01% 12.5048 12.3791 0.0340
>>
>> Performance Improvements - Compile Time Δ Previous Current σ
>> External/SPEC/CINT2006/403.gcc/403.gcc -1.64% 54.0801 53.1930 -
>> External/SPEC/CINT2006/400.perlbench/400.perlbench -1.25% 19.1481 18.9091 -
>> External/SPEC/CINT2006/445.gobmk/445.gobmk -1.01% 15.2819 15.1274 -
>>
>>
>> Do such changes make sense? The patch doesn't change O3, but it does change Os and potentially can change performance there (though I didn't see any changes in my tests).
>>
>> The patch is attached for the reference, if we decide to go for it, I'll upload it to phab:
>>
>> <0001-InstCombine-Move-some-infrequent-patterns-under-if-E.patch>
>>
>>
>> Thanks,
>> Michael
>>
>> [1]: http://lists.llvm.org/pipermail/llvm-dev/2016-December/108279.html
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170317/723f7037/attachment.html>
More information about the llvm-dev
mailing list