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]

Re: [tree-ssa] PATCH to improve optimization at ssa rewrite time



On Tuesday, May 13, 2003, at 04:33 PM, Andrew MacLeod wrote:


On Tue, 2003-05-13 at 15:50, Daniel Berlin wrote:

On Tuesday, May 13, 2003, at 03:36 PM, Andrew MacLeod wrote:


On Tue, 2003-05-13 at 15:26, Daniel Berlin wrote:

*However*, doing simple const-prop during SSA-rewriting (as we do now)
transforms the original into:
;; Function main (main)

main ()
{
   int a;
   int b;
   int c;

   a_2 = 5;
   b_3 = 25
   if (c_4 != 0)
     {
       {
         a_5 = 6;
       }
     }
   else
     {
       {
         a_6 = 7;
       }
     };
   #   a_1 = PHI <a_5(1), a_6(2)>;
   b_7 = a_1 * 5
}

We can't SSAPRE this at *all*, and therefore, are left with the
multiply.
Propping the constants into the phi won't help you here, because it's
different on each branch.


But you will see:


main ()
{
  int a;
  int b;
  int c;

  a_2 = 5;
  b_3 = 25
  if (c_4 != 0)
    {
      {
        a_5 = 6;
      }
    }
  else
    {
      {
        a_6 = 7;
      }
    };
  #   a_1 = PHI <6(1), 7(2)>;
  b_7 = a_1 * 5


and then it seems pretty easy to do exactly the same thing with the caclulation of b_7

its clear that on edge (1,3)  b_7 can be calculated as 6 * 5, and on
edge (2,3) its 7 * 5...

So isn't it just as trivial for someone to insert temps on those edges:
Who is this someone?
Are we going to do out-of-ssa const-prop too?
Or do you think CCP should be doing it?
Diego also suggested adding temps in this case, my response was, of course:
Isn't it easier to make it not miss these optimizations in the first place by not const-prop'ing when we can't const-prop it everywhere (getting the trivial cases, but leaving the complex ones to passes that handle it right), than it is to add passes and code in them to fix it up?
--Dan



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