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: [PATCH] New and semi-improved PHI-OPT



On Mar 6, 2005, at 3:11 PM, Kazu Hirata wrote:


Hi Andrew and Richard,

This is port of the PHI-OPT from the tree cleanup branch. The original
patch
was posted here:
http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02959.html> which
describes what the patch does.


OK? Bootstrapped and tested on powerpc-darwin with no regressions.

Do you have some numbers on the compile-time and memory-usage impact vs. performance benefit of this patch?

In particular, it would be interesting to see how many more opportunities we catch at tree level and how much work we take away from ifcvt at the RTL level.

Also note both the old algorithm and this one is still O(n), the n changed
from the number of BBs with one PHIs to the number of BBs that end in a
conditional. Also one more thing the following code we get better code
than before (this shows up in PR8361 for an example):
_Bool f1(_Bool a, _Bool b)
{
if (a)
{
if (b)
return 1;
else
return 0;
}
return 0;
}


Before (PPC):
_f1:
        cmpwi cr7,r3,0
        cmpwi cr6,r4,0
        li r3,1
        beq- cr7,L2
        bnelr+ cr6
L2:
        li r3,0
        blr

After:
_f1:
        cmpwi cr7,r3,0
        li r3,0
        beqlr- cr7
        addic r0,r4,-1
        subfe r3,r0,r4
        blr

Notice how it is smaller code and one less branch so it will be faster.


+	   for (i = 0;i < PHI_NUM_ARGS (phi); i++)
+	     {
+	       if (PHI_ARG_EDGE (phi, i) == e1)
+	         arg0 = PHI_ARG_DEF_TREE (phi, i);
+	       else if (PHI_ARG_EDGE (phi, i) == e2)
+	         arg1 = PHI_ARG_DEF_TREE (phi, i);
+	     }

This loop can collapse to

  arg0 = PHI_ARG_DEF (phi, e1->dest_idx);
  arg1 = PHI_ARG_DEF (phi, e2->dest_idx);

Woops, I had forgot about that, well that is because this changed after I wrote the code and it is not really written up anywhere.


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