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

--- Comment #5 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Drea Pinski from comment #4)
> You have to add a clone method to cprop_hardreg. After that it should just
> work :).
Cutting some corners and just moving pass_cprop_hardreg after
pass_reorder_blocks:

diff --git a/gcc/passes.def b/gcc/passes.def
index cdddb87302f..673bf3ebe46 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -540,9 +540,9 @@ along with GCC; see the file COPYING3.  If not see
          NEXT_PASS (pass_dep_fusion);
          NEXT_PASS (pass_regrename);
          NEXT_PASS (pass_fold_mem_offsets);
-         NEXT_PASS (pass_cprop_hardreg);
          NEXT_PASS (pass_fast_rtl_dce);
          NEXT_PASS (pass_reorder_blocks);
+         NEXT_PASS (pass_cprop_hardreg);
          NEXT_PASS (pass_leaf_regs);
          NEXT_PASS (pass_split_before_sched2);
          NEXT_PASS (pass_sched2);

results in:

 .L4:
-       movl    %eax, %ecx
        cmpl    %esi, (%eax)
        jne     .L11
-       movl    %ecx, %eax
        popl    %ebx

But the pass *does not* perform the trivial propagation of %ecx to %eax in the
final BB. The change even slightly regresses linux code size:

$ size *.o
   text    data     bss     dec     hex filename
29434169        4932443  754228 35120840        217e6c8 vmlinux-cprop.o
29415516        4932443  754228 35102187        2179deb vmlinux-new.o
29432351        4932443  754228 35119022        217dfae vmlinux-old.o

Reply via email to