[vect] : fix prologue peeling dominator updates [PR125509]
Checks
Commit Message
In the change to enable vectorization without needing a scalar epilogue I
disabled the dominators update for prolog peeling with the assumption that since
I don't need to go to rewire the exits when we vectorize the main loop we don't
end up with the complicated merge block for which the updates were needed.
And indeed no test failed. But it turns out we now get a different form so the
updates are still needed. The merge block is still a mess so determining
manually who is the new dominator of whom is still quite difficult so I couldn't
simplify the updates.
This re-enabled dominator updates after prolog peeling.
Bootstrapped Regtested on aarch64-none-linux-gnu,
arm-none-linux-gnueabihf, x86_64-pc-linux-gnu
-m32, -m64 and no issues.
Pushed.
Thanks,
Tamar
gcc/ChangeLog:
PR tree-optimization/125509
* tree-vect-loop-manip.cc (vect_do_peeling): Re-enable dominators
update for prolog peeling.
gcc/testsuite/ChangeLog:
PR tree-optimization/125509
* gcc.dg/vect/pr125509.c: New test.
---
--
new file mode 100644
@@ -0,0 +1,31 @@
+/* { dg-add-options vect_early_break } */
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_early_break } */
+/* { dg-require-effective-target vect_int } */
+
+struct a {
+ char *b;
+ long c;
+} e;
+long d;
+char f;
+static bool g(char *h, long j) {
+ auto i = h + j - 1;
+ for (; h != i; h++)
+ if (*h)
+ return false;
+ return f;
+}
+void k();
+static void l(struct a h) {
+ if (!g(h.b, h.c))
+ if (d)
+ k();
+}
+void m() {
+ if (e.c != 1)
+ l(e);
+}
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
+/* { dg-final { scan-tree-dump "early break does not require epilog" "vect" } } */
@@ -3506,12 +3506,11 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1,
/* Peel prolog and put it on preheader edge of loop. */
edge scalar_e = LOOP_VINFO_SCALAR_MAIN_EXIT (loop_vinfo);
edge prolog_e = NULL;
- bool early_break_peel_p = LOOP_VINFO_EARLY_BRK_NEEDS_EPILOG (loop_vinfo);
prolog = slpeel_tree_duplicate_loop_to_edge_cfg (loop, exit_e,
scalar_loop, scalar_e,
e, &prolog_e, true, NULL,
uncounted_p, uncounted_p,
- early_break_peel_p);
+ false);
gcc_assert (prolog);
prolog->force_vectorize = false;
@@ -3678,7 +3677,6 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1,
/* Handle any remaining dominator updates needed after
inserting the loop skip edge above. */
if (LOOP_VINFO_EARLY_BREAKS (loop_vinfo)
- && LOOP_VINFO_EARLY_BRK_NEEDS_EPILOG (loop_vinfo)
&& prolog_peeling)
{
/* Adding a skip edge to skip a loop with multiple exits