This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR40328


This fixes PR40328 where we fail to fold COMPLE_EXPR <0, 0> to
a COMPLEX_CST.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2009-06-03  Richard Guenther  <rguenther@suse.de>

	PR middle-end/40328
	* fold-const.c (fold_convert): Fold the build COMPLEX_EXPR.

	* gcc.dg/torture/pr40328.c: New testcase.

Index: gcc/fold-const.c
===================================================================
*** gcc/fold-const.c	(revision 148119)
--- gcc/fold-const.c	(working copy)
*************** fold_convert (tree type, tree arg)
*** 2643,2651 ****
  	case POINTER_TYPE: case REFERENCE_TYPE:
  	case REAL_TYPE:
  	case FIXED_POINT_TYPE:
! 	  return build2 (COMPLEX_EXPR, type,
! 			 fold_convert (TREE_TYPE (type), arg),
! 			 fold_convert (TREE_TYPE (type), integer_zero_node));
  	case COMPLEX_TYPE:
  	  {
  	    tree rpart, ipart;
--- 2643,2652 ----
  	case POINTER_TYPE: case REFERENCE_TYPE:
  	case REAL_TYPE:
  	case FIXED_POINT_TYPE:
! 	  return fold_build2 (COMPLEX_EXPR, type,
! 			      fold_convert (TREE_TYPE (type), arg),
! 			      fold_convert (TREE_TYPE (type),
! 					    integer_zero_node));
  	case COMPLEX_TYPE:
  	  {
  	    tree rpart, ipart;
Index: gcc/testsuite/gcc.dg/torture/pr40328.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr40328.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr40328.c	(revision 0)
***************
*** 0 ****
--- 1,11 ----
+ /* { dg-do compile } */
+ /* { dg-options "-fno-tree-sra" } */
+ 
+ _Complex float foo(void)
+ {
+   _Complex float a[64] = {};
+   _Complex float x;
+   x =  a[1];
+   return x;
+ }
+ 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]