[committed] PA long branch support

John David Anglin dave@hiauly1.hia.nrc.ca
Sat Apr 15 16:05:00 GMT 2006


> > The patch has been tested on hppa-unknown-linux-gnu with no regressions
> > and testcase for PR 26743.  However, the patch is hard to test as a GCC
> > build doesn't trigger the use of long branches.  Thus, I've probably
> > made a few mistakes ;)

> One of the ways I used to test this this kind of stuff was to 
> drastically reduce the maximum displacement for the short branches.

This update fixes the problems found by reducing the maximum displacements.
The output_bb and output_bvb cases were shortened by one instruction.
No regressions were observed in testing on hppa-unknown-linux-gnu.

Committed to trunk.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2006-04-15  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	* pa.md (output_bb patterns): Shorten long branch alternatives by 4.
	(output_bvb patterns): Likewise.
	* pa.c (output_bb): Use 'bb' insn for long branch case.
	(output_bvb): Likewise use '{bvb|bb}' for long branch case.
	(output_dbra): Use '{comb|cmpb}' for long branch case for alternative
	1.  Correct length operand for alternatives 1 and 2.
	(output_movb): Use '{comb|cmpb}' for long branch case for alternatives
	1, 2 and 3.  Correct length operand for alternatives 1, 2 and 3.

Index: config/pa/pa.md
===================================================================
--- config/pa/pa.md	(revision 112896)
+++ config/pa/pa.md	(working copy)
@@ -1898,10 +1898,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 (define_insn ""
   [(set (pc)
@@ -1926,10 +1926,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 (define_insn ""
   [(set (pc)
@@ -1954,10 +1954,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 (define_insn ""
   [(set (pc)
@@ -1982,10 +1982,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 (define_insn ""
   [(set (pc)
@@ -2010,10 +2010,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 (define_insn ""
   [(set (pc)
@@ -2038,10 +2038,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 (define_insn ""
   [(set (pc)
@@ -2066,10 +2066,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 (define_insn ""
   [(set (pc)
@@ -2094,10 +2094,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 ;; Branch on Variable Bit patterns.
 (define_insn ""
@@ -2123,10 +2123,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 (define_insn ""
   [(set (pc)
@@ -2151,10 +2151,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 (define_insn ""
   [(set (pc)
@@ -2179,10 +2179,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 (define_insn ""
   [(set (pc)
@@ -2207,10 +2207,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 (define_insn ""
   [(set (pc)
@@ -2235,10 +2235,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 (define_insn ""
   [(set (pc)
@@ -2263,10 +2263,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 (define_insn ""
   [(set (pc)
@@ -2291,10 +2291,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 (define_insn ""
   [(set (pc)
@@ -2319,10 +2319,10 @@
 	       (const_int MAX_17BIT_OFFSET))
 	   (const_int 8)
 	   (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
-	   (const_int 28)
+	   (const_int 24)
 	   (eq (symbol_ref "flag_pic") (const_int 0))
-	   (const_int 24)]
-	  (const_int 32)))])
+	   (const_int 20)]
+	  (const_int 28)))])
 
 ;; Floating point branches
 
Index: config/pa/pa.c
===================================================================
--- config/pa/pa.c	(revision 112896)
+++ config/pa/pa.c	(working copy)
@@ -1,6 +1,6 @@
 /* Subroutines for insn-output.c for HPPA.
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
    Contributed by Tim Moore (moore@cs.utah.edu), based on sparc.c
 
 This file is part of GCC.
@@ -6436,27 +6436,27 @@
 	  {
 	    nullify = 1;
 	    xdelay = 0;
-	    operands[4] = GEN_INT (length - 8);
+	    operands[4] = GEN_INT (length);
 	  }
 	else
 	  {
 	    xdelay = 1;
-	    operands[4] = GEN_INT (length - 4);
+	    operands[4] = GEN_INT (length + 4);
 	  }
 
 	if (GET_MODE (operands[0]) == DImode)
-	  strcpy (buf, "extrd,s,*");
+	  strcpy (buf, "bb,*");
 	else
-	  strcpy (buf, "{extrs,|extrw,s,}");
+	  strcpy (buf, "bb,");
 	if ((which == 0 && negated)
 	    || (which == 1 && !negated))
-	  strcat (buf, ">= %0,%1,1,%%r0\n\t");
+	  strcat (buf, "<");
 	else
-	  strcat (buf, "< %0,%1,1,%%r0\n\t");
+	  strcat (buf, ">=");
 	if (nullify)
-	  strcat (buf, "b,n .+%4");
+	  strcat (buf, ",n %0,%1,.+%4");
 	else
-	  strcat (buf, "b .+%4");
+	  strcat (buf, " %0,%1,.+%4");
 	output_asm_insn (buf, operands);
 	return output_lbranch (negated ? operands[3] : operands[2],
 			       insn, xdelay);
@@ -6616,27 +6616,27 @@
 	  {
 	    nullify = 1;
 	    xdelay = 0;
-	    operands[4] = GEN_INT (length - 8);
+	    operands[4] = GEN_INT (length);
 	  }
 	else
 	  {
 	    xdelay = 1;
-	    operands[4] = GEN_INT (length - 4);
+	    operands[4] = GEN_INT (length + 4);
 	  }
 
 	if (GET_MODE (operands[0]) == DImode)
-	  strcpy (buf, "extrd,s,*");
+	  strcpy (buf, "bb,*");
 	else
-	  strcpy (buf, "{extrs,|extrw,s,}");
+	  strcpy (buf, "{bvb,|bb,}");
 	if ((which == 0 && negated)
 	    || (which == 1 && !negated))
-	  strcat (buf, ">= {%0,%1,1,%%r0|%0,%%sar,1,%%r0}\n\t");
+	  strcat (buf, "<");
 	else
-	  strcat (buf, "< {%0,%1,1,%%r0|%0,%%sar,1,%%r0}\n\t");
+	  strcat (buf, ">=");
 	if (nullify)
-	  strcat (buf, "b,n .+%4");
+	  strcat (buf, ",n {%0,.+%4|%0,%%sar,.+%4}");
 	else
-	  strcat (buf, "b .+%4");
+	  strcat (buf, " {%0,.+%4|%0,%%sar,.+%4}");
 	output_asm_insn (buf, operands);
 	return output_lbranch (negated ? operands[3] : operands[2],
 			       insn, xdelay);
@@ -6763,8 +6763,8 @@
 	return "{comclr|cmpclr},%B2 %%r0,%4,%%r0\n\tb %3\n\t{fldws|fldw} -16(%%r30),%0";
       else
 	{
-	  operands[4] = GEN_INT (length - 24);
-	  output_asm_insn ("addib,%N2 %1,%0,.+%4", operands);
+	  operands[5] = GEN_INT (length - 16);
+	  output_asm_insn ("{comb|cmpb},%B2 %%r0,%4,.+%5", operands);
 	  output_asm_insn ("{fldws|fldw} -16(%%r30),%0", operands);
 	  return output_lbranch (operands[3], insn, 0);
 	}
@@ -6781,8 +6781,8 @@
 	return "addi,%N2 %1,%4,%4\n\tb %3\n\tstw %4,%0";
       else
 	{
-	  operands[5] = GEN_INT (length - 12);
-	  output_asm_insn ("addib,%N2 %1,%0,.+%5\n\tstw %4,%0", operands);
+	  operands[5] = GEN_INT (length - 4);
+	  output_asm_insn ("addib,%N2 %1,%4,.+%5\n\tstw %4,%0", operands);
 	  return output_lbranch (operands[3], insn, 0);
 	}
     }
@@ -6906,8 +6906,8 @@
 	return "{comclr|cmpclr},%B2 %%r0,%1,%%r0\n\tb %3\n\t{fldws|fldw} -16(%%r30),%0";
       else
 	{
-	  operands[4] = GEN_INT (length - 12);
-	  output_asm_insn ("movb,%N2 %1,%0,.+%4", operands);
+	  operands[4] = GEN_INT (length - 4);
+	  output_asm_insn ("{comb|cmpb},%B2 %%r0,%1,.+%4", operands);
 	  output_asm_insn ("{fldws|fldw} -16(%%r30),%0", operands);
 	  return output_lbranch (operands[3], insn, 0);
 	}
@@ -6923,8 +6923,9 @@
 	return "{comclr|cmpclr},%B2 %%r0,%1,%%r0\n\tb %3\n\tstw %1,%0";
       else
 	{
-	  operands[4] = GEN_INT (length - 8);
-	  output_asm_insn ("movb,%N2 %1,%0,.+%4\n\tstw %1,%0", operands);
+	  operands[4] = GEN_INT (length);
+	  output_asm_insn ("{comb|cmpb},%B2 %%r0,%1,.+%4\n\tstw %1,%0",
+			   operands);
 	  return output_lbranch (operands[3], insn, 0);
 	}
     }
@@ -6937,8 +6938,9 @@
 	return "{comclr|cmpclr},%B2 %%r0,%1,%%r0\n\tb %3\n\tmtsar %r1";
       else
 	{
-	  operands[4] = GEN_INT (length - 8);
-	  output_asm_insn ("movb,%N2 %1,%0,.+%4\n\tmtsar %r1", operands);
+	  operands[4] = GEN_INT (length);
+	  output_asm_insn ("{comb|cmpb},%B2 %%r0,%1,.+%4\n\tmtsar %r1",
+			   operands);
 	  return output_lbranch (operands[3], insn, 0);
 	}
     }



More information about the Gcc-patches mailing list