https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126332

--- Comment #1 from Drea Pinski <pinskia at gcc dot gnu.org> ---
This pass was originally an RTL pass but it was moved to gimple at
r0-83240-g232abc3ff8954a . 

https://inbox.sourceware.org/gcc-patches/[email protected]/

But the problem is we don't form ifcvt until afterwards.

Looks like we need to reorg passes.

This is the current late post loop optimization pass list:
```
      NEXT_PASS (pass_simduid_cleanup);
      NEXT_PASS (pass_lower_vector_ssa);
      NEXT_PASS (pass_lower_switch);
      NEXT_PASS (pass_cse_sincos);
      NEXT_PASS (pass_cse_reciprocals);
      NEXT_PASS (pass_reassoc, false /* early_p */);
      NEXT_PASS (pass_strength_reduction);
      NEXT_PASS (pass_tracer);
      NEXT_PASS (pass_fre, false /* may_iterate */);
      /* After late FRE we rewrite no longer addressed locals into SSA
         form if possible.  */
      NEXT_PASS (pass_thread_jumps, /*first=*/false);
      NEXT_PASS (pass_dominator, false /* may_peel_loop_headers_p */);
      NEXT_PASS (pass_strlen);
      NEXT_PASS (pass_thread_jumps_full, /*first=*/false);
      NEXT_PASS (pass_vrp, true /* final_p */);
      /* Run CCP to compute alignment and nonzero bits.  */
      NEXT_PASS (pass_ccp, true /* nonzero_p */);
      NEXT_PASS (pass_warn_restrict);
      NEXT_PASS (pass_dse);
      NEXT_PASS (pass_dce, true /* update_address_taken_p */, true /*
remove_unused_locals */);
      /* After late DCE we rewrite no longer addressed locals into SSA
         form if possible.  */
      NEXT_PASS (pass_forwprop, /*full_walk=*/false, /*last=*/true);
      NEXT_PASS (pass_sink_code, true /* unsplit edges */);
      NEXT_PASS (pass_phiopt, false /* early_p */);
      NEXT_PASS (pass_optimize_widening_mul);
      NEXT_PASS (pass_store_merging);
      /* If DCE is not run before checking for uninitialized uses,
         we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c).
         However, this also causes us to misdiagnose cases that should be
         real warnings (e.g., testsuite/gcc.dg/pr18501.c).  */
      NEXT_PASS (pass_cd_dce, false /* update_address_taken_p */);
      NEXT_PASS (pass_sccopy);
      NEXT_PASS (pass_tail_calls);

```


I am not even sure supperblock formation is needed except for the RTL level.
But then things get complex as we don't do ifcvt/cmov/csel formation during
RTL.
Also I am not sure supperblock formation is actually better to do in general.

I understand what is trying to a similar as path splitting but both really
should be after ifcvt I think.

I wonder if we could convert tracer back to a RTL pass and move it back to
right before the RTL loop opts.

Things has changed so much since 2007 with respect of passes on the gimple and
rtl level even.

The other thing is the pre-loop optmization passes seems too much too:
```
      NEXT_PASS (pass_remove_cgraph_callee_edges);
      /* Initial scalar cleanups before alias computation.
         They ensure memory accesses are not indirect wherever possible.  */
      NEXT_PASS (pass_strip_predict_hints, false /* early_p */);
      NEXT_PASS (pass_ccp, true /* nonzero_p */);
      /* After CCP we rewrite no longer addressed locals into SSA
         form if possible.  */
      NEXT_PASS (pass_object_sizes);
      NEXT_PASS (pass_post_ipa_warn);
      /* Must run before loop unrolling.  */
      NEXT_PASS (pass_warn_access, /*early=*/false, /*check_dangling=*/true);
      /* Profile count may overflow as a result of inlinining very large
         loop nests.  This pass should run before any late pass that makes
         use of profile.  */
      NEXT_PASS (pass_rebuild_frequencies);
      NEXT_PASS (pass_complete_unrolli);
      NEXT_PASS (pass_backprop);
      NEXT_PASS (pass_phiprop);
      NEXT_PASS (pass_forwprop, /*full_walk=*/true);
      /* pass_build_alias is a dummy pass that ensures that we
         execute TODO_rebuild_alias at this point.  */
      NEXT_PASS (pass_build_alias);
      NEXT_PASS (pass_return_slot);
      NEXT_PASS (pass_fre, true /* may_iterate */);
      NEXT_PASS (pass_merge_phi);
      NEXT_PASS (pass_thread_jumps_full, /*first=*/true);
      NEXT_PASS (pass_vrp, false /* final_p*/);
      NEXT_PASS (pass_array_bounds);
      NEXT_PASS (pass_dse);
      NEXT_PASS (pass_dce, false /* update_address_taken_p */, true /*
remove_unused_locals */);
      NEXT_PASS (pass_stdarg);
      NEXT_PASS (pass_call_cdce);
      NEXT_PASS (pass_cselim);
      NEXT_PASS (pass_copy_prop);
      NEXT_PASS (pass_tree_ifcombine);
      NEXT_PASS (pass_merge_phi);
      NEXT_PASS (pass_phiopt, false /* early_p */);
      NEXT_PASS (pass_tail_recursion);
      NEXT_PASS (pass_ch);
      NEXT_PASS (pass_lower_complex);
      NEXT_PASS (pass_lower_bitint);
      NEXT_PASS (pass_sra);
      /* The dom pass will also resolve all __builtin_constant_p calls
         that are still there to 0.  This has to be done after some
         propagations have already run, but before some more dead code
         is removed, and this place fits nicely.  Remember this when
         trying to move or duplicate pass_dominator somewhere earlier.  */
      NEXT_PASS (pass_thread_jumps, /*first=*/true);
      NEXT_PASS (pass_dominator, true /* may_peel_loop_headers_p */);
      /* Threading can leave many const/copy propagations in the IL.
         Clean them up.  Failure to do so well can lead to false
         positives from warnings for erroneous code.  */
      NEXT_PASS (pass_copy_prop);
      /* Identify paths that should never be executed in a conforming
         program and isolate those paths.  */
      NEXT_PASS (pass_isolate_erroneous_paths);
      NEXT_PASS (pass_reassoc, true /* early_p */);
      NEXT_PASS (pass_dce);
      NEXT_PASS (pass_forwprop);
      NEXT_PASS (pass_phiopt, false /* early_p */);
      NEXT_PASS (pass_ccp, true /* nonzero_p */);
      /* After CCP we rewrite no longer addressed locals into SSA
         form if possible.  */
      NEXT_PASS (pass_expand_pow);
      NEXT_PASS (pass_optimize_bswap);
      NEXT_PASS (pass_laddress);
      NEXT_PASS (pass_lim);
      NEXT_PASS (pass_walloca, false);
      NEXT_PASS (pass_pre);
      NEXT_PASS (pass_sink_code, false /* unsplit edges */);
```

I am not sure the second phiopt does anything but I could be wrong.

Reply via email to