Question about JIT Peephole optimizations
Yi Yang
qingfeng.yy at alibaba-inc.com
Sat Sep 18 07:34:26 UTC 2021
Hello Community,
I see that both C1 and C2 introduced peephole optimization, which is a classic compiler optimization phase. However, it seems that they are barely implemented/used/changed from the first time they open-sourced to now on.
C1's peephole(LIR_Assembler::peephole) does nothing, and its implementation on most platforms is empty. As for C2's peephole, I noticed currently arm/aarch64 has no peephole rules, x686/s390/ppc has 2-3 peephole rules. PhasePeephole on almost all platforms is disabled by default, the only exception is x86, which is enabled by default.
I want to know why we do not add more rules to allow merging more instructions by using peephole(Like llvm/lib/CodeGen/PeepholeOptimizer.cpp). And I noticed that many rules have been commented out. Is there any reason for that? Is it because XXNode::Ideal does most of the work? Or has profiling proved that peepholes are not profitable/balanced between compilation time and their outcome? Or it's difficult to do peepholes by rule-based approach? Are we worthy of continuing to work on it?
I know nothing about the prehistoric era of HotSpot JITs, any input is appreciated!
Thanks.
More information about the hotspot-compiler-dev
mailing list