This is the mail archive of the gcc-bugs@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]

Re: optimization/8967: Making class data members `const' pessimizes code


The problem seems to be in the life analysis code. 
It can be seen by doing the following:

Create 2 files:
pr8967m.cc

class Mutable
{

 private: int x, y;
 public:
 Mutable (int X, int Y) : x (X), y (Y) {
 }
 inline friend Mutable operator +  (const Mutable &  z1, const Mutable &  z2)
   {
     return Mutable (z1.x +  z2.x, z1.y +  z2.y); }
};
Mutable Mutable_foo () {
   return Mutable(1,2) +  Mutable(8,9); }

and 
pr8967c.cc

class Const
{

 private: const int x, y;
 public:
 Const (int X, int Y) : x (X), y (Y) {
 }
 inline friend Const operator +  (const Const &  z1, const Const &  z2)
   {
     return Const (z1.x +  z2.x, z1.y +  z2.y); }
};

Const Const_foo () {
   return Const(1,2) +  Const(8,9); }

compile both of them with gcc -S -O2 -da 
Do: 
wc -l pr8967c.cc.*
wc -l pr8967m.cc.*

Here is the output of the above wc commands side to side:


     220 pr8967c.cc.00.rtl                220 pr8967m.c.00.rtl              
     166 pr8967c.cc.01.sibling            166 pr8967m.c.01.sibling   
     117 pr8967c.cc.02.eh                 117 pr8967m.c.02.eh                
     164 pr8967c.cc.03.jump               164 pr8967m.c.03.jump      
     164 pr8967c.cc.08.null               164 pr8967m.c.08.null      
     129 pr8967c.cc.09.cse                129 pr8967m.c.09.cse               
      76 pr8967c.cc.10.addressof           76 pr8967m.c.10.addressof         
     104 pr8967c.cc.11.gcse               104 pr8967m.c.11.gcse      
      76 pr8967c.cc.12.loop                76 pr8967m.c.12.loop      
     107 pr8967c.cc.13.ce1                107 pr8967m.c.13.ce1               
      86 pr8967c.cc.14.cfg                 86 pr8967m.c.14.cfg               
     110 pr8967c.cc.15.bp                 110 pr8967m.c.15.bp                
     103 pr8967c.cc.17.cse2               103 pr8967m.c.17.cse2      
     112 pr8967c.cc.18.life                73 pr8967m.c.18.life      
      89 pr8967c.cc.19.combine             51 pr8967m.c.19.combine   
      86 pr8967c.cc.20.ce2                 48 pr8967m.c.20.ce2               
      94 pr8967c.cc.21.regmove             56 pr8967m.c.21.regmove   
     115 pr8967c.cc.22.sched               70 pr8967m.c.22.sched     
     149 pr8967c.cc.23.lreg                90 pr8967m.c.23.lreg      
     144 pr8967c.cc.24.greg                73 pr8967m.c.24.greg      
      84 pr8967c.cc.25.postreload          49 pr8967m.c.25.postreload        
     108 pr8967c.cc.26.flow2               70 pr8967m.c.26.flow2     
      90 pr8967c.cc.27.peephole2           52 pr8967m.c.27.peephole2         
      90 pr8967c.cc.28.rnreg               52 pr8967m.c.28.rnreg     
      90 pr8967c.cc.29.ce3                 52 pr8967m.c.29.ce3               
     117 pr8967c.cc.30.sched2              72 pr8967m.c.30.sched2    
     100 pr8967c.cc.32.bbro                62 pr8967m.c.32.bbro      
     105 pr8967c.cc.34.dbr                 67 pr8967m.c.34.dbr          

everything is identical up to the .18.life dump
pr8967m.c.18.life says "deleted 7 dead insns"
no insns are deleted in pr8967c.c.18.life 

Can somebody that understands the life analysis code take a look at
this? 


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