diff mbox series

[SPARC] Fix more UNSPEC notes during libgo build

Message ID 2165141.vqUrzexPze@polaris
State New
Headers show
Series [SPARC] Fix more UNSPEC notes during libgo build | expand

Commit Message

Eric Botcazou Jan. 22, 2019, 10:20 a.m. UTC
There were a couple of issues in the code for mov{si,di}_pic_label_ref in 
sparc_delegitimize_address: it wouldn't recognize the GOT register and it 
wouldn't recognize a decoded HIGH/LO_SUM combination.

Tested on SPARC/Solaris 11, applied on the mainline.


2019-01-22  Eric Botcazou  <ebotcazou@adacore.com>

	* config/sparc/sparc.c (parc_delegitimize_address): Recognize the GOT
	register and decoded HIGH/LO_SUM combinations for labels in PIC mode.
diff mbox series

Patch

Index: config/sparc/sparc.c
===================================================================
--- config/sparc/sparc.c	(revision 268071)
+++ config/sparc/sparc.c	(working copy)
@@ -4995,17 +4995,23 @@  sparc_delegitimize_address (rtx x)
 
   /* This is generated by mov{si,di}_pic_label_ref in PIC mode.  */
   if (GET_CODE (x) == MINUS
-      && sparc_pic_register_p (XEXP (x, 0))
-      && GET_CODE (XEXP (x, 1)) == LO_SUM
-      && GET_CODE (XEXP (XEXP (x, 1), 1)) == UNSPEC
-      && XINT (XEXP (XEXP (x, 1), 1), 1) == UNSPEC_MOVE_PIC_LABEL)
+      && (XEXP (x, 0) == global_offset_table_rtx
+	  || sparc_pic_register_p (XEXP (x, 0))))
     {
-      x = XVECEXP (XEXP (XEXP (x, 1), 1), 0, 0);
-      gcc_assert (GET_CODE (x) == LABEL_REF
-		  || (GET_CODE (x) == CONST
-		      && GET_CODE (XEXP (x, 0)) == PLUS
-		      && GET_CODE (XEXP (XEXP (x, 0), 0)) == LABEL_REF
-		      && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT));
+      rtx y = XEXP (x, 1);
+
+      if (GET_CODE (y) == LO_SUM)
+	y = XEXP (y, 1);
+
+      if (GET_CODE (y) == UNSPEC && XINT (y, 1) == UNSPEC_MOVE_PIC_LABEL)
+	{
+	  x = XVECEXP (y, 0, 0);
+	  gcc_assert (GET_CODE (x) == LABEL_REF
+		      || (GET_CODE (x) == CONST
+			  && GET_CODE (XEXP (x, 0)) == PLUS
+			  && GET_CODE (XEXP (XEXP (x, 0), 0)) == LABEL_REF
+			  && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT));
+	}
     }
 
   return x;