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]

Re: Fwd: GCC COUNT register problem



> Date: Thu, 19 Apr 2001 18:19:28 -0700
> From: Reza Yazdani <reza@apple.com>
> 
> 
> 
> Begin forwarded message:
> 
> > From: reza@apple.com
> > Date: Thu Apr 19, 2001  06:12:47 PM US/Pacific
> > To: geoffk@redhat.com, dje@watson.ibm.com
> > Cc: Dale Johannesen <dalej@apple.com>, Stan Shebs <shebs@apple.com>, 
> > Reza Yazdani <reza@apple.com>
> > Subject: GCC COUNT register problem
> >
> > Hello:
> >
> > I tried the following test on PowerPc. The COUNT register is used very 
> > inefficiently at
> > the loop branch. I tracked it down to the code segments similar to the 
> > following code in rs6000.md file:
> >
> > (Define_insn "*ctrsi_internal2"
> >   [(set (pc)
> >         (if_then_else (ne (match_operand:SI 1 "register_operand" 
> > "c,*r,*r")
> >                           (const_int 1))
> >                       (pc)
> >                       (label_ref (match_operand 0 "" ""))))
> >    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
> >         (plus:SI (match_dup 1)
> >                  (const_int -1)))
> >    (clobber (match_scratch:CC 3 "=X,&x,&x"))
> >    (clobber (match_scratch:SI 4 "=X,X,r"))]
> >   "! TARGET_POWERPC64"
> >   "*
> > {
> >   if (which_alternative != 0)
> >     return \"#\";
> >   else if (get_attr_length (insn) == 8)
> >     return \"{bdn|bdnz} %$+8\;b %l0\";
> >   else
> >     return \"bdz %l0\";
> > }"
> >   [(set_attr "type" "branch")
> >    (set_attr "length" "*,12,16")])
> >
> > As I understand we should generate two instructions in case the length 
> > is 8. Therefore the "if" part code and the
> > "else" part code must be switched to generate the expected code. In the 
> > current form an extra branch  is going to
> > be generated all the time.
> >
> > Please let me know if you agree with me.
> >
> > C source:
> > -------------
> >
> > int i, a[100];
> > int main()
> > {
> >   for (i==0; i<=100; i++)
> >   {
> >     a[i] = i;
> >   }
> > }
> >
> > The .s file for the loop before the source change:
> > -------------------------------------------------------
> >
> > L9:
> >         slwi r5,r11,2
> >         stwx r11,r9,r5
> >         addi r11,r11,1
> >         bnz $+8
> >         b L9
> >
> > The .s file for the loop after the source change:
> > -------------------------------------------------------
> >
> > L9:
> >         slwi r5,r11,2
> >         stwx r11,r9,r5
> >         addi r11,r11,1
> >         bdnz L9
> >

I think you are right.  There are 12 places where '8' needs to be
changed to '4'.  I'll commit the attached patch if it passes testing.

(Of course, '8' was wrong in the first place, because the
instruction is only 4 bytes long.)

-- 
- Geoffrey Keating <geoffk@geoffk.org>

===File ~/patches/cygnus/rs6000-ctrlength.patch=============
2001-04-19  Geoff Keating  <geoffk@redhat.com>

	* config/rs6000/rs6000.md (ctrsi_internal1, ctrsi_internal2,
	ctrsi_internal3, ctrsi_internal4, ctrsi_internal5,
	ctrsi_internal6, ctrdi_internal1, ctrdi_internal2,
	ctrdi_internal3, ctrdi_internal4, ctrdi_internal5,
	ctrdi_internal6): In the short-branch case, this insn is only 4
	instructions long.  Reported by Reza Yazdani <reza@apple.com>.

Index: config/rs6000/rs6000.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.md,v
retrieving revision 1.113
diff -p -u -u -p -r1.113 rs6000.md
--- rs6000.md	2001/04/12 03:11:48	1.113
+++ rs6000.md	2001/04/20 01:56:05
@@ -12888,7 +12888,7 @@ operands[2] = GEN_INT (INTVAL (operands[
 {
   if (which_alternative != 0)
     return \"#\";
-  else if (get_attr_length (insn) == 8)
+  else if (get_attr_length (insn) == 4)
     return \"{bdn|bdnz} %l0\";
   else
     return \"bdz %$+8\;b %l0\";
@@ -12912,7 +12912,7 @@ operands[2] = GEN_INT (INTVAL (operands[
 {
   if (which_alternative != 0)
     return \"#\";
-  else if (get_attr_length (insn) == 8)
+  else if (get_attr_length (insn) == 4)
     return \"bdz %l0\";
   else
     return \"{bdn|bdnz} %$+8\;b %l0\";
@@ -12936,7 +12936,7 @@ operands[2] = GEN_INT (INTVAL (operands[
 {
   if (which_alternative != 0)
     return \"#\";
-  else if (get_attr_length (insn) == 8)
+  else if (get_attr_length (insn) == 4)
     return \"{bdn|bdnz} %l0\";
   else
     return \"bdz %$+8\;b %l0\";
@@ -12960,7 +12960,7 @@ operands[2] = GEN_INT (INTVAL (operands[
 {
   if (which_alternative != 0)
     return \"#\";
-  else if (get_attr_length (insn) == 8)
+  else if (get_attr_length (insn) == 4)
     return \"bdz %l0\";
   else
     return \"{bdn|bdnz} %$+8\;b %l0\";
@@ -12986,7 +12986,7 @@ operands[2] = GEN_INT (INTVAL (operands[
 {
   if (which_alternative != 0)
     return \"#\";
-  else if (get_attr_length (insn) == 8)
+  else if (get_attr_length (insn) == 4)
     return \"{bdn|bdnz} %l0\";
   else
     return \"bdz %$+8\;b %l0\";
@@ -13010,7 +13010,7 @@ operands[2] = GEN_INT (INTVAL (operands[
 {
   if (which_alternative != 0)
     return \"#\";
-  else if (get_attr_length (insn) == 8)
+  else if (get_attr_length (insn) == 4)
     return \"bdz %l0\";
   else
     return \"{bdn|bdnz} %$+8\;b %l0\";
@@ -13034,7 +13034,7 @@ operands[2] = GEN_INT (INTVAL (operands[
 {
   if (which_alternative != 0)
     return \"#\";
-  else if (get_attr_length (insn) == 8)
+  else if (get_attr_length (insn) == 4)
     return \"{bdn|bdnz} %l0\";
   else
     return \"bdz %$+8\;b %l0\";
@@ -13058,7 +13058,7 @@ operands[2] = GEN_INT (INTVAL (operands[
 {
   if (which_alternative != 0)
     return \"#\";
-  else if (get_attr_length (insn) == 8)
+  else if (get_attr_length (insn) == 4)
     return \"bdz %l0\";
   else
     return \"{bdn|bdnz} %$+8\;b %l0\";
@@ -13084,7 +13084,7 @@ operands[2] = GEN_INT (INTVAL (operands[
 {
   if (which_alternative != 0)
     return \"#\";
-  else if (get_attr_length (insn) == 8)
+  else if (get_attr_length (insn) == 4)
     return \"bdz %l0\";
   else
     return \"{bdn|bdnz} %$+8\;b %l0\";
@@ -13108,7 +13108,7 @@ operands[2] = GEN_INT (INTVAL (operands[
 {
   if (which_alternative != 0)
     return \"#\";
-  else if (get_attr_length (insn) == 8)
+  else if (get_attr_length (insn) == 4)
     return \"{bdn|bdnz} %l0\";
   else
     return \"bdz %$+8\;b %l0\";
@@ -13132,7 +13132,7 @@ operands[2] = GEN_INT (INTVAL (operands[
 {
   if (which_alternative != 0)
     return \"#\";
-  else if (get_attr_length (insn) == 8)
+  else if (get_attr_length (insn) == 4)
     return \"bdz %l0\";
   else
     return \"{bdn|bdnz} %$+8\;b %l0\";
@@ -13156,7 +13156,7 @@ operands[2] = GEN_INT (INTVAL (operands[
 {
   if (which_alternative != 0)
     return \"#\";
-  else if (get_attr_length (insn) == 8)
+  else if (get_attr_length (insn) == 4)
     return \"{bdn|bdnz} %l0\";
   else
     return \"bdz %$+8\;b %l0\";
============================================================


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