This fixes the missed vectorization of gcc.dg/vect/pr65947-2.c following the
previous patch, by cleaning up:
i_49 = 1;
...
goto <bb 3>;
<bb 3>:
<bb 4>: <--- LOOP HEADER
# i_53 = PHI <i_42(7), i_49(3)>
into:
<bb 3>:
# i_53 = PHI <i_42(4), 1(2)>
Allowing scalar evolution and vectorization to proceed.
A similar sequence of partial peeling, header-copying, and constant propagation
also leads to pr65947-9.c successfully vectorizing (it previously didn't as
the iteration count was too high) when inlined and so using known data.
I'm not sure whether adding a pass_copy_prop is the right thing here, but since
loop-header-copying can create such opportunities, it seems good to take them!
gcc/ChangeLog:
* passes.def: Add a pass_copy_prop following pass_ch_vect.
gcc/testsuite/ChangeLog:
* gcc.dg/vect/pr65947-9.c: Add __attribute__ ((noinline)).
--Alan
---
gcc/passes.def | 1 +
gcc/testsuite/gcc.dg/vect/pr65947-9.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/gcc/passes.def b/gcc/passes.def
index 624d121..1043548 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -269,6 +269,7 @@ along with GCC; see the file COPYING3. If not see
NEXT_PASS (pass_expand_omp_ssa);
POP_INSERT_PASSES ()
NEXT_PASS (pass_ch_vect);
+ NEXT_PASS (pass_copy_prop);
NEXT_PASS (pass_if_conversion);
/* pass_vectorize must immediately follow pass_if_conversion.
Please do not add any other passes in between. */
diff --git a/gcc/testsuite/gcc.dg/vect/pr65947-9.c
b/gcc/testsuite/gcc.dg/vect/pr65947-9.c
index d0da13f..c7aac8d 100644
--- a/gcc/testsuite/gcc.dg/vect/pr65947-9.c
+++ b/gcc/testsuite/gcc.dg/vect/pr65947-9.c
@@ -7,7 +7,7 @@ extern void abort (void) __attribute__ ((noreturn));
/* Condition reduction with maximum possible loop size. Will fail to
vectorize because the vectorisation requires a slot for default values. */
-char
+__attribute__ ((noinline)) char
condition_reduction (char *a, char min_v)
{
char last = -72;
--
1.9.1