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]

Fix PR target/16494


I discovered this yesterday: on non-V9 targets, when delay slots are not 
filled, FP conditional branches are unnecessarily reversed.  See the PR for 
an example.

This was inadvertently introduced by:

2003-10-01  Eric Botcazou  <ebotcazou@libertysurf.fr>

	PR optimization/11753
	* config/sparc/sparc.md (length attribute) [fcc branch]: Add 1 to
	the length in the non-V9 case.

because there is an "undocumented" side-effect associated with having a 
length greater or equal to 3 for conditional branches: output_cbranch will 
automatically reverse the branch. *sigh*

Fixed by restricting the feature to the V9 case and adding a warning.  
Bootstrapped/regtested on sparc64-sun-solaris2.9, sparc-sun-solaris2.8, 
sparc-sun-solaris2.7, sparc-sun-solaris2.6 and sparc-sun-solaris2.5.1.

Applied to all active branches.


2004-07-13  Eric Botcazou  <ebotcazou@libertysurf.fr>

	PR target/16494
	* config/sparc/sparc.c (output_cbranch): Properly guard
	the code handling far branches with TARGET_V9.
	* config/sparc/sparc.md (length attribute): Document the
	side-effect of having a length greater or equal to 3.


-- 
Eric Botcazou
Index: config/sparc/sparc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sparc.c,v
retrieving revision 1.233.4.10
diff -u -p -r1.233.4.10 sparc.c
--- config/sparc/sparc.c	31 May 2004 21:45:32 -0000	1.233.4.10
+++ config/sparc/sparc.c	12 Jul 2004 13:20:12 -0000
@@ -5491,7 +5491,7 @@ output_cbranch (op, dest, label, reverse
      nop
      ba .LC29  */
 
-  far = get_attr_length (insn) >= 3;
+  far = TARGET_V9 && (get_attr_length (insn) >= 3);
   if (reversed ^ far)
     {
       /* Reversal of FP compares takes care -- an ordered compare
@@ -5621,9 +5621,7 @@ output_cbranch (op, dest, label, reverse
       spaces -= 2;
     }
 
-  if (! TARGET_V9)
-    labelno = "";
-  else
+  if (TARGET_V9)
     {
       rtx note;
       int v8 = 0;
@@ -5673,6 +5671,9 @@ output_cbranch (op, dest, label, reverse
 	  spaces -= 3;
 	}
     }
+  else
+    labelno = "";
+
   if (spaces > 0)
     *p++ = '\t';
   else
Index: config/sparc/sparc.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sparc.md,v
retrieving revision 1.181.4.11
diff -u -p -r1.181.4.11 sparc.md
--- config/sparc/sparc.md	31 May 2004 21:45:33 -0000	1.181.4.11
+++ config/sparc/sparc.md	12 Jul 2004 13:20:22 -0000
@@ -120,6 +120,8 @@
   (symbol_ref "TARGET_FLAT != 0"))
 
 ;; Length (in # of insns).
+;; Beware that setting a length greater or equal to 3 for conditional branches
+;; has a side-effect (see output_cbranch and output_v9branch).
 (define_attr "length" ""
   (cond [(eq_attr "type" "uncond_branch,call,sibcall")
 	   (if_then_else (eq_attr "empty_delay_slot" "true")

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