]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-optimization/111137 - dependence checking for SLP
authorRichard Biener <rguenther@suse.de>
Fri, 25 Aug 2023 11:37:30 +0000 (13:37 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 15 Dec 2023 12:18:57 +0000 (13:18 +0100)
commite35556c61bdeb9f41b4111fffb423a705232ab9c
tree884c9afbae6dd682d7f2d6dcf5719680b4e41a68
parent4ef015bd9a87a06a0dae04a5bcf52a562046d1b6
tree-optimization/111137 - dependence checking for SLP

The following fixes a mistake with SLP dependence checking.  When
checking whether we can hoist loads to the first load place we
special-case stores of the same instance considering them sunk
to the last store place.  But we fail to consider that stores from
other SLP instances are sunk in a similar way.  This leads us to
miss the dependence between (A) and (B) in

  b[0][1] = 0;             (A)
...
  _6 = b[_5 /* 0 */][0];   (B')
  _7 = _6 ^ 1;
  b[_5 /* 0 */][0] = _7;
  b[0][2] = 0;             (A')
  _10 = b[_5 /* 0 */][1];  (B)
  _11 = _10 ^ 1;
  b[_5 /* 0 */][1] = _11;

where the zeroing stores are sunk to (A') and the loads hoisted
to (B').  The following fixes this, treating grouped stores from
other instances similar to stores from our own instance.  The
difference is - and this is more conservative than necessary - that
we don't know which stores of a group are in which SLP instance
(though I believe either all of the grouped stores will be in
a single SLP instance or in none at the moment), so we don't
know which stores are sunk where.  We simply assume they are
all sunk to the last store we run into.  Likewise we do not take
into account that an SLP instance might be cancelled (or a grouped
store not actually belong to any instance).

PR tree-optimization/111137
* tree-vect-data-refs.cc (vect_slp_analyze_load_dependences):
Properly handle grouped stores from other SLP instances.

* gcc.dg/torture/pr111137.c: New testcase.

(cherry picked from commit 845ee9c7107956845e487cb123fa581d9c70ea1b)
gcc/testsuite/gcc.dg/torture/pr111137.c [new file with mode: 0644]
gcc/tree-vect-data-refs.cc