On Fri, Oct 15, 2021 at 3:50 PM Andrew MacLeod <amacl...@redhat.com> wrote: > > I've been looking at the pathological time issue ranger has with the > testcase from, uuuuuh.. PR 97623 I think. I've lost the details, but > kept the file since it was showing unpleasant behaviour. > > Most of the time is spent in callbacks from substitute_and_fold to > value_on_edge() dealing with PHI results and arguments. Turns out, its > virtually all wasted time dealing with SSA_NAMES with the > OCCURS_IN_ABNORMAL_PHI flag set.. > > This patch tells ranger not to consider any SSA_NAMEs which occur in > abnormal PHIs. This reduces the memory footprint of all the caches, and > also has a ripple effect with the new threader code which uses the GORI > exports and imports tables, making it faster as well as no ssa-name with > the abnormal flag set will be entered into the tables. > > That alone was not quite enough, as all the sheer volume of call backs > still took time, so I added checks in the value_of_* class of routines > used by substitute_and_fold to indicate there is no constant value > available for any SSA_NAME with that flag set. > > On my x86_64 box, before this change, that test case looked like: > > tree VRP : 7.76 ( 4%) 0.23 ( 5%) 8.02 > ( 4%) 537k ( 0%) > tree VRP threader : 7.20 ( 4%) 0.08 ( 2%) 7.28 ( > 4%) 392k ( 0%) > tree Early VRP : 39.22 ( 22%) 0.07 ( 2%) 39.44 ( > 22%) 1142k ( 0%) > > And with this patch , the results are: > > tree VRP : 7.57 ( 6%) 0.26 ( 5%) 7.85 > ( 6%) 537k ( 0%) > tree VRP threader : 0.62 ( 0%) 0.02 ( 0%) 0.65 > ( 0%) 392k ( 0%) > tree Early VRP : 4.00 ( 3%) 0.01 ( 0%) 4.03 > ( 3%) 1142k ( 0%) > > Which is a significant improvement, both for EVRP and the threader.. > > The patch adjusts the ranger folder, as well as the hybrid folder. > > bootstrapped on x86_64-pc-linux-gnu with no regressions and no missed > cases that I have been able to find. > > I don't want to push it quite yet as I wanted feedback to make sure we > don't actually do anything I'm not aware of with SSA_NAMES which have > the ABNORMAL_PHI flag set. Most of the code i can find in VRP and > vr-values appears to punt, so I presume not even considering those names > is fine? > > This also seems like something that might be worth back-porting, > especially the hybrid pass parts...
Returning NULL in gimple_range_ssa_p is probably not a good idea. The name does carry a range it just has to be considered VARYING. The issue with abnormal edges is that they do not have a jump associated with them and thus we cannot insert code on the edge because we cannot split it. That has implications for coalescing since we cannot even insert copies there so the PHI argument and the PHI result have to be the same register for the arguments on abnormal edges. Otherwise they do carry a value and a range but forcing that to be VARYING makes sense to avoid propagating constants to where it is not allowed (though the substitution phase should be the one checking). Richard. > Andrew > >