1 From b55922d45fd16f5e8fc7c3885da42b2b9b37754d Mon Sep 17 00:00:00 2001
2 From: Claudiu Zissulescu <claziss@synopsys.com>
3 Date: Mon, 18 Jan 2016 16:43:18 +0100
4 Subject: [PATCH] UPDATE: Fix handling complex PIC moves.
6 fwprop is putting in the REG_EQUIV notes which are involving the
7 constant pic unspecs. Then, loop may use those notes for
8 optimizations rezulting in complex patterns that are not supported by
9 the current implementation. The following piece of code tries to
10 convert the complex instruction in simpler ones.
12 The fix is done in development tree: [arc-4.8-dev b55922d]
13 and will be a part of the next release of ARC GNU tools.
14 Once that new release happens this patch must be removed.
18 2016-01-18 Claudiu Zissulescu <claziss@synopsys.com>
20 * config/arc/arc.c (arc_legitimize_pic_address): Handle MINUS
21 operations when doing PIC moves. Make this function static.
22 (arc_legitimate_pc_offset_p): Use
23 arc_raw_symbolic_reference_mentioned_p.
24 * config/arc/arc-protos.h (arc_legitimize_pic_address): Remove.
26 gcc/config/arc/arc-protos.h | 1 -
27 gcc/config/arc/arc.c | 33 +++++++++++++++++++--------------
28 2 files changed, 19 insertions(+), 15 deletions(-)
30 * config/arc/arc.c (arc_legitimize_pic_address): Handle complex
31 diff --git a/gcc/config/arc/arc-protos.h b/gcc/config/arc/arc-protos.h
32 index 464e0ab..5986e06 100644
33 --- a/gcc/config/arc/arc-protos.h
34 +++ b/gcc/config/arc/arc-protos.h
35 @@ -53,7 +53,6 @@ extern unsigned int arc_compute_frame_size ();
36 extern bool arc_ccfsm_branch_deleted_p (void);
37 extern void arc_ccfsm_record_branch_deleted (void);
39 -extern rtx arc_legitimize_pic_address (rtx, rtx);
40 void arc_asm_output_aligned_decl_local (FILE *, tree, const char *,
41 unsigned HOST_WIDE_INT,
42 unsigned HOST_WIDE_INT,
43 diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
44 index a89c8ee..f7cae9f 100644
45 --- a/gcc/config/arc/arc.c
46 +++ b/gcc/config/arc/arc.c
47 @@ -5243,19 +5243,7 @@ arc_legitimate_pc_offset_p (rtx addr)
48 if (GET_CODE (addr) != CONST)
50 addr = XEXP (addr, 0);
51 - if (GET_CODE (addr) == PLUS)
53 - if (GET_CODE (XEXP (addr, 1)) != CONST_INT)
55 - addr = XEXP (addr, 0);
57 - return (GET_CODE (addr) == UNSPEC
58 - && XVECLEN (addr, 0) == 1
59 - && (XINT (addr, 1) == ARC_UNSPEC_GOT
60 - || XINT (addr, 1) == ARC_UNSPEC_GOTOFFPC
61 - || XINT (addr, 1) == UNSPEC_TLS_GD
62 - || XINT (addr, 1) == UNSPEC_TLS_IE)
63 - && GET_CODE (XVECEXP (addr, 0, 0)) == SYMBOL_REF);
64 + return flag_pic && !arc_raw_symbolic_reference_mentioned_p (addr, false);
67 /* Return true if ADDR is a valid pic address.
68 @@ -5522,7 +5510,7 @@ arc_legitimize_tls_address (rtx addr, enum tls_model model)
69 The return value is the legitimated address.
70 If OLDX is non-zero, it is the target to assign the address to first. */
74 arc_legitimize_pic_address (rtx orig, rtx oldx)
77 @@ -5569,6 +5557,23 @@ arc_legitimize_pic_address (rtx orig, rtx oldx)
78 /* Check that the unspec is one of the ones we generate? */
81 + else if (GET_CODE (addr) == MINUS)
83 + /* The same story with fwprop. */
84 + rtx op0 = XEXP (addr, 0);
85 + rtx op1 = XEXP (addr, 1);
87 + gcc_assert (GET_CODE (op1) == UNSPEC);
89 + emit_move_insn (oldx,
90 + gen_rtx_CONST (SImode,
91 + arc_legitimize_pic_address (op1,
93 + emit_insn (gen_rtx_SET (VOIDmode, oldx,
94 + gen_rtx_MINUS (SImode, op0, oldx)));
98 else if (GET_CODE (addr) != PLUS)
100 /* fwprop is putting in the REG_EQUIV notes which are