Patchwork PATCH: PR middle-end/45634: [4.6 regression] Revision 163973 faild to compile 191.fma3d in SPEC CPU 2K

login
register
mail settings
Submitter H.J. Lu
Date Sept. 10, 2010, 2:38 p.m.
Message ID <20100910143812.GA13978@intel.com>
Download mbox | patch
Permalink /patch/64398/
State New
Headers show

Comments

H.J. Lu - Sept. 10, 2010, 2:38 p.m.
Hi,

Here is a patch to check result of string folding is of integral type.
OK for trunk?

Thanks.


H.J.
---
gcc/

2010-09-10  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/45634
	* tree-ssa-ccp.c (fold_const_aggregate_ref): Check that result
	of string folding is of integral type.

gcc/testsuite/

2010-09-10  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/45634
	* gfortran.fortran-torture/compile/pr45634.f90: New.
Richard Guenther - Sept. 10, 2010, 2:39 p.m.
On Fri, Sep 10, 2010 at 4:38 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> Hi,
>
> Here is a patch to check result of string folding is of integral type.
> OK for trunk?

Ok.

Thanks,
Richard.

>
> Thanks.
>
>
> H.J.
> ---
> gcc/
>
> 2010-09-10  H.J. Lu  <hongjiu.lu@intel.com>
>
>        PR middle-end/45634
>        * tree-ssa-ccp.c (fold_const_aggregate_ref): Check that result
>        of string folding is of integral type.
>
> gcc/testsuite/
>
> 2010-09-10  H.J. Lu  <hongjiu.lu@intel.com>
>
>        PR middle-end/45634
>        * gfortran.fortran-torture/compile/pr45634.f90: New.
>
> diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
> index 60e2b55..33d5cc7 100644
> --- a/gcc/tree-ssa-ccp.c
> +++ b/gcc/tree-ssa-ccp.c
> @@ -1537,8 +1537,9 @@ fold_const_aggregate_ref (tree t)
>       /* Fold read from constant string.  */
>       if (TREE_CODE (ctor) == STRING_CST)
>        {
> -         if ((TYPE_MODE (TREE_TYPE (t))
> -              == TYPE_MODE (TREE_TYPE (TREE_TYPE (ctor))))
> +         if (INTEGRAL_TYPE_P (TREE_TYPE (t))
> +             && (TYPE_MODE (TREE_TYPE (t))
> +                 == TYPE_MODE (TREE_TYPE (TREE_TYPE (ctor))))
>              && (GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_TYPE (ctor))))
>                  == MODE_INT)
>              && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (ctor)))) == 1
> --- /dev/null   2010-09-09 09:16:30.485584932 -0700
> +++ gcc/gcc/testsuite/gfortran.fortran-torture/compile/pr45634.f90      2010-09-10 07:32:31.188022445 -0700
> @@ -0,0 +1,5 @@
> +      SUBROUTINE RCRDRD (VTYP)
> +      CHARACTER(4), INTENT(OUT) :: VTYP
> +      CHARACTER(1), SAVE :: DBL = "D"
> +      VTYP = DBL
> +      END
>

Patch

diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 60e2b55..33d5cc7 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1537,8 +1537,9 @@  fold_const_aggregate_ref (tree t)
       /* Fold read from constant string.  */
       if (TREE_CODE (ctor) == STRING_CST)
 	{
-	  if ((TYPE_MODE (TREE_TYPE (t))
-	       == TYPE_MODE (TREE_TYPE (TREE_TYPE (ctor))))
+	  if (INTEGRAL_TYPE_P (TREE_TYPE (t))
+	      && (TYPE_MODE (TREE_TYPE (t))
+		  == TYPE_MODE (TREE_TYPE (TREE_TYPE (ctor))))
 	      && (GET_MODE_CLASS (TYPE_MODE (TREE_TYPE (TREE_TYPE (ctor))))
 	          == MODE_INT)
 	      && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (ctor)))) == 1
--- /dev/null	2010-09-09 09:16:30.485584932 -0700
+++ gcc/gcc/testsuite/gfortran.fortran-torture/compile/pr45634.f90	2010-09-10 07:32:31.188022445 -0700
@@ -0,0 +1,5 @@ 
+      SUBROUTINE RCRDRD (VTYP)
+      CHARACTER(4), INTENT(OUT) :: VTYP 
+      CHARACTER(1), SAVE :: DBL = "D" 
+      VTYP = DBL
+      END