From 784fb9b322452e7f5e31e75be538ccf453335abb Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <jakub@redhat.com>
Date: Tue, 13 Nov 2012 08:25:36 +0100
Subject: re PR tree-optimization/55281 (ICE in  build_int_cst_wide, at
 tree.c:1217  (with Ofast, ok with O3))

	PR tree-optimization/55281
	* tree-vect-generic.c (expand_vector_condition): Accept any
	is_gimple_val rather than just SSA_NAME if not COMPARISON_CLASS_P.
	* fold-const.c (fold_ternary_loc): Fold VEC_COND_EXPR if arg0 is
	either integer_all_onesp or integer_zerop.
	* tree-vect-stmts.c (vectorizable_condition): Build the condition
	using corresponding vector integer type instead of vectype.

	* gcc.dg/vect/fast-math-pr55281.c: New test.
	* g++.dg/opt/pr55281.C: New test.

From-SVN: r193471
---
 gcc/tree-vect-stmts.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

(limited to 'gcc/tree-vect-stmts.c')

diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 2731084..2f4be11 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -5310,6 +5310,7 @@ vectorizable_condition (gimple stmt, gimple_stmt_iterator *gsi,
   bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info);
   VEC (tree, heap) *vec_oprnds0 = NULL, *vec_oprnds1 = NULL;
   VEC (tree, heap) *vec_oprnds2 = NULL, *vec_oprnds3 = NULL;
+  tree vec_cmp_type = vectype;
 
   if (slp_node || PURE_SLP_STMT (stmt_info))
     ncopies = 1;
@@ -5382,6 +5383,15 @@ vectorizable_condition (gimple stmt, gimple_stmt_iterator *gsi,
 	   && TREE_CODE (else_clause) != FIXED_CST)
     return false;
 
+  if (!INTEGRAL_TYPE_P (TREE_TYPE (vectype)))
+    {
+      unsigned int prec = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (vectype)));
+      tree cmp_type = build_nonstandard_integer_type (prec, 1);
+      vec_cmp_type = get_same_sized_vectype (cmp_type, vectype);
+      if (vec_cmp_type == NULL_TREE)
+	return false;
+    }
+
   if (!vec_stmt)
     {
       STMT_VINFO_TYPE (stmt_info) = condition_vec_info_type;
@@ -5488,8 +5498,8 @@ vectorizable_condition (gimple stmt, gimple_stmt_iterator *gsi,
           vec_then_clause = VEC_index (tree, vec_oprnds2, i);
           vec_else_clause = VEC_index (tree, vec_oprnds3, i);
 
-          vec_compare = build2 (TREE_CODE (cond_expr), vectype,
-  			       vec_cond_lhs, vec_cond_rhs);
+	  vec_compare = build2 (TREE_CODE (cond_expr), vec_cmp_type,
+				vec_cond_lhs, vec_cond_rhs);
           vec_cond_expr = build3 (VEC_COND_EXPR, vectype,
  		         vec_compare, vec_then_clause, vec_else_clause);
 
-- 
cgit v1.1