On 12/01/2022 11:59, Richard Biener wrote:
On Wed, 12 Jan 2022, Andre Vieira (lists) wrote:

On 12/01/2022 11:44, Richard Sandiford wrote:
Another alternative would be to push autodetected_vector_mode when the
length is 1 and keep 1 as the starting point.

Richard
I'm guessing we would still want to skip epilogue vectorization if
!VECTOR_MODE_P (autodetected_vector_mode) in that case?
Practically we currently only support fixed width word_mode there,
but eventually one could end up with 64bit DImode for the main loop
and 32bit V4QImode in the epilogue ... so not sure if it's worth
special-casing.  But I don't mind adding that skip.

Richard.

I left out the skip, it shouldn't break anything as it would try that same mode before anyway. Just to clarify what I meant though was to skip if autodetected_vector_mode wasn't a vector AND the target didn't define autovectorize_vector_modes, so in that scenario it wouldn't ever try  V4QImode for the epilogue if the mainloop was autodetected DImode, I think... Either way, this is less code, less complicated and doesn't analyze more than it did before the original patch, so I'm happy with that too.

Is this what you had in mind?

Andre
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 
6ed2b5f8724e5ebf27592f67d7f6bdfe1ebcf512..03459363afa48f0e2753bc7aa18cbf2771d2a4e5
 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -3023,7 +3023,16 @@ vect_analyze_loop (class loop *loop, vec_info_shared 
*shared)
      array may contain length-agnostic and length-specific modes.  Their
      ordering is not guaranteed, so we could end up picking a mode for the main
      loop that is after the epilogue's optimal mode.  */
-  mode_i = 1;
+  if (vector_modes.length () == 1)
+    {
+      /* If we only had VOIDmode then use AUTODETECTED_VECTOR_MODE to see if
+        an epilogue can be created with that mode.  */
+      vector_modes[0] = autodetected_vector_mode;
+      mode_i = 0;
+    }
+  else
+    mode_i = 1;
+
   bool supports_partial_vectors = partial_vectors_supported_p ();
   poly_uint64 first_vinfo_vf = LOOP_VINFO_VECT_FACTOR (first_loop_vinfo);
 

Reply via email to