]> git.ipfire.org Git - thirdparty/gcc.git/commit
middle-end: make memory analysis for early break more deterministic [PR113135]
authorTamar Christina <tamar.christina@arm.com>
Fri, 12 Jan 2024 15:24:49 +0000 (15:24 +0000)
committerTamar Christina <tamar.christina@arm.com>
Fri, 12 Jan 2024 15:24:49 +0000 (15:24 +0000)
commit6cb155a6cf314232248a12bdd395ed4151ae5a28
tree778cb185e087339d488e24b9737fe13568cfe391
parenta0e3d2ff6219d860c5108b3d1ff25a05a9a5559f
middle-end: make memory analysis for early break more deterministic [PR113135]

Instead of searching for where to move stores to, they should always be in
exit belonging to the latch.  We can only ever delay stores and even if we
pick a different exit than the latch one as the main one, effects still
happen in program order when vectorized.  If we don't move the stores to the
latch exit but instead to whever we pick as the "main" exit then we can
perform incorrect memory accesses (luckily these are trapped by verify_ssa).

We used to iterate over the conds and check the loads and stores inside them.
However this relies on the conds being ordered in program order.  Additionally
if there is a basic block between two conds we would not have analyzed it.

Instead this now walks from the preds of the destination basic block up to the
loop header and analyzes every block along the way.  As a later optimization we
could stop as soon as we've seen all the BBs we have conds for.  For now the
header will always contain the first cond, but this can change when we support
arbitrary control flow.

gcc/ChangeLog:

PR tree-optimization/113135
* tree-vect-data-refs.cc (vect_analyze_early_break_dependences): Rework
dependency analysis.

gcc/testsuite/ChangeLog:

PR tree-optimization/113135
* gcc.dg/vect/vect-early-break_103-pr113135.c: New test.
gcc/testsuite/gcc.dg/vect/vect-early-break_103-pr113135.c [new file with mode: 0644]
gcc/tree-vect-data-refs.cc