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]

[RFA:] gcc-3.2.x (committed elsewhere): Fix PR target/10377


PR target/10377 is about GCC emitting an invalid address for -fPIC for
cris-axis-linux-gnu.  A symbol expression for a visible data symbol
(in the GOT) appears where only a non-pic address is valid.  Such
addresses appear as "symbol" in non-pic code and as "[$r0+symbol:GOT]"
for -fPIC.  Constraints are wrong: an 'i' matches any constant for
non-pic, and filtered through LEGITIMATE_PIC_OPERAND_P for pic.  The
symbol *is* a LEGITIMATE_PIC_OPERAND_P.  For patterns where constraint
'i' is unsuitable for pic but suitable for non-pic, symbolic constants
are already matched by an 'R' constraint.  The reason to have 'i'
instead of 'n' is to guide register allocation, but by code inspection
I can't see any difference in recorded preferences for 'i' to those
for 'n'.  A combination of "Rn" matches the same as "Ri".  Hence the
only effect of this blanket "Ri" to "Rn" change should be to no longer
get invalid addresses for pic code.  It seems quite safe even for the
3.2 branch.

The test-case in the PR is apparently (from the name, $Id$ strings,
header files and the code itself) infocmp.c from ncurses-5.3.  That
source is copyright FSF so there should be no problem having the
distilled test-case in the test-suite.  Unfortunately the test-case
(distilled and original) only fails for the 3.2-branch, but to keep
things uniform I've committed it to HEAD and 3.3 too, in addition to
3.2.  I did try to write a test-case myself, but failed; the failure
seems rarely exposed despite appearance.  If I hadn't known, I'd have
guessed this bug would appear about once per file with -fPIC, assuming
same file-size as infocmp.c.  I raised the PR priority to "high".

The (almost identical) corresponding changes are committed to
3.3-branch and HEAD; the bug is there too.

Gaby, can I please commit the cris.md patch to 3.2-branch?

gcc:
	PR target/10377
	* config/cris/cris.md ("*mov_sideqi", "*mov_sidehi")
	("*mov_sidesi", "*mov_sideqi_mem", "*mov_sidehi_mem")
	("*mov_sidesi_mem", "*clear_sidesi", "*clear_sidehi")
	("*clear_sideqi", "*ext_sideqihi", "*ext_sideqisi")
	("*ext_sidehisi", "*op_sideqi", "*op_sidehi", "*op_sidesi")
	("*op_swap_sideqi", "*op_swap_sidehi", "*op_swap_sidesi")
	("*extopqihi_side", "*extopqisi_side", "*extophisi_side")
	("*extopqihi_swap_side", "*extopqisi_swap_side")
	("*extophisi_swap_side", 8th, 9th, 10th, 11th, 14th peepholes):
	When next to constraint R, replace constraint i with n.

testsuite:
	PR target/10377
	* gcc.dg/20030414-1.c: New test.


Index: cris.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/cris/cris.md,v
retrieving revision 1.2.10.3
diff -p -c -u -p -r1.2.10.3 cris.md
cvs server: conflicting specifications of output style
--- cris.md	17 Jun 2002 22:06:34 -0000	1.2.10.3
+++ cris.md	13 Apr 2003 15:17:47 -0000
@@ -1,5 +1,5 @@
 ;; GCC machine description for CRIS cpu cores.
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
 ;; Contributed by Axis Communications.
 
 ;; This file is part of GCC.
@@ -496,7 +496,7 @@
   [(set (match_operand:QI 0 "register_operand" "=r,r,r")
 	(mem:QI
 	 (plus:SI (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
-		  (match_operand:SI 2 "cris_bdap_operand" "r>Ri,r,>Ri"))))
+		  (match_operand:SI 2 "cris_bdap_operand" "r>Rn,r,>Rn"))))
    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
 	(plus:SI (match_dup 1)
 		 (match_dup 2)))]
@@ -519,7 +519,7 @@
   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
 	(mem:HI
 	 (plus:SI (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
-		  (match_operand:SI 2 "cris_bdap_operand" "r>Ri,r,>Ri"))))
+		  (match_operand:SI 2 "cris_bdap_operand" "r>Rn,r,>Rn"))))
    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
 	(plus:SI (match_dup 1)
 		 (match_dup 2)))]
@@ -542,7 +542,7 @@
   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
 	(mem:SI
 	 (plus:SI (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
-		  (match_operand:SI 2 "cris_bdap_operand" "r>Ri,r,>Ri"))))
+		  (match_operand:SI 2 "cris_bdap_operand" "r>Rn,r,>Rn"))))
    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
 	(plus:SI (match_dup 1)
 		 (match_dup 2)))]
@@ -671,7 +671,7 @@
 (define_insn "*mov_sideqi_mem"
   [(set (mem:QI
 	 (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r,r")
-		  (match_operand:SI 1 "cris_bdap_operand" "r>Ri,r>Ri,r,>Ri")))
+		  (match_operand:SI 1 "cris_bdap_operand" "r>Rn,r>Rn,r,>Rn")))
 	(match_operand:QI 2 "register_operand" "r,r,r,r"))
    (set (match_operand:SI 3 "register_operand" "=*0,!*2,r,r")
 	(plus:SI (match_dup 0)
@@ -696,7 +696,7 @@
 (define_insn "*mov_sidehi_mem"
   [(set (mem:HI
 	 (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r,r")
-		  (match_operand:SI 1 "cris_bdap_operand" "r>Ri,r>Ri,r,>Ri")))
+		  (match_operand:SI 1 "cris_bdap_operand" "r>Rn,r>Rn,r,>Rn")))
 	(match_operand:HI 2 "register_operand" "r,r,r,r"))
    (set (match_operand:SI 3 "register_operand" "=*0,!*2,r,r")
 	(plus:SI (match_dup 0)
@@ -721,7 +721,7 @@
 (define_insn "*mov_sidesi_mem"
   [(set (mem:SI
 	 (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r,r")
-		  (match_operand:SI 1 "cris_bdap_operand" "r>Ri,r>Ri,r,>Ri")))
+		  (match_operand:SI 1 "cris_bdap_operand" "r>Rn,r>Rn,r,>Rn")))
 	(match_operand:SI 2 "register_operand" "r,r,r,r"))
    (set (match_operand:SI 3 "register_operand" "=*0,!*2,r,r")
 	(plus:SI (match_dup 0)
@@ -786,7 +786,7 @@
 (define_insn "*clear_sidesi"
   [(set (mem:SI
 	 (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r")
-		  (match_operand:SI 1 "cris_bdap_operand" "r>Ri,r,>Ri")))
+		  (match_operand:SI 1 "cris_bdap_operand" "r>Rn,r,>Rn")))
 	(const_int 0))
    (set (match_operand:SI 2 "register_operand" "=*0,r,r")
 	(plus:SI (match_dup 0)
@@ -826,7 +826,7 @@
 (define_insn "*clear_sidehi"
   [(set (mem:HI
 	 (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r")
-		  (match_operand:SI 1 "cris_bdap_operand" "r>Ri,r,>Ri")))
+		  (match_operand:SI 1 "cris_bdap_operand" "r>Rn,r,>Rn")))
 	(const_int 0))
    (set (match_operand:SI 2 "register_operand" "=*0,r,r")
 	(plus:SI (match_dup 0)
@@ -866,7 +866,7 @@
 (define_insn "*clear_sideqi"
   [(set (mem:QI
 	 (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r")
-		  (match_operand:SI 1 "cris_bdap_operand" "r>Ri,r,>Ri")))
+		  (match_operand:SI 1 "cris_bdap_operand" "r>Rn,r,>Rn")))
 	(const_int 0))
    (set (match_operand:SI 2 "register_operand" "=*0,r,r")
 	(plus:SI (match_dup 0)
@@ -1127,7 +1127,7 @@
 	 4 "cris_extend_operator"
 	 [(mem:QI (plus:SI
 		   (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
-		   (match_operand:SI 2 "cris_bdap_operand" "r>Ri,r,>Ri")))]))
+		   (match_operand:SI 2 "cris_bdap_operand" "r>Rn,r,>Rn")))]))
    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
 	(plus:SI (match_dup 1)
 		 (match_dup 2)))]
@@ -1152,7 +1152,7 @@
 	 4 "cris_extend_operator"
 	 [(mem:QI (plus:SI
 		   (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
-		   (match_operand:SI 2 "cris_bdap_operand" "r>Ri,r,>Ri")))]))
+		   (match_operand:SI 2 "cris_bdap_operand" "r>Rn,r,>Rn")))]))
    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
 	(plus:SI (match_dup 1)
 		 (match_dup 2)))]
@@ -1177,7 +1177,7 @@
 	 4 "cris_extend_operator"
 	 [(mem:HI (plus:SI
 		   (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
-		   (match_operand:SI 2 "cris_bdap_operand" "r>Ri,r,>Ri")))]))
+		   (match_operand:SI 2 "cris_bdap_operand" "r>Rn,r,>Rn")))]))
    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
 	(plus:SI (match_dup 1)
 		 (match_dup 2)))]
@@ -1473,7 +1473,7 @@
 	 [(match_operand:QI 1 "register_operand" "0,0,0")
 	  (mem:QI (plus:SI
 		   (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
-		   (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))]))
+		   (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))]))
    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
 	(plus:SI (match_dup 2)
 		 (match_dup 3)))]
@@ -1499,7 +1499,7 @@
 	 [(match_operand:HI 1 "register_operand" "0,0,0")
 	  (mem:HI (plus:SI
 		   (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
-		   (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))]))
+		   (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))]))
    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
 	(plus:SI (match_dup 2)
 		 (match_dup 3)))]
@@ -1525,7 +1525,7 @@
 	 [(match_operand:SI 1 "register_operand" "0,0,0")
 	  (mem:SI (plus:SI
 		   (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
-		   (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))]))
+		   (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))]))
    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
 	(plus:SI (match_dup 2)
 		 (match_dup 3)))]
@@ -1624,7 +1624,7 @@
 	 5 "cris_commutative_orth_op"
 	 [(mem:QI
 	   (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
-		    (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))
+		    (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))
 	  (match_operand:QI 1 "register_operand" "0,0,0")]))
    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
 	(plus:SI (match_dup 2)
@@ -1650,7 +1650,7 @@
 	 5 "cris_commutative_orth_op"
 	 [(mem:HI
 	   (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
-		    (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))
+		    (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))
 	  (match_operand:HI 1 "register_operand" "0,0,0")]))
    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
 	(plus:SI (match_dup 2)
@@ -1676,7 +1676,7 @@
 	 5 "cris_commutative_orth_op"
 	 [(mem:SI
 	   (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
-		    (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))
+		    (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))
 	  (match_operand:SI 1 "register_operand" "0,0,0")]))
    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
 	(plus:SI (match_dup 2)
@@ -1965,7 +1965,7 @@
 	   6 "cris_extend_operator"
 	   [(mem:QI
 	     (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
-		      (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")
+		      (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")
 		      ))])]))
    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
 	(plus:SI (match_dup 2)
@@ -1995,7 +1995,7 @@
 	   6 "cris_extend_operator"
 	   [(mem:QI
 	     (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
-		      (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")
+		      (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")
 		      ))])]))
    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
 	(plus:SI (match_dup 2)
@@ -2026,7 +2026,7 @@
 	   6 "cris_extend_operator"
 	   [(mem:HI
 	     (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
-		      (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")
+		      (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")
 		      ))])]))
    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
 	(plus:SI (match_dup 2)
@@ -2135,7 +2135,7 @@
 	   5 "cris_extend_operator"
 	   [(mem:QI (plus:SI
 		     (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
-		     (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))])
+		     (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))])
 	  (match_operand:HI 1 "register_operand" "0,0,0")]))
    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
 	(plus:SI (match_dup 2)
@@ -2164,7 +2164,7 @@
 	   5 "cris_extend_operator"
 	   [(mem:QI (plus:SI
 		     (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
-		     (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))])
+		     (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))])
 	  (match_operand:SI 1 "register_operand" "0,0,0")]))
    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
 	(plus:SI (match_dup 2)
@@ -2193,7 +2193,7 @@
 	   5 "cris_extend_operator"
 	   [(mem:HI (plus:SI
 		     (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
-		     (match_operand:SI 3 "cris_bdap_operand" "r>Ri,r,>Ri")))])
+		     (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))])
 	  (match_operand:SI 1 "register_operand" "0,0,0")]))
    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
 	(plus:SI (match_dup 2)
@@ -4854,10 +4854,10 @@
 
 (define_peephole
   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
-	(match_operand:SI 1 "cris_bdap_biap_operand" "r,>Ri,r,>Ri"))
+	(match_operand:SI 1 "cris_bdap_biap_operand" "r,>Rn,r,>Rn"))
    (set (match_dup 0)
-	(plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Ri,r")
-		 (match_operand:SI 3 "cris_bdap_biap_operand" "r>Ri,r,0,0")))
+	(plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Rn,r")
+		 (match_operand:SI 3 "cris_bdap_biap_operand" "r>Rn,r,0,0")))
    (set (match_operand 4 "register_operand" "=r,r,r,r")
 	(mem (match_dup 0)))]
   "(rtx_equal_p (operands[2], operands[0])
@@ -4882,10 +4882,10 @@
 
 (define_peephole
   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
-	(match_operand:SI 1 "cris_bdap_biap_operand" "r,>Ri,r,>Ri"))
+	(match_operand:SI 1 "cris_bdap_biap_operand" "r,>Rn,r,>Rn"))
    (set (match_dup 0)
-	(plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Ri,r")
-		 (match_operand:SI 3 "cris_bdap_biap_operand" "r>Ri,r,0,0")))
+	(plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Rn,r")
+		 (match_operand:SI 3 "cris_bdap_biap_operand" "r>Rn,r,0,0")))
    (set (mem (match_dup 0))
 	(match_operand 4 "register_operand" "=r,r,r,r"))]
   "(rtx_equal_p (operands[2], operands[0])
@@ -4912,10 +4912,10 @@
 
 (define_peephole
   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
-	(match_operand:SI 1 "cris_bdap_biap_operand" "r,>Ri,r,>Ri"))
+	(match_operand:SI 1 "cris_bdap_biap_operand" "r,>Rn,r,>Rn"))
    (set (match_dup 0)
-	(plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Ri,r")
-		 (match_operand:SI 3 "cris_bdap_biap_operand" "r>Ri,r,0,0")))
+	(plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Rn,r")
+		 (match_operand:SI 3 "cris_bdap_biap_operand" "r>Rn,r,0,0")))
    (set (match_operand 4 "register_operand" "=r,r,r,r")
 	(match_operator 5 "cris_orthogonal_operator"
 			[(match_dup 3)
@@ -4942,10 +4942,10 @@
 
 (define_peephole
   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
-	(match_operand:SI 1 "cris_bdap_biap_operand" "r,>Ri,r,>Ri"))
+	(match_operand:SI 1 "cris_bdap_biap_operand" "r,>Rn,r,>Rn"))
    (set (match_dup 0)
-	(plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Ri,r")
-		 (match_operand:SI 3 "cris_bdap_biap_operand" "r>Ri,r,0,0")))
+	(plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Rn,r")
+		 (match_operand:SI 3 "cris_bdap_biap_operand" "r>Rn,r,0,0")))
    (set (match_operand 4 "register_operand" "=r,r,r,r")
 	(match_operator 5 "cris_commutative_orth_op"
 			[(mem (match_dup 0))
@@ -5014,8 +5014,8 @@
 (define_peephole
   [(set (match_operand 0 "register_operand" "=r,r,r,r")
 	(mem (plus:SI
-	      (match_operand:SI 1 "cris_bdap_biap_operand" "r,r>Ri,r,r>Ri")
-	      (match_operand:SI 2 "cris_bdap_biap_operand" "r>Ri,r,r>Ri,r"))))
+	      (match_operand:SI 1 "cris_bdap_biap_operand" "r,r>Rn,r,r>Rn")
+	      (match_operand:SI 2 "cris_bdap_biap_operand" "r>Rn,r,r>Rn,r"))))
    (set (match_dup 0)
 	(match_operator 5 "cris_commutative_orth_op"
 			[(match_operand 3 "register_operand" "0,0,r,r")
--- /dev/null	Tue Jan  1 05:00:00 1980
+++ gcc.dg/20030414-1.c	Sun Apr 13 20:44:48 2003
@@ -0,0 +1,39 @@
+/* PR target/10377
+   Distilled by Hans-Peter Nilsson <hp at axis dot com> from ncurses-5.3 infocmp.c.
+   Copyright (C) 2003 Free Software Foundation.  */
+
+/* { dg-do assemble } */
+/* { dg-options "-O2 -fPIC" { target *-*-*gnu* } } */
+
+extern int f2 (char *, char *);
+extern char *ss[];
+extern char *cc;
+void
+f1 (char *dd, char *bb)
+{
+  char *sp = bb + 1;
+  char *ap;
+  int i;
+  char *ee = 0;
+  char *cp;
+
+  for (i = 0, cp = cc; i < 42; i++)
+    if (cp)
+      {
+	if (f2 (dd, "xx") || f2 (ss[i], "xx") || f2 (ss[i], "yy"))
+	  if (bb < cp)
+	    continue;
+	ee = ss[i];
+	break;
+      }
+
+  if (!ee)
+    for (ap = cc; *ap; ap++)
+      if (f2(ap, sp))
+	{
+	  ee = ap;
+	  break;
+	}
+
+  cc = ee;
+}

brgds, H-P


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