[patch] PR23911

Steven Bosscher stevenb@suse.de
Thu Sep 29 12:10:00 GMT 2005


On Thursday 29 September 2005 14:04, Steven Bosscher wrote:
> Hi,
>
> This fixes a missed optimization at the tree level.
> Bootstrapped and tested on x86_64-linux.  OK?
>
> Gr.
> Steven

D'oh!

gcc/
	PR tree-optimization/23911
	* tree-ssa-ccp.c (fold_const_aggregate_ref): Handle REALPART_EXPR
	and IMAGPART_EXPR too.

testsuite/
	* gcc.dg/pr23911.c: New test.


> Index: tree-ssa-ccp.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/tree-ssa-ccp.c,v
> retrieving revision 2.87
> diff -u -3 -p -r2.87 tree-ssa-ccp.c
> --- tree-ssa-ccp.c	17 Aug 2005 07:27:38 -0000	2.87
> +++ tree-ssa-ccp.c	29 Sep 2005 11:57:02 -0000
> @@ -1045,6 +1045,15 @@ fold_const_aggregate_ref (tree t)
>  	  return cval;
>        break;
>
> +    case REALPART_EXPR:
> +    case IMAGPART_EXPR:
> +      {
> +	tree c = fold_const_aggregate_ref (TREE_OPERAND (t, 0));
> +	if (c && TREE_CODE (c) == COMPLEX_CST)
> +	  return fold_build1 (TREE_CODE (t), TREE_TYPE (t), c);
> +	break;
> +      }
> +
>      default:
>        break;
>      }
> Index: testsuite/gcc.dg/pr23911.c
> ===================================================================
> RCS file: testsuite/gcc.dg/pr23911.c
> diff -N testsuite/gcc.dg/pr23911.c
> --- /dev/null	1 Jan 1970 00:00:00 -0000
> +++ testsuite/gcc.dg/pr23911.c	29 Sep 2005 11:57:04 -0000
> @@ -0,0 +1,22 @@
> +/* This was a missed optimization in tree constant propagation
> +   that CSE would catch later on.  */
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-store_ccp" } */
> +
> +double _Complex *a;
> +const double _Complex b[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
> +
> +void
> +test (void)
> +{
> +  a[0] = b[0] + b[1];
> +  a[1] = b[0] + b[1];
> +  return;
> +}
> +
> +/* After store_ccp, there should not be any assignments from real or
> +   imaginary parts anymore.  The constants should be loaded from b and
> +   propagated into the elements of a.  */
> +/* { dg-final { scan-tree-dump-times "= CR" 0 "store_ccp" } } */
> +/* { dg-final { scan-tree-dump-times "= CI" 0 "store_ccp" } } */
> +/* { dg-final { cleanup-tree-dump "store_ccp" } } */



More information about the Gcc-patches mailing list