OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / tree-vect-generic.c
index 42ce2e3..9dec8c6 100644 (file)
@@ -125,8 +125,10 @@ static tree
 do_binop (gimple_stmt_iterator *gsi, tree inner_type, tree a, tree b,
          tree bitpos, tree bitsize, enum tree_code code)
 {
-  a = tree_vec_extract (gsi, inner_type, a, bitsize, bitpos);
-  b = tree_vec_extract (gsi, inner_type, b, bitsize, bitpos);
+  if (TREE_CODE (TREE_TYPE (a)) == VECTOR_TYPE)
+    a = tree_vec_extract (gsi, inner_type, a, bitsize, bitpos);
+  if (TREE_CODE (TREE_TYPE (b)) == VECTOR_TYPE)
+    b = tree_vec_extract (gsi, inner_type, b, bitsize, bitpos);
   return gimplify_build2 (gsi, code, inner_type, a, b);
 }
 
@@ -647,7 +649,7 @@ lower_vec_perm (gimple_stmt_iterator *gsi)
       tree vals = TREE_VECTOR_CST_ELTS (mask);
 
       for (i = 0; i < elements; ++i, vals = TREE_CHAIN (vals))
-       sel_int[i] = TREE_INT_CST_LOW (TREE_VALUE (vals));
+       sel_int[i] = TREE_INT_CST_LOW (TREE_VALUE (vals)) & (2 * elements - 1);
 
       if (can_vec_perm_p (TYPE_MODE (vect_type), false, sel_int))
        return;
@@ -785,10 +787,12 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi)
       || code == LROTATE_EXPR
       || code == RROTATE_EXPR)
     {
+      optab opv;
+
       /* Check whether we have vector <op> {x,x,x,x} where x
          could be a scalar variable or a constant.  Transform
          vector <op> {x,x,x,x} ==> vector <op> scalar.  */
-      if (VECTOR_MODE_P (TYPE_MODE (TREE_TYPE (rhs2))))
+      if (VECTOR_INTEGER_TYPE_P (TREE_TYPE (rhs2)))
         {
           tree first;
           gimple def_stmt;
@@ -807,17 +811,18 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi)
             }
         }
 
-      if (VECTOR_MODE_P (TYPE_MODE (TREE_TYPE (rhs2))))
-        op = optab_for_tree_code (code, type, optab_vector);
+      opv = optab_for_tree_code (code, type, optab_vector);
+      if (VECTOR_INTEGER_TYPE_P (TREE_TYPE (rhs2)))
+       op = opv;
       else
        {
           op = optab_for_tree_code (code, type, optab_scalar);
 
          /* The rtl expander will expand vector/scalar as vector/vector
             if necessary.  Don't bother converting the stmt here.  */
-         if (op == NULL
-             || optab_handler (op, TYPE_MODE (type)) == CODE_FOR_nothing)
-           op = optab_for_tree_code (code, type, optab_vector);
+         if (optab_handler (op, TYPE_MODE (type)) == CODE_FOR_nothing
+             && optab_handler (opv, TYPE_MODE (type)) != CODE_FOR_nothing)
+           return;
        }
     }
   else
@@ -848,14 +853,16 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi)
 
   /* For very wide vectors, try using a smaller vector mode.  */
   compute_type = type;
-  if (TYPE_MODE (type) == BLKmode && op)
+  if (!VECTOR_MODE_P (TYPE_MODE (type)) && op)
     {
       tree vector_compute_type
         = type_for_widest_vector_mode (TYPE_MODE (TREE_TYPE (type)), op,
                                       TYPE_SATURATING (TREE_TYPE (type)));
       if (vector_compute_type != NULL_TREE
          && (TYPE_VECTOR_SUBPARTS (vector_compute_type)
-             < TYPE_VECTOR_SUBPARTS (compute_type)))
+             < TYPE_VECTOR_SUBPARTS (compute_type))
+         && (optab_handler (op, TYPE_MODE (vector_compute_type))
+             != CODE_FOR_nothing))
        compute_type = vector_compute_type;
     }