tree-optimization/103527 - always use thruth type forgather mask

Message ID 6o5r5295-rnss-4325-p8pp-q7974o22q4o@fhfr.qr
State Committed
Commit 70ece2d4ca403dfc6a837d876642378a8d4d3dce
Headers
Series tree-optimization/103527 - always use thruth type forgather mask |

Commit Message

Richard Biener Dec. 2, 2021, 12:31 p.m. UTC
  This makes sure to always use a truth type to build the gather
mask argument even when the target builtin prototype in the end
wants a float vector.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

2021-12-02  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/103527
	* tree-vect-stmts.c (vect_build_gather_load_calls): Always
	use a truth type for building the vector mask.
---
 gcc/tree-vect-stmts.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Patch

diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 9726450ab2d..e63bc2afdaa 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -2740,7 +2740,7 @@  vect_build_gather_load_calls (vec_info *vinfo, stmt_vec_info stmt_info,
 		       && (!mask
 			   || TREE_CODE (masktype) == INTEGER_TYPE
 			   || types_compatible_p (srctype, masktype)));
-  if (mask && TREE_CODE (masktype) == INTEGER_TYPE)
+  if (mask)
     masktype = truth_type_for (srctype);
 
   tree mask_halftype = masktype;
@@ -2893,7 +2893,8 @@  vect_build_gather_load_calls (vec_info *vinfo, stmt_vec_info stmt_info,
       if (masktype != real_masktype)
 	{
 	  tree utype, optype = TREE_TYPE (mask_op);
-	  if (TYPE_MODE (real_masktype) == TYPE_MODE (optype))
+	  if (VECTOR_TYPE_P (real_masktype)
+	      || TYPE_MODE (real_masktype) == TYPE_MODE (optype))
 	    utype = real_masktype;
 	  else
 	    utype = lang_hooks.types.type_for_mode (TYPE_MODE (optype), 1);