public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* New warning for expanded vector operations
@ 2011-10-04 22:25 Artem Shinkarov
  2011-10-05  8:40 ` Richard Guenther
  0 siblings, 1 reply; 19+ messages in thread
From: Artem Shinkarov @ 2011-10-04 22:25 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 689 bytes --]

Hi

Here is a patch to inform a programmer about the expanded vector operation.
Bootstrapped on x86-unknown-linux-gnu.

ChangeLog:

        * gcc/tree-vect-generic.c (expand_vector_piecewise): Adjust to
          produce the warning.
          (expand_vector_parallel): Adjust to produce the warning.
          (lower_vec_shuffle): Adjust to produce the warning.
        * gcc/common.opt: New warning Wvector-operation-expanded.
        * gcc/doc/invoke.texi: Document the wawning.


Ok?


Thanks,
Artem Shinkarov.

P.S. It is hard to write a reasonable testcase for the patch, because
one needs to guess which architecture would expand a given vector
operation. But the patch is trivial.

[-- Attachment #2: vector-op-warning.diff --]
[-- Type: text/plain, Size: 4277 bytes --]

Index: gcc/tree-vect-generic.c
===================================================================
--- gcc/tree-vect-generic.c	(revision 179464)
+++ gcc/tree-vect-generic.c	(working copy)
@@ -235,6 +235,10 @@ expand_vector_piecewise (gimple_stmt_ite
   int delta = tree_low_cst (part_width, 1)
 	      / tree_low_cst (TYPE_SIZE (TREE_TYPE (type)), 1);
   int i;
+  location_t loc = gimple_location (gsi_stmt (*gsi));
+
+  warning_at (loc, OPT_Wvector_operation_expanded,
+	      "vector operation will be expanded piecewise");
 
   v = VEC_alloc(constructor_elt, gc, (nunits + delta - 1) / delta);
   for (i = 0; i < nunits;
@@ -260,6 +264,10 @@ expand_vector_parallel (gimple_stmt_iter
   tree result, compute_type;
   enum machine_mode mode;
   int n_words = tree_low_cst (TYPE_SIZE_UNIT (type), 1) / UNITS_PER_WORD;
+  location_t loc = gimple_location (gsi_stmt (*gsi));
+
+  warning_at (loc, OPT_Wvector_operation_expanded,
+	      "vector operation will be expanded in parallel");
 
   /* We have three strategies.  If the type is already correct, just do
      the operation an element at a time.  Else, if the vector is wider than
@@ -301,16 +309,15 @@ expand_vector_addition (gimple_stmt_iter
 {
   int parts_per_word = UNITS_PER_WORD
 	  	       / tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (type)), 1);
+  location_t loc = gimple_location (gsi_stmt (*gsi));
 
   if (INTEGRAL_TYPE_P (TREE_TYPE (type))
       && parts_per_word >= 4
       && TYPE_VECTOR_SUBPARTS (type) >= 4)
-    return expand_vector_parallel (gsi, f_parallel,
-				   type, a, b, code);
+    return expand_vector_parallel (gsi, f_parallel, type, a, b, code);
   else
-    return expand_vector_piecewise (gsi, f,
-				    type, TREE_TYPE (type),
-				    a, b, code);
+    return expand_vector_piecewise (gsi, f, type,
+				    TREE_TYPE (type), a, b, code);
 }
 
 /* Check if vector VEC consists of all the equal elements and
@@ -400,8 +407,8 @@ expand_vector_operation (gimple_stmt_ite
       case PLUS_EXPR:
       case MINUS_EXPR:
         if (!TYPE_OVERFLOW_TRAPS (type))
-          return expand_vector_addition (gsi, do_binop, do_plus_minus, type,
-		      		         gimple_assign_rhs1 (assign),
+	  return expand_vector_addition (gsi, do_binop, do_plus_minus, type,
+					 gimple_assign_rhs1 (assign),
 					 gimple_assign_rhs2 (assign), code);
 	break;
 
@@ -622,6 +629,8 @@ lower_vec_shuffle (gimple_stmt_iterator
       return true;
     }
 
+  warning_at (loc, OPT_Wvector_operation_expanded,
+	      "vector shuffling operation will be expanded piecewise");
   if (operand_equal_p (vec0, vec1, 0))
     {
       unsigned i;
Index: gcc/common.opt
===================================================================
--- gcc/common.opt	(revision 179464)
+++ gcc/common.opt	(working copy)
@@ -694,6 +694,10 @@ Wcoverage-mismatch
 Common Var(warn_coverage_mismatch) Init(1) Warning
 Warn in case profiles in -fprofile-use do not match
 
+Wvector-operation-expanded
+Common Var(warn_vector_operation_expanded) Warning
+Warn when a vector operation is expanded piecewise
+
 Xassembler
 Driver Separate
 
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi	(revision 179464)
+++ gcc/doc/invoke.texi	(working copy)
@@ -271,7 +271,8 @@ Objective-C and Objective-C++ Dialects}.
 -Wunused-label  -Wunused-local-typedefs -Wunused-parameter @gol
 -Wno-unused-result -Wunused-value @gol -Wunused-variable @gol
 -Wunused-but-set-parameter -Wunused-but-set-variable @gol
--Wvariadic-macros -Wvla -Wvolatile-register-var  -Wwrite-strings}
+-Wvariadic-macros -Wvector-operation-expanded -Wvla 
+-Wvolatile-register-var  -Wwrite-strings}
 
 @item C and Objective-C-only Warning Options
 @gccoptlist{-Wbad-function-cast  -Wmissing-declarations @gol
@@ -4532,6 +4533,12 @@ Warn if variadic macros are used in peda
 alternate syntax when in pedantic ISO C99 mode.  This is default.
 To inhibit the warning messages, use @option{-Wno-variadic-macros}.
 
+@item -Wvector-operation-expanded
+@opindex Wvector-operation-expanded
+@opindex Wno-vector-operation-expanded
+Warn if vector operation is not implemented via SIMD capabilities of the
+architecture. Mainly useful for the performance tuning.
+
 @item -Wvla
 @opindex Wvla
 @opindex Wno-vla

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

end of thread, other threads:[~2011-10-14 18:03 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-04 22:25 New warning for expanded vector operations Artem Shinkarov
2011-10-05  8:40 ` Richard Guenther
2011-10-05 11:31   ` Artem Shinkarov
2011-10-05 11:37     ` Richard Guenther
2011-10-07  7:13       ` Artem Shinkarov
2011-10-07  8:01         ` Artem Shinkarov
2011-10-10 11:15           ` Richard Guenther
2011-10-10 13:27             ` Artem Shinkarov
2011-10-11 11:40               ` Richard Guenther
2011-10-11 17:26                 ` Artem Shinkarov
2011-10-12 16:25                   ` H.J. Lu
2011-10-12 22:10                     ` Artem Shinkarov
2011-10-13  9:32                       ` Mike Stump
2011-10-13 10:17                         ` Richard Guenther
2011-10-13 10:18                           ` Artem Shinkarov
2011-10-14 14:02                             ` Artem Shinkarov
2011-10-14 14:15                               ` Richard Guenther
2011-10-14 16:05                                 ` Artem Shinkarov
2011-10-14 18:31                                   ` Mike Stump

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).