Loosen loop crossing restriction in threader.
authorAldy Hernandez <aldyh@redhat.com>
Tue, 5 Oct 2021 13:03:34 +0000 (15:03 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Tue, 5 Oct 2021 16:24:30 +0000 (18:24 +0200)
commitec0124e0acb556cdf5dba0e8d0ca6b69d9537fcc
tree644adb390be49233e736f3aa2639fe2da2b23bcc
parent1f51e9af7b615838424214e6aaea0de793cb10fe
Loosen loop crossing restriction in threader.

Crossing loops is generally discouraged from the threader, but we can
make an exception when we don't cross the latch or enter another loop,
since this is just an early exit out of the loop.

In fact, the whole threaded path is logically outside the loop.  This
has nice secondary effects.  For example, objects on the threaded path
will no longer necessarily be live throughout the loop, so we can get
register allocation improvements.  The threaded path can physically
move outside the loop resulting in better icache efficiency, etc.

Tested on x86-64 Linux, and on a visium-elf cross making sure that the
following tests do not have an abort in the final assembly:

gcc.c-torture/execute/960218-1.c
gcc.c-torture/execute/visium-pending-4.c
gcc.c-torture/execute/pr58209.c

gcc/ChangeLog:

* tree-ssa-threadupdate.c (jt_path_registry::cancel_invalid_paths):
Loosen restrictions

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/ssa-thread-valid.c: New test.
gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-valid.c [new file with mode: 0644]
gcc/tree-ssa-threadupdate.c