public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/23911] New: Failure to propagate constants from a const initializer for _Complex
@ 2005-09-16  8:10 steven at gcc dot gnu dot org
  2005-09-16  9:12 ` [Bug tree-optimization/23911] " bonzini at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-09-16  8:10 UTC (permalink / raw)
  To: gcc-bugs

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; 
} 
 
--> 
 
;; Function test (test) 
 
test () 
{ 
  double CI.17; 
  double CR.16; 
  complex double * D.1616; 
  complex double * a.0; 
 
<bb 0>: 
  a.0 = a; 
  CR.16 = REALPART_EXPR <b[0]> + REALPART_EXPR <b[1]>; 
  CI.17 = IMAGPART_EXPR <b[0]> + IMAGPART_EXPR <b[1]>; 
  REALPART_EXPR <*a.0> = CR.16; 
  IMAGPART_EXPR <*a.0> = CI.17; 
  D.1616 = a.0 + 16B; 
  REALPART_EXPR <*D.1616> = CR.16; 
  IMAGPART_EXPR <*D.1616> = CI.17; 
  return; 
 
} 
 
CSE later optimizes this, but we should do it earlier.

-- 
           Summary: Failure to propagate constants from a const initializer
                    for _Complex
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: missed-optimization, TREE
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: steven at gcc dot gnu dot org
                CC: bonzini at gcc dot gnu dot org,gcc-bugs at gcc dot gnu
                    dot org
OtherBugsDependingO 19721
             nThis:


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/23911] Failure to propagate constants from a const initializer for _Complex
  2005-09-16  8:10 [Bug tree-optimization/23911] New: Failure to propagate constants from a const initializer for _Complex steven at gcc dot gnu dot org
@ 2005-09-16  9:12 ` bonzini at gcc dot gnu dot org
  2005-09-16  9:58 ` steven at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bonzini at gcc dot gnu dot org @ 2005-09-16  9:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bonzini at gcc dot gnu dot org  2005-09-16 09:11 -------
fold_const_aggregate_ref does not handle REALPART_EXPR and IMAGPART_EXPR.

Steven has a patch, or so I'm told.

-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/23911] Failure to propagate constants from a const initializer for _Complex
  2005-09-16  8:10 [Bug tree-optimization/23911] New: Failure to propagate constants from a const initializer for _Complex steven at gcc dot gnu dot org
  2005-09-16  9:12 ` [Bug tree-optimization/23911] " bonzini at gcc dot gnu dot org
@ 2005-09-16  9:58 ` steven at gcc dot gnu dot org
  2005-09-16 10:39 ` steven at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-09-16  9:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2005-09-16 09:58 -------
This fixes it.  Sadly only store-ccp propagates constants out of  
initializers right now, which is a separate bug -- we _do_ find the  
constant in the initializer... but then we don't propagate it for  
some reason.  I'm also looking into that.  
  
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      16 Sep 2005 09:56:43 -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;  
     }  
  

-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/23911] Failure to propagate constants from a const initializer for _Complex
  2005-09-16  8:10 [Bug tree-optimization/23911] New: Failure to propagate constants from a const initializer for _Complex steven at gcc dot gnu dot org
  2005-09-16  9:12 ` [Bug tree-optimization/23911] " bonzini at gcc dot gnu dot org
  2005-09-16  9:58 ` steven at gcc dot gnu dot org
@ 2005-09-16 10:39 ` steven at gcc dot gnu dot org
  2005-09-16 14:12 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-09-16 10:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2005-09-16 10:39 -------
The reason why this only happens in store-ccp is this: 
 
  /* If we are not doing store-ccp, statements with loads 
     and/or stores will never fold into a constant.  */ 
  if (!do_store_ccp 
      && (ann->makes_aliased_stores 
          || ann->makes_aliased_loads 
          || !ZERO_SSA_OPERANDS (stmt, SSA_OP_ALL_VIRTUALS))) 
    return VARYING; 
 
But statements making loads _will_ fold into a constant if the load is 
made from a constant initializer. 
 

-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/23911] Failure to propagate constants from a const initializer for _Complex
  2005-09-16  8:10 [Bug tree-optimization/23911] New: Failure to propagate constants from a const initializer for _Complex steven at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2005-09-16 10:39 ` steven at gcc dot gnu dot org
@ 2005-09-16 14:12 ` pinskia at gcc dot gnu dot org
  2005-09-29 12:25 ` cvs-commit at gcc dot gnu dot org
  2005-09-29 12:40 ` steven at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-16 14:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-16 14:11 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-09-16 14:11:56
               date|                            |


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/23911] Failure to propagate constants from a const initializer for _Complex
  2005-09-16  8:10 [Bug tree-optimization/23911] New: Failure to propagate constants from a const initializer for _Complex steven at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2005-09-16 14:12 ` pinskia at gcc dot gnu dot org
@ 2005-09-29 12:25 ` cvs-commit at gcc dot gnu dot org
  2005-09-29 12:40 ` steven at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-09-29 12:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-09-29 12:25 -------
Subject: Bug 23911

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	steven@gcc.gnu.org	2005-09-29 12:25:10

Modified files:
	gcc            : ChangeLog tree-ssa-ccp.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: pr23911.c 

Log message:
	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.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.10046&r2=2.10047
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-ccp.c.diff?cvsroot=gcc&r1=2.87&r2=2.88
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6112&r2=1.6113
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr23911.c.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug tree-optimization/23911] Failure to propagate constants from a const initializer for _Complex
  2005-09-16  8:10 [Bug tree-optimization/23911] New: Failure to propagate constants from a const initializer for _Complex steven at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2005-09-29 12:25 ` cvs-commit at gcc dot gnu dot org
@ 2005-09-29 12:40 ` steven at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-09-29 12:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2005-09-29 12:40 -------
. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-09-29 12:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-16  8:10 [Bug tree-optimization/23911] New: Failure to propagate constants from a const initializer for _Complex steven at gcc dot gnu dot org
2005-09-16  9:12 ` [Bug tree-optimization/23911] " bonzini at gcc dot gnu dot org
2005-09-16  9:58 ` steven at gcc dot gnu dot org
2005-09-16 10:39 ` steven at gcc dot gnu dot org
2005-09-16 14:12 ` pinskia at gcc dot gnu dot org
2005-09-29 12:25 ` cvs-commit at gcc dot gnu dot org
2005-09-29 12:40 ` steven at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).