http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49478

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-06-21 
09:39:47 UTC ---
(In reply to comment #2)
> I am testing this patch:
> 
> Index: tree-vect-loop.c
> ===================================================================
> --- tree-vect-loop.c    (revision 175238)
> +++ tree-vect-loop.c    (working copy)
> @@ -4591,6 +4591,29 @@ vectorizable_reduction (gimple stmt, gim
>        return false;
>      }
> 
> +  /* In case of widenning multiplication by a constant, we update the type
> +     of the constant to be the type of the other operand.  We check that the
> +     constant fits the type in the pattern recognition pass.  */
> +  if (code == DOT_PROD_EXPR
> +      && !types_compatible_p (TREE_TYPE (ops[0]), TREE_TYPE (ops[1])))
> +    {
> +      if (TREE_CODE (ops[0]) == INTEGER_CST)
> +        ops[0] = build_int_cst_wide (TREE_TYPE (ops[1]),
> +                                    TREE_INT_CST_LOW (ops[0]),
> +                                    TREE_INT_CST_HIGH (ops[0]));
> +      else if (TREE_CODE (ops[1]) == INTEGER_CST)
> +        ops[1] = build_int_cst_wide (TREE_TYPE (ops[0]),
> +                                    TREE_INT_CST_LOW (ops[1]),
> +                                    TREE_INT_CST_HIGH (ops[1]));
> +      else
> +        {
> +          if (vect_print_dump_info (REPORT_DETAILS))
> +            fprintf (vect_dump, "invalid types in dot-prod");
> +
> +          return false;
> +        }
> +    }

Please instead simply do

       if (code == DOT_PROD_EXPR
           && !types_compatible_p (TREE_TYPE (ops[0]), TREE_TYPE (ops[1])))
         {
           if (TREE_CODE (ops[0]) == INTEGER_CST)
             ops[0] = fold_convert (TREE_TYPE (ops[1]), ops[0]);
           else if (TREE_CODE (ops[1]) == INTEEGER_CST)
             ops[1] = fold_convert (TREE_TYPE (ops[0]), ops[1]);
> +      else
> +        {
> +          if (vect_print_dump_info (REPORT_DETAILS))
> +            fprintf (vect_dump, "invalid types in dot-prod");
> +
> +          return false;
           }
         }

Thanks.

> +
>    if (!vec_stmt) /* transformation not required.  */
>      {
>        if (!vect_model_reduction_cost (stmt_info, epilog_reduc_code, ncopies))

Reply via email to