aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-patterns.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2017-12-08 08:06:31 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2017-12-08 08:06:31 +0000
commit8da4c8d83b7a21127cbe464aa54c5f3e7c034feb (patch)
treee7409b2670c511d8b3917122616fb4fbe1c09aa1 /gcc/tree-vect-patterns.c
parent5cb7ca60332394a1afa7ed03b70d7718bf86cda3 (diff)
downloadgcc-8da4c8d83b7a21127cbe464aa54c5f3e7c034feb.zip
gcc-8da4c8d83b7a21127cbe464aa54c5f3e7c034feb.tar.gz
gcc-8da4c8d83b7a21127cbe464aa54c5f3e7c034feb.tar.bz2
re PR tree-optimization/81303 (410.bwaves regression caused by r249919)
2017-12-08 Richard Biener <rguenther@suse.de> PR tree-optimization/81303 * tree-vect-stmts.c (vect_is_simple_cond): For invariant conditions try to create a comparison vector type matching the data vector type. (vectorizable_condition): Adjust. * tree-vect-patterns.c (vect_recog_mask_conversion_pattern): Leave invariant conditions alone in case we can vectorize those. * gcc.target/i386/vectorize9.c: New testcase. * gcc.target/i386/vectorize10.c: New testcase. From-SVN: r255497
Diffstat (limited to 'gcc/tree-vect-patterns.c')
-rw-r--r--gcc/tree-vect-patterns.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index e4051b6..a2c6293 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -3976,6 +3976,32 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_in,
|| TYPE_VECTOR_SUBPARTS (vectype1) == TYPE_VECTOR_SUBPARTS (vectype2))
return NULL;
+ /* If rhs1 is invariant and we can promote it leave the COND_EXPR
+ in place, we can handle it in vectorizable_condition. This avoids
+ unnecessary promotion stmts and increased vectorization factor. */
+ if (COMPARISON_CLASS_P (rhs1)
+ && INTEGRAL_TYPE_P (rhs1_type)
+ && TYPE_VECTOR_SUBPARTS (vectype1) < TYPE_VECTOR_SUBPARTS (vectype2))
+ {
+ gimple *dummy;
+ enum vect_def_type dt;
+ if (vect_is_simple_use (TREE_OPERAND (rhs1, 0), stmt_vinfo->vinfo,
+ &dummy, &dt)
+ && dt == vect_external_def
+ && vect_is_simple_use (TREE_OPERAND (rhs1, 1), stmt_vinfo->vinfo,
+ &dummy, &dt)
+ && (dt == vect_external_def
+ || dt == vect_constant_def))
+ {
+ tree wide_scalar_type = build_nonstandard_integer_type
+ (tree_to_uhwi (TYPE_SIZE (TREE_TYPE (vectype1))),
+ TYPE_UNSIGNED (rhs1_type));
+ tree vectype3 = get_vectype_for_scalar_type (wide_scalar_type);
+ if (expand_vec_cond_expr_p (vectype1, vectype3, TREE_CODE (rhs1)))
+ return NULL;
+ }
+ }
+
/* If rhs1 is a comparison we need to move it into a
separate statement. */
if (TREE_CODE (rhs1) != SSA_NAME)