From: Robin Dapp <[email protected]>

This series adds no-wrap assumptions to scev, data-ref analysis,
and the vectorizer.  It allows us to version a loop and assume
that no unsigned overflow/wraparound happens.
The general idea is to add an input/output parameter to scev, enabling
it to continue and store an assumption if it can't prove no overflow.
Scev users can then opt into assumptions but need to ensure they handle
the result properly.  The vectorizer does this via loop versioning.
As the machinery for niter versioning already exists we can re-use it and
add the no-wrap assumptions on top of the niter assumptions.

After this is in place, I believe we can also get rid of LOOP_C_FINITE.
I have a work-in-progress patch that does that but it will take
some more time to polish it.

Bootstrapped and regtested on x86, power10, and aarch64.
Regtested on riscv64.

There is a single new aarch64 FAIL in
gcc.target/aarch64/sve2/niter-convert-range.c.
which I haven't investigated yet.  I suppose adjusting test flags
or expectations is enough.  As I'm expecting comments and complaints
anyway, it didn't seem worth tackling for now.

Robin Dapp (5):
  niter: Add helper to compute type bound.
  scev: Add nowrap bound.
  dr: Add no-wrap bound.
  vect: Request no-wrap bounds from DR analysis.
  vect: Cost niter conditions.

 .../gcc.dg/tree-prof/update-loopch.c          |   2 +
 gcc/testsuite/gcc.dg/tree-ssa/scev-12.c       |   2 +-
 gcc/testsuite/gcc.dg/tree-ssa/scev-8.c        |   2 +-
 .../gcc.dg/vect/vect-unsigned-assump-1.c      |  22 ++
 .../gcc.dg/vect/vect-unsigned-assump-2.c      |  24 ++
 .../gcc.dg/vect/vect-unsigned-assump-3.c      |  20 ++
 .../gcc.dg/vect/vect-unsigned-assump-4.c      |  13 +
 .../gcc.dg/vect/vect-unsigned-assump-5.c      |  14 +
 .../gcc.dg/vect/vect-unsigned-assump-6.c      |  13 +
 .../gcc.dg/vect/vect-unsigned-assump-7.c      |  17 +
 .../gcc.dg/vect/vect-unsigned-assump-8.c      |  13 +
 gcc/tree-chrec.cc                             |  51 ++-
 gcc/tree-chrec.h                              |   7 +-
 gcc/tree-data-ref.cc                          |  78 +++-
 gcc/tree-data-ref.h                           |  13 +-
 gcc/tree-scalar-evolution.cc                  | 340 +++++++++++-------
 gcc/tree-scalar-evolution.h                   |   9 +-
 gcc/tree-ssa-loop-niter.cc                    |  64 +++-
 gcc/tree-ssa-loop-niter.h                     |   3 +-
 gcc/tree-ssa-loop.h                           |   4 +
 gcc/tree-vect-data-refs.cc                    |  15 +-
 gcc/tree-vect-loop.cc                         | 202 +++++++++--
 gcc/tree-vectorizer.h                         |   1 +
 23 files changed, 710 insertions(+), 219 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/vect/vect-unsigned-assump-1.c
 create mode 100644 gcc/testsuite/gcc.dg/vect/vect-unsigned-assump-2.c
 create mode 100644 gcc/testsuite/gcc.dg/vect/vect-unsigned-assump-3.c
 create mode 100644 gcc/testsuite/gcc.dg/vect/vect-unsigned-assump-4.c
 create mode 100644 gcc/testsuite/gcc.dg/vect/vect-unsigned-assump-5.c
 create mode 100644 gcc/testsuite/gcc.dg/vect/vect-unsigned-assump-6.c
 create mode 100644 gcc/testsuite/gcc.dg/vect/vect-unsigned-assump-7.c
 create mode 100644 gcc/testsuite/gcc.dg/vect/vect-unsigned-assump-8.c

-- 
2.54.0

Reply via email to