]> git.ipfire.org Git - thirdparty/gcc.git/commit
Use a single comparison for index-based alias checks
authorRichard Sandiford <richard.sandiford@arm.com>
Sat, 16 Nov 2019 11:43:31 +0000 (11:43 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Sat, 16 Nov 2019 11:43:31 +0000 (11:43 +0000)
commitf9d6338bd15ce1fae36bf25d3a0545e9678ddc58
treedf3f266e8905b2bb9efece9a71af140fced56abb
parentb4d1b635737a4780e5be247f8be9550eaf83dae5
Use a single comparison for index-based alias checks

This patch rewrites the index-based alias checks to use conditions
of the form:

  (unsigned T) (a - b + bias) <= limit

E.g. before the patch:

  struct s { int x[100]; };

  void
  f1 (struct s *s1, int a, int b)
  {
    for (int i = 0; i < 32; ++i)
      s1->x[i + a] += s1->x[i + b];
  }

used:

        add     w3, w1, 3
        cmp     w3, w2
        add     w3, w2, 3
        ccmp    w1, w3, 0, ge
        ble     .L2

whereas after the patch it uses:

        sub     w3, w1, w2
        add     w3, w3, 3
        cmp     w3, 6
        bls     .L2

The patch also fixes the seg_len1 and seg_len2 negation for cases in
which seg_len is a "negative unsigned" value narrower than 64 bits,
like it is for 32-bit targets.  Previously we'd end up with values
like 0xffffffff000000001 instead of 1.

2019-11-16  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
* tree-data-ref.c (create_intersect_range_checks_index): Rewrite
the index tests to have the form (unsigned T) (B - A + bias) <= limit.

gcc/testsuite/
* gcc.dg/vect/vect-alias-check-18.c: New test.
* gcc.dg/vect/vect-alias-check-19.c: Likewise.
* gcc.dg/vect/vect-alias-check-20.c: Likewise.

From-SVN: r278354
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/vect-alias-check-18.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-alias-check-19.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-alias-check-20.c [new file with mode: 0644]
gcc/tree-data-ref.c