public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Scalar masks 2/x] Use bool masks in if-conversion
@ 2015-08-17 16:27 Ilya Enkovich
  2015-08-20 19:26 ` Jeff Law
  0 siblings, 1 reply; 48+ messages in thread
From: Ilya Enkovich @ 2015-08-17 16:27 UTC (permalink / raw)
  To: gcc-patches

Hi,

This patch intoriduces a new vectorizer hook use_scalar_mask_p which affects code generated by if-conversion pass (and affects patterns in later patches).

Thanks,
Ilya
--
2015-08-17  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* doc/tm.texi (TARGET_VECTORIZE_USE_SCALAR_MASK_P): New.
	* doc/tm.texi.in: Regenerated.
	* target.def (use_scalar_mask_p): New.
	* tree-if-conv.c: Include target.h.
	(predicate_mem_writes): Don't convert boolean predicates into
	integer when scalar masks are used.


diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 2383fb9..a124489 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -4233,6 +4233,8 @@ address;  but often a machine-dependent strategy can generate better code.
 
 @hook TARGET_VECTORIZE_DESTROY_COST_DATA
 
+@hook TARGET_VECTORIZE_USE_SCALAR_MASK_P
+
 @hook TARGET_VECTORIZE_BUILTIN_TM_LOAD
 
 @hook TARGET_VECTORIZE_BUILTIN_TM_STORE
diff --git a/gcc/target.def b/gcc/target.def
index 4edc209..0975bf3 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -1855,6 +1855,15 @@ DEFHOOK
  (void *data),
  default_destroy_cost_data)
 
+/* Target function to check scalar masks support.  */
+DEFHOOK
+(use_scalar_mask_p,
+ "This hook returns 1 if vectorizer should use scalar masks instead of "
+ "vector ones for MASK_LOAD, MASK_STORE and VEC_COND_EXPR.",
+ bool,
+ (void),
+ hook_bool_void_false)
+
 HOOK_VECTOR_END (vectorize)
 
 #undef HOOK_PREFIX
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 291e602..73dcecd 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -122,6 +122,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "insn-codes.h"
 #include "optabs.h"
 #include "tree-hash-traits.h"
+#include "target.h"
 
 /* List of basic blocks in if-conversion-suitable order.  */
 static basic_block *ifc_bbs;
@@ -2082,15 +2083,24 @@ predicate_mem_writes (loop_p loop)
 	      mask = vect_masks[index];
 	    else
 	      {
-		masktype = build_nonstandard_integer_type (bitsize, 1);
-		mask_op0 = build_int_cst (masktype, swap ? 0 : -1);
-		mask_op1 = build_int_cst (masktype, swap ? -1 : 0);
-		cond = force_gimple_operand_gsi_1 (&gsi, unshare_expr (cond),
-						   is_gimple_condexpr,
-						   NULL_TREE,
-						   true, GSI_SAME_STMT);
-		mask = fold_build_cond_expr (masktype, unshare_expr (cond),
-					     mask_op0, mask_op1);
+		if (targetm.vectorize.use_scalar_mask_p ())
+		  {
+		    masktype = boolean_type_node;
+		    mask = unshare_expr (cond);
+		  }
+		else
+		  {
+		    masktype = build_nonstandard_integer_type (bitsize, 1);
+		    mask_op0 = build_int_cst (masktype, swap ? 0 : -1);
+		    mask_op1 = build_int_cst (masktype, swap ? -1 : 0);
+		    cond = force_gimple_operand_gsi_1 (&gsi,
+						       unshare_expr (cond),
+						       is_gimple_condexpr,
+						       NULL_TREE,
+						       true, GSI_SAME_STMT);
+		    mask = fold_build_cond_expr (masktype, unshare_expr (cond),
+						 mask_op0, mask_op1);
+		  }
 		mask = ifc_temp_var (masktype, mask, &gsi);
 		/* Save mask and its size for further use.  */
 	        vect_sizes.safe_push (bitsize);

^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2015-09-25 14:39 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-17 16:27 [Scalar masks 2/x] Use bool masks in if-conversion Ilya Enkovich
2015-08-20 19:26 ` Jeff Law
2015-08-21  8:32   ` Richard Biener
2015-08-21 10:52     ` Ilya Enkovich
2015-08-21 11:15       ` Richard Biener
2015-08-21 12:19         ` Ilya Enkovich
2015-08-25 21:40           ` Jeff Law
2015-08-26 11:13             ` Ilya Enkovich
2015-08-26 13:09           ` Richard Biener
2015-08-26 13:21             ` Jakub Jelinek
2015-08-26 13:27               ` Richard Biener
2015-08-26 13:47                 ` Jakub Jelinek
2015-08-26 14:36                   ` Richard Biener
2015-08-26 14:51             ` Ilya Enkovich
2015-08-26 15:02               ` Richard Biener
2015-08-26 15:15                 ` Jakub Jelinek
2015-08-26 16:09                 ` Ilya Enkovich
2015-08-27  7:58                   ` Richard Biener
2015-09-01 13:13                     ` [RFC] Try vector<bool> as a new representation for vector masks Ilya Enkovich
2015-09-01 14:25                       ` Richard Biener
     [not found]                         ` <CAMbmDYafMuqzmRwRQfFHpLORFFGmFpfSRTR0QKx+LRFm6z75JQ@mail.gmail.com>
2015-09-03 12:12                           ` Ilya Enkovich
2015-09-03 12:42                             ` Richard Biener
2015-09-03 14:12                               ` Ilya Enkovich
2015-09-18 12:29                                 ` Richard Biener
2015-09-18 13:44                                   ` Ilya Enkovich
2015-09-23 13:46                                     ` Ilya Enkovich
2015-09-23 14:10                                       ` Richard Biener
2015-09-23 18:51                                         ` Richard Henderson
2015-09-24  8:40                                           ` Richard Biener
2015-09-24 16:55                                             ` Richard Henderson
2015-09-25  8:51                                               ` Richard Biener
2015-09-25 14:57                                         ` Ilya Enkovich
2015-09-23 13:50                                     ` Richard Biener
2015-09-04 20:47                       ` Jeff Law
2015-09-08 12:43                         ` Ilya Enkovich
2015-09-15 13:55                           ` Ilya Enkovich
2015-09-17 17:54                             ` Richard Henderson
2015-09-18 13:26                               ` Ilya Enkovich
2015-09-18 16:58                                 ` Richard Henderson
2015-09-21 12:21                                   ` Ilya Enkovich
2015-09-21 17:40                                     ` Richard Henderson
2015-09-18 12:45                             ` Richard Biener
2015-09-18 13:55                               ` Ilya Enkovich
2015-08-25 21:42       ` [Scalar masks 2/x] Use bool masks in if-conversion Jeff Law
2015-08-26 11:14         ` Ilya Enkovich
2015-08-26 13:12           ` Richard Biener
2015-08-26 16:58           ` Jeff Law
2015-08-21 15:57     ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).