[committed] Fix PR target/40575

John David Anglin dave@hiauly1.hia.nrc.ca
Wed Jul 1 17:07:00 GMT 2009


The attached change fixes a problem with switch statements in PIC code
when labels are aligned to a boundary greater than the instruction
alignment.

The "ldo" instruction used to determine the address of the jump table
will fail if the alignment amount is too big.  In that case, more instructions
would be needed to compute the address of the jump table.  That's just going
to waste memory and reduce performance, so I can't see supporting this.

Tested on hppa-unknown-linux-gnu and hppa64-hp-hpux11.11.

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

2009-07-01  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	PR target/40575
	* pa.md (casesi32p): Use jump table label to determine the offset
	of the jump table.
	(casesi64p): Likewise.

Index: config/pa/pa.md
===================================================================
--- config/pa/pa.md	(revision 149031)
+++ config/pa/pa.md	(working copy)
@@ -7130,7 +7130,7 @@
    (clobber (match_scratch:SI 2 "=&r"))
    (clobber (match_scratch:SI 3 "=&r"))]
   "flag_pic"
-  "{bl .+8,%2\;depi 0,31,2,%2|mfia %2}\;ldo {16|20}(%2),%2\;\
+  "{bl .+8,%2\;depi 0,31,2,%2|mfia %2}\;ldo {%l1-.|%l1+4-.}(%2),%2\;\
 {ldwx|ldw},s %0(%2),%3\;{addl|add,l} %2,%3,%3\;bv,n %%r0(%3)"
   [(set_attr "type" "multi")
    (set (attr "length")
@@ -7148,7 +7148,7 @@
    (clobber (match_scratch:DI 2 "=&r"))
    (clobber (match_scratch:DI 3 "=&r"))]
   ""
-  "mfia %2\;ldo 24(%2),%2\;ldw,s %0(%2),%3\;extrd,s %3,63,32,%3\;\
+  "mfia %2\;ldo %l1+4-.(%2),%2\;ldw,s %0(%2),%3\;extrd,s %3,63,32,%3\;\
 add,l %2,%3,%3\;bv,n %%r0(%3)"
   [(set_attr "type" "multi")
    (set_attr "length" "24")])



More information about the Gcc-patches mailing list