]> git.ipfire.org Git - thirdparty/gcc.git/commit
middle-end: correctly identify the edge taken when condition is true. [PR113287]
authorTamar Christina <tamar.christina@arm.com>
Wed, 10 Jan 2024 14:31:02 +0000 (14:31 +0000)
committerTamar Christina <tamar.christina@arm.com>
Wed, 10 Jan 2024 14:31:57 +0000 (14:31 +0000)
commit91fd5c94965b4077490c6bfcc9aa4b0e4146b38a
tree6b0b956fe0cfb4a301857c894796476cd0fb3ad5
parentcac9d2d2346bf06b29b34e12cf0a005c37eacdc9
middle-end: correctly identify the edge taken when condition is true. [PR113287]

The vectorizer needs to know during early break vectorization whether the edge
that will be taken if the condition is true stays or leaves the loop.

This is because the code assumes that if you take the true branch you exit the
loop.  If you don't exit the loop it has to generate a different condition.

Basically it uses this information to decide whether it's generating a
"any element" or an "all element" check.

Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu
and no issues with --enable-lto --with-build-config=bootstrap-O3
--enable-checking=release,yes,rtl,extra.

gcc/ChangeLog:

PR tree-optimization/113287
* tree-vect-stmts.cc (vectorizable_early_exit): Check the flags on edge
instead of using BRANCH_EDGE to determine true edge.

gcc/testsuite/ChangeLog:

PR tree-optimization/113287
* gcc.dg/vect/vect-early-break_100-pr113287.c: New test.
* gcc.dg/vect/vect-early-break_99-pr113287.c: New test.
gcc/testsuite/gcc.dg/vect/vect-early-break_100-pr113287.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-early-break_99-pr113287.c [new file with mode: 0644]
gcc/tree-vect-stmts.cc