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