1 From f00b0f17d6889d811468c2c77508fbea8bfc377d Mon Sep 17 00:00:00 2001
2 From: Claudiu Zissulescu <claziss@synopsys.com>
3 Date: Tue, 19 Jan 2016 14:40:16 +0100
4 Subject: [PATCH] UPDATE1: Fix handling complex PIC moves.
6 The arc_legitimate_pc_offset_p condition is too lax. Updated it.
8 The fix is done in development tree: [arc-4.8-dev f00b0f1]
9 and will be a part of the next release of ARC GNU tools.
10 Once that new release happens this patch must be removed.
13 2016-01-18 Claudiu Zissulescu <claziss@synopsys.com>
15 * config/arc/arc.c (arc_needs_pcl_p ): New function
16 (arc_legitimate_pc_offset_p): Use arc_needs_pcl_p.
18 gcc/config/arc/arc.c | 42 ++++++++++++++++++++++++++++++++++++++++--
19 1 file changed, 40 insertions(+), 2 deletions(-)
21 diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
22 index f7cae9f..18d88a3 100644
23 --- a/gcc/config/arc/arc.c
24 +++ b/gcc/config/arc/arc.c
25 @@ -5234,6 +5234,45 @@ arc_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED,
29 +/* Helper used by arc_legitimate_pc_offset_p. */
32 +arc_needs_pcl_p (rtx x)
34 + register const char *fmt;
37 + if ((GET_CODE (x) == UNSPEC)
38 + && (XVECLEN (x, 0) == 1)
39 + && (GET_CODE (XVECEXP (x, 0, 0)) == SYMBOL_REF))
40 + switch (XINT (x, 1))
42 + case ARC_UNSPEC_GOT:
43 + case ARC_UNSPEC_GOTOFFPC:
51 + fmt = GET_RTX_FORMAT (GET_CODE (x));
52 + for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
56 + if (arc_needs_pcl_p (XEXP (x, i)))
59 + else if (fmt[i] == 'E')
60 + for (j = XVECLEN (x, i) - 1; j >= 0; j--)
61 + if (arc_needs_pcl_p (XVECEXP (x, i, j)))
68 /* Return true if ADDR is an address that needs to be expressed as an
69 explicit sum of pcl + offset. */
71 @@ -5242,8 +5281,7 @@ arc_legitimate_pc_offset_p (rtx addr)
73 if (GET_CODE (addr) != CONST)
75 - addr = XEXP (addr, 0);
76 - return flag_pic && !arc_raw_symbolic_reference_mentioned_p (addr, false);
77 + return arc_needs_pcl_p (addr);
80 /* Return true if ADDR is a valid pic address.