Bug 49478 - ice in expand_widen_pattern_expr with -O3
Summary: ice in expand_widen_pattern_expr with -O3
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2011-06-20 19:46 UTC by David Binderman
Modified: 2011-06-21 12:14 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-06-21 00:31:48


Attachments
C source code (60.87 KB, text/plain)
2011-06-20 19:46 UTC, David Binderman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2011-06-20 19:46:40 UTC
Created attachment 24569 [details]
C source code

I just tried to compile the groona-1.2.2 package with the latest trunk
snapshot 20110618 on an AMD x86_64 box.

The compiler said

io.c: In function 'grn_io_create_with_array':
io.c:287:13: internal compiler error: in expand_widen_pattern_expr, at optabs.c:535
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Preprocessed source code attached. Flag -O3 required.
Comment 1 H.J. Lu 2011-06-21 00:31:48 UTC
It is caused by revision 174735:

http://gcc.gnu.org/ml/gcc-cvs/2011-06/msg00223.html
Comment 2 Ira Rosen 2011-06-21 07:33:15 UTC
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;
+        }
+    }
+
   if (!vec_stmt) /* transformation not required.  */
     {
       if (!vect_model_reduction_cost (stmt_info, epilog_reduc_code, ncopies))
Comment 3 Richard Biener 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))
Comment 4 Ira Rosen 2011-06-21 10:03:05 UTC
OK.
Thanks,
Ira
Comment 5 irar 2011-06-21 11:58:36 UTC
Author: irar
Date: Tue Jun 21 11:58:33 2011
New Revision: 175255

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175255
Log:

        PR tree-optimization/49478
        * tree-vect-loop.c (vectorizable_reduction): Handle DOT_PROD_EXPR
        with constant operand.


Added:
    trunk/gcc/testsuite/gcc.dg/vect/pr49478.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-loop.c
Comment 6 Ira Rosen 2011-06-21 12:14:09 UTC
Fixed.