diff options
author | Richard Biener <rguenther@suse.de> | 2024-01-24 14:55:49 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2024-01-25 08:37:37 +0100 |
commit | 578c7b91f418ebbef1bf169117815409e06f5197 (patch) | |
tree | 384a8c30ec3dafd6d8e2d05f46dbb99384f67196 /gcc/tree-vect-loop.cc | |
parent | 0801a88af40e4bb41c240788a2365ca1e30e281a (diff) | |
download | gcc-578c7b91f418ebbef1bf169117815409e06f5197.zip gcc-578c7b91f418ebbef1bf169117815409e06f5197.tar.gz gcc-578c7b91f418ebbef1bf169117815409e06f5197.tar.bz2 |
tree-optimization/113576 - non-empty latch and may_be_zero vectorization
We can't support niters with may_be_zero when we end up with a
non-empty latch due to early exit peeling. At least not in
the simplistic way the vectorizer handles this now. Disallow
it again for exits that are not the last one.
PR tree-optimization/113576
* tree-vect-loop.cc (vec_init_loop_exit_info): Only allow
exits with may_be_zero niters when its the last one.
* gcc.dg/vect/pr113576.c: New testcase.
Diffstat (limited to 'gcc/tree-vect-loop.cc')
-rw-r--r-- | gcc/tree-vect-loop.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 21a9975..30b90d9 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -991,8 +991,13 @@ vec_init_loop_exit_info (class loop *loop) { tree may_be_zero = niter_desc.may_be_zero; if ((integer_zerop (may_be_zero) - || integer_nonzerop (may_be_zero) - || COMPARISON_CLASS_P (may_be_zero)) + /* As we are handling may_be_zero that's not false by + rewriting niter to may_be_zero ? 0 : niter we require + an empty latch. */ + || (single_pred_p (loop->latch) + && exit->src == single_pred (loop->latch) + && (integer_nonzerop (may_be_zero) + || COMPARISON_CLASS_P (may_be_zero)))) && (!candidate || dominated_by_p (CDI_DOMINATORS, exit->src, candidate->src))) |