Move uncprop after modref pass

Message ID 20211108175011.GA21089@kam.mff.cuni.cz
State Committed
Commit 666d780426f39883db8362f5cc24cdf9b4d3e98d
Headers
Series Move uncprop after modref pass |

Commit Message

Jan Hubicka Nov. 8, 2021, 5:50 p.m. UTC
  Hi,
this patch moves uncprop after modref and pure/const pass and adds a comment that
this pass should alwasy be last since it is only supposed to help PHI lowering.
The pass replaces constant by SSA names that are known to be constant at the
place which hardly helps other passes.

Modref now allows easily to compare ipa solutions with local solutions done
at compile time.  The local solutions should be monotonously better ideally
they should be the same showing that IPA machinery can do all we can do locally.

Neither is quite true. Building cc1plus we get
 - 1075 parameters whose EAF flags detected late are worse than those from IPA
   (1384 before the patch)
 - 5943 parameters whose EAF flags detected late are better than those from IPA
   (5766 before the patch)
 - 367 parameters whose RAF flags are changed (some better some worse)
   (375 before the patch)

Out of about 30k params tracked in 32k functions.
So not optimal, but still situation is noticeably better than before the patch
changing from

Alias oracle query stats:
  refs_may_alias_p: 76514746 disambiguations, 101144061 queries
  ref_maybe_used_by_call_p: 642091 disambiguations, 77522063 queries
  call_may_clobber_ref_p: 387354 disambiguations, 390389 queries
  nonoverlapping_component_refs_p: 0 disambiguations, 26150 queries
  nonoverlapping_refs_since_match_p: 30138 disambiguations, 65278 must overlaps, 96375 queries
  aliasing_component_refs_p: 57707 disambiguations, 15412274 queries
  TBAA oracle: 28146643 disambiguations 104216840 queries
               14970479 are in alias set 0
               8940210 queries asked about the same object
               117 queries asked about the same alias set
               0 access volatile
               50245719 are dependent in the DAG
               1913672 are aritificially in conflict with void *

Modref stats:
  modref use: 25185 disambiguations, 697431 queries
  modref clobber: 2333371 disambiguations, 22334828 queries
  5347614 tbaa queries (0.239429 per modref query)
  759061 base compares (0.033986 per modref query)

PTA query stats:
  pt_solution_includes: 13361936 disambiguations, 40666636 queries
  pt_solutions_intersect: 1589896 disambiguations, 13702105 queries

to

Alias oracle query stats:
  refs_may_alias_p: 76706288 disambiguations, 101289627 queries
  ref_maybe_used_by_call_p: 647660 disambiguations, 77711837 queries
  call_may_clobber_ref_p: 388155 disambiguations, 391104 queries
  nonoverlapping_component_refs_p: 0 disambiguations, 26150 queries
  nonoverlapping_refs_since_match_p: 30138 disambiguations, 65170 must overlaps, 96267 queries
  aliasing_component_refs_p: 57149 disambiguations, 15405496 queries
  TBAA oracle: 28122633 disambiguations 104205741 queries
               14987347 are in alias set 0
               8944156 queries asked about the same object
               99 queries asked about the same alias set
               0 access volatile
               50238319 are dependent in the DAG
               1913187 are aritificially in conflict with void *

Modref stats:
  modref use: 25273 disambiguations, 701571 queries
  modref clobber: 2337545 disambiguations, 22431672 queries
  5357026 tbaa queries (0.238815 per modref query)
  762911 base compares (0.034010 per modref query)

PTA query stats:
  pt_solution_includes: 13467699 disambiguations, 40734635 queries
  pt_solutions_intersect: 1681618 disambiguations, 13751306 queries

So we got 6% better on pt_soltions_intersect

Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

	PR tree-opt/103177
	* passes.def: Move uncprop after pure/const and modref.
  

Comments

Jeff Law Nov. 8, 2021, 6:32 p.m. UTC | #1
On 11/8/2021 11:50 AM, Jan Hubicka via Gcc-patches wrote:
> Hi,
> this patch moves uncprop after modref and pure/const pass and adds a comment that
> this pass should alwasy be last since it is only supposed to help PHI lowering.
> The pass replaces constant by SSA names that are known to be constant at the
> place which hardly helps other passes.
>
> Modref now allows easily to compare ipa solutions with local solutions done
> at compile time.  The local solutions should be monotonously better ideally
> they should be the same showing that IPA machinery can do all we can do locally.
>
> Neither is quite true. Building cc1plus we get
>   - 1075 parameters whose EAF flags detected late are worse than those from IPA
>     (1384 before the patch)
>   - 5943 parameters whose EAF flags detected late are better than those from IPA
>     (5766 before the patch)
>   - 367 parameters whose RAF flags are changed (some better some worse)
>     (375 before the patch)
>
> Out of about 30k params tracked in 32k functions.
> So not optimal, but still situation is noticeably better than before the patch
> changing from
>
> Alias oracle query stats:
>    refs_may_alias_p: 76514746 disambiguations, 101144061 queries
>    ref_maybe_used_by_call_p: 642091 disambiguations, 77522063 queries
>    call_may_clobber_ref_p: 387354 disambiguations, 390389 queries
>    nonoverlapping_component_refs_p: 0 disambiguations, 26150 queries
>    nonoverlapping_refs_since_match_p: 30138 disambiguations, 65278 must overlaps, 96375 queries
>    aliasing_component_refs_p: 57707 disambiguations, 15412274 queries
>    TBAA oracle: 28146643 disambiguations 104216840 queries
>                 14970479 are in alias set 0
>                 8940210 queries asked about the same object
>                 117 queries asked about the same alias set
>                 0 access volatile
>                 50245719 are dependent in the DAG
>                 1913672 are aritificially in conflict with void *
>
> Modref stats:
>    modref use: 25185 disambiguations, 697431 queries
>    modref clobber: 2333371 disambiguations, 22334828 queries
>    5347614 tbaa queries (0.239429 per modref query)
>    759061 base compares (0.033986 per modref query)
>
> PTA query stats:
>    pt_solution_includes: 13361936 disambiguations, 40666636 queries
>    pt_solutions_intersect: 1589896 disambiguations, 13702105 queries
>
> to
>
> Alias oracle query stats:
>    refs_may_alias_p: 76706288 disambiguations, 101289627 queries
>    ref_maybe_used_by_call_p: 647660 disambiguations, 77711837 queries
>    call_may_clobber_ref_p: 388155 disambiguations, 391104 queries
>    nonoverlapping_component_refs_p: 0 disambiguations, 26150 queries
>    nonoverlapping_refs_since_match_p: 30138 disambiguations, 65170 must overlaps, 96267 queries
>    aliasing_component_refs_p: 57149 disambiguations, 15405496 queries
>    TBAA oracle: 28122633 disambiguations 104205741 queries
>                 14987347 are in alias set 0
>                 8944156 queries asked about the same object
>                 99 queries asked about the same alias set
>                 0 access volatile
>                 50238319 are dependent in the DAG
>                 1913187 are aritificially in conflict with void *
>
> Modref stats:
>    modref use: 25273 disambiguations, 701571 queries
>    modref clobber: 2337545 disambiguations, 22431672 queries
>    5357026 tbaa queries (0.238815 per modref query)
>    762911 base compares (0.034010 per modref query)
>
> PTA query stats:
>    pt_solution_includes: 13467699 disambiguations, 40734635 queries
>    pt_solutions_intersect: 1681618 disambiguations, 13751306 queries
>
> So we got 6% better on pt_soltions_intersect
>
> Bootstrapped/regtested x86_64-linux, comitted.
>
> gcc/ChangeLog:
>
> 	PR tree-opt/103177
> 	* passes.def: Move uncprop after pure/const and modref.
OK.

jeff
  

Patch

diff --git a/gcc/passes.def b/gcc/passes.def
index 0f541454e7f..56dab80a029 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -360,9 +360,11 @@  along with GCC; see the file COPYING3.  If not see
          number of false positives from it.  */
       NEXT_PASS (pass_split_crit_edges);
       NEXT_PASS (pass_late_warn_uninitialized);
-      NEXT_PASS (pass_uncprop);
       NEXT_PASS (pass_local_pure_const);
       NEXT_PASS (pass_modref);
+      /* uncprop replaces constants by SSA names.  This makes analysis harder
+	 and thus it should be run last.  */
+      NEXT_PASS (pass_uncprop);
   POP_INSERT_PASSES ()
   NEXT_PASS (pass_all_optimizations_g);
   PUSH_INSERT_PASSES_WITHIN (pass_all_optimizations_g)
@@ -393,9 +395,11 @@  along with GCC; see the file COPYING3.  If not see
          number of false positives from it.  */
       NEXT_PASS (pass_split_crit_edges);
       NEXT_PASS (pass_late_warn_uninitialized);
-      NEXT_PASS (pass_uncprop);
       NEXT_PASS (pass_local_pure_const);
       NEXT_PASS (pass_modref);
+      /* uncprop replaces constants by SSA names.  This makes analysis harder
+	 and thus it should be run last.  */
+      NEXT_PASS (pass_uncprop);
   POP_INSERT_PASSES ()
   NEXT_PASS (pass_tm_init);
   PUSH_INSERT_PASSES_WITHIN (pass_tm_init)