> > Yep, tree_to_shwi will check it. The old code did generic expression folding > and > called tree_to_shwi on result, so the only difference is that old code will > accept > unfolded expressions that miraculously folds into constant. I think it is > bug to > have those in IL especially on places we do not expect variable offsets. > > Based on that observation, I think we can also drop handling of PLUS_EXPR in > this case > as follows. > > Concerning the function, it has documented in toplevel comment that parameter > must > be constant or it crashes, so I think it is fine. Conerning name, I am open > for renaming, > but we have those int_* variants in quite few copies, so I can do that > incrementally > (see int_byte_position and related functions in stor layout). > > I am testing the following simplified (and inline) variant. > Perhaps we could do similar stuff for other int_* accessors even if they do > not > sit on hot paths in my test, just for the sake of code size.
Note that I benchmarked libxul build. This patch makes devirtualization to go from 70% of compile time to 30%, so it is about twice as fast. I will care the rest by caching reorg (it went up from 4% to 70% by introducing the speculation) Honza