]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix handling of static exists in loop_ch
authorJan Hubicka <jh@suse.cz>
Wed, 23 Aug 2023 09:17:20 +0000 (11:17 +0200)
committerJan Hubicka <jh@suse.cz>
Wed, 23 Aug 2023 09:17:20 +0000 (11:17 +0200)
commit936a12331a2bd95e9003221e292719b7ffcf07d0
tree361e3311595ebc3b99506a8af574dc8672357955
parent7a2e232fa6e0ce2120dedcb340d683f6ac9b3f19
Fix handling of static exists in loop_ch

This patch fixes wrong return value in should_duplicate_loop_header_p.
Doing so uncovered suboptimal decisions on some jump threading testcases
where we choose to stop duplicating just before basic block that has zero
cost and duplicating so would be always a win.

This is because the heuristics trying to choose right point to duplicate
all winning blocks and to get loop to be do_while did not account
zero_cost blocks in all cases.  The patch simplifies the logic by
simply remembering zero cost blocks and handling them last after
the right stopping point is chosen.

gcc/ChangeLog:

* tree-ssa-loop-ch.cc (enum ch_decision): Fix comment.
(should_duplicate_loop_header_p): Fix return value for static exits.
(ch_base::copy_headers): Improve handling of ch_possible_zero_cost.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/copy-headers-9.c: Update template.
gcc/testsuite/gcc.dg/tree-ssa/copy-headers-9.c
gcc/tree-ssa-loop-ch.cc