diff --git a/gcc/ChangeLog b/gcc/ChangeLog index feda772ffc6..e45075c7e62 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-01-22 Eric Botcazou + + * config/sparc/sparc.c (parc_delegitimize_address): Recognize the GOT + register and decoded HIGH/LO_SUM combinations for labels in PIC mode. + 2019-01-22 Jakub Jelinek PR tree-optimization/88044 diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index dc6f94d1906..da909c0c6e7 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -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;