With -Os we inhibit most loop header copying which in turn will disable
any vectorization attempt either via -fopenmp or via -ftree-vectorize.

The following makes sure the aggressive gate in 
should_duplicate_loop_header_p is not applied for force-vectorize loops.
There's still PARAM_MAX_LOOP_HEADER_INSNS limiting growth.

This reportedly makes -fopenmp -Os vectorize loops properly.

Bootstrap / regtest running on x86_64-unknown-linux-gnu.

Is this OK for trunk (and branches?) or do we want sth different
in the end?

Thanks,
Richard.

2018-03-09  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/84777
        * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): For
        force-vectorize loops ignore whether we are optimizing for size.

Index: gcc/tree-ssa-loop-ch.c
===================================================================
--- gcc/tree-ssa-loop-ch.c      (revision 258380)
+++ gcc/tree-ssa-loop-ch.c      (working copy)
@@ -57,7 +57,8 @@ should_duplicate_loop_header_p (basic_bl
      be true, since quite often it is possible to verify that the condition is
      satisfied in the first iteration and therefore to eliminate it.  Jump
      threading handles these cases now.  */
-  if (optimize_loop_for_size_p (loop))
+  if (optimize_loop_for_size_p (loop)
+      && !loop->force_vectorize)
     {
       if (dump_file && (dump_flags & TDF_DETAILS))
        fprintf (dump_file,

Reply via email to