]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fixup partial_vectors_supported_p use
authorRichard Biener <rguenther@suse.de>
Thu, 26 Jun 2025 09:45:05 +0000 (11:45 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 27 Jun 2025 09:06:56 +0000 (11:06 +0200)
The following fixes the computation of supports_partial_vectors which
is used to prune the set of modes to iterate over for epilog
vectorization.  The used partial_vectors_supported_p predicate
only looks for while_ult while also support predication when
mask modes are integer modes as for AVX512.

I've noticed this isn't very effective on x86_64 anyway since
if the main loop mode is autodetected we skip re-analyzing
mode_i == 0, but then mode_i == 1 is usually the very same
large mode.  A patch for this will follow, but this will
regress without the fix below.

* tree-vect-loop.cc (vect_analyze_loop): Consider AVX512
style masking when computing supports_partial_vectors.

gcc/tree-vect-loop.cc

index 5b6769af31c305c9ae3d9405cd8ba13796da220a..18404f01c1eaff028ec2a8eee730230c29680515 100644 (file)
@@ -3701,8 +3701,15 @@ vect_analyze_loop (class loop *loop, gimple *loop_vectorized_call,
     vector_modes[0] = autodetected_vector_mode;
   mode_i = 0;
 
-  bool supports_partial_vectors =
-    partial_vectors_supported_p () && param_vect_partial_vector_usage != 0;
+  bool supports_partial_vectors = param_vect_partial_vector_usage != 0;
+  machine_mode mask_mode;
+  if (supports_partial_vectors
+      && !partial_vectors_supported_p ()
+      && !(VECTOR_MODE_P (first_loop_vinfo->vector_mode)
+          && targetm.vectorize.get_mask_mode
+               (first_loop_vinfo->vector_mode).exists (&mask_mode)
+          && SCALAR_INT_MODE_P (mask_mode)))
+    supports_partial_vectors = false;
   poly_uint64 first_vinfo_vf = LOOP_VINFO_VECT_FACTOR (first_loop_vinfo);
 
   loop_vec_info orig_loop_vinfo = first_loop_vinfo;