From: Uros Bizjak Date: Thu, 29 Mar 2012 19:19:26 +0000 (+0200) Subject: backport: re PR target/52698 (-maddress-mode=long doesn't work) X-Git-Tag: releases/gcc-4.6.4~614 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3524e8093774c3368f4b48401f53b107360e5eba;p=thirdparty%2Fgcc.git backport: re PR target/52698 (-maddress-mode=long doesn't work) Backported from mainline 2012-03-27 Uros Bizjak PR target/52698 * config/i386/i386-protos.h (ix86_legitimize_reload_address): New prototype. * config/i386/i386.h (LEGITIMIZE_RELOAD_ADDRESS): New define. * config/i386/i386.c: Include reload.h. (ix86_legitimize_reload_address): New function. From-SVN: r185973 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d0d023643327..c86086a54dd3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2012-03-29 Uros Bizjak + + Backported from mainline + 2012-03-27 Uros Bizjak + + PR target/52698 + * config/i386/i386-protos.h (ix86_legitimize_reload_address): + New prototype. + * config/i386/i386.h (LEGITIMIZE_RELOAD_ADDRESS): New define. + * config/i386/i386.c: Include reload.h. + (ix86_legitimize_reload_address): New function. + 2012-03-28 Joey Ye Backported from mainline @@ -39,7 +51,7 @@ * config/avr/libgcc.S (__prologue_saves__, __epilogue_restores__) * config/avr/avr.md (movhi_sp_r_irq_off, movhi_sp_r_irq_on) * config/avr/avr.c (output_movhi, avr_file_start) - + 2012-03-28 Jakub Jelinek PR target/52736 @@ -51,7 +63,7 @@ Backport from mainline PR regression/52696 * predict.c (predict_paths_for_bb): Fix typo. - + 2012-03-24 Jan Hubicka Backport from mainline @@ -59,8 +71,8 @@ * cgraph.c (cgraph_remove_node_and_inline_clones): Add FORBIDDEN_NODE parameter. * cgraph.h (cgraph_remove_node_and_inline_clones): Update prototype. - * ipa-inline-transform.c (save_inline_function_body): Remove copied clone - if needed. + * ipa-inline-transform.c (save_inline_function_body): Remove copied + clone if needed. * tree-inline.c (delete_unreachable_blocks_update_callgraph): Update. 2012-03-24 Steven Bosscher @@ -125,8 +137,7 @@ (vector_ltgt): Likewise. (vector_ordered): Likewise. (vector_unordered): Likewise. - * config/rs6000/rs6000.c (rs6000_emit_vector_compare_inner): - Likewise. + * config/rs6000/rs6000.c (rs6000_emit_vector_compare_inner): Likewise. 2012-03-04 John David Anglin diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 4f90b502167a..d4513fa8ee9b 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -59,7 +59,8 @@ extern bool legitimate_constant_p (rtx); extern bool constant_address_p (rtx); extern bool legitimate_pic_operand_p (rtx); extern bool legitimate_pic_address_disp_p (rtx); - +extern bool ix86_legitimize_reload_address (rtx, enum machine_mode, + int, int, int); extern void print_reg (rtx, int, FILE*); extern void ix86_print_operand (FILE *, rtx, int); diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index a58a8cac2a57..b8022a894243 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see #include "target.h" #include "target-def.h" #include "langhooks.h" +#include "reload.h" #include "cgraph.h" #include "gimple.h" #include "dwarf2.h" @@ -12168,6 +12169,64 @@ legitimate_pic_address_disp_p (rtx disp) return false; } +/* Our implementation of LEGITIMIZE_RELOAD_ADDRESS. Returns a value to + replace the input X, or the original X if no replacement is called for. + The output parameter *WIN is 1 if the calling macro should goto WIN, + 0 if it should not. */ + +bool +ix86_legitimize_reload_address (rtx x, + enum machine_mode mode ATTRIBUTE_UNUSED, + int opnum, int type, + int ind_levels ATTRIBUTE_UNUSED) +{ + /* Reload can generate: + + (plus:DI (plus:DI (unspec:DI [(const_int 0 [0])] UNSPEC_TP) + (reg:DI 97)) + (reg:DI 2 cx)) + + This RTX is rejected from ix86_legitimate_address_p due to + non-strictness of base register 97. Following this rejection, + reload pushes all three components into separate registers, + creating invalid memory address RTX. + + Following code reloads only the invalid part of the + memory address RTX. */ + + if (GET_CODE (x) == PLUS + && REG_P (XEXP (x, 1)) + && GET_CODE (XEXP (x, 0)) == PLUS + && REG_P (XEXP (XEXP (x, 0), 1))) + { + rtx base, index; + bool something_reloaded = false; + + base = XEXP (XEXP (x, 0), 1); + if (!REG_OK_FOR_BASE_STRICT_P (base)) + { + push_reload (base, NULL_RTX, &XEXP (XEXP (x, 0), 1), NULL, + BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0, + opnum, (enum reload_type)type); + something_reloaded = true; + } + + index = XEXP (x, 1); + if (!REG_OK_FOR_INDEX_STRICT_P (index)) + { + push_reload (index, NULL_RTX, &XEXP (x, 1), NULL, + INDEX_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0, + opnum, (enum reload_type)type); + something_reloaded = true; + } + + gcc_assert (something_reloaded); + return true; + } + + return false; +} + /* Recognizes RTL expressions that are valid memory addresses for an instruction. The MODE argument is the machine mode for the MEM expression that wants to use this address. diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index dcb3f295ac78..b342930f84ae 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -1668,6 +1668,17 @@ typedef struct ix86_args { #define LEGITIMATE_CONSTANT_P(X) legitimate_constant_p (X) +/* Try a machine-dependent way of reloading an illegitimate address + operand. If we find one, push the reload and jump to WIN. This + macro is used in only one place: `find_reloads_address' in reload.c. */ + +#define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, INDL, WIN) \ +do { \ + if (ix86_legitimize_reload_address ((X), (MODE), (OPNUM), \ + (int)(TYPE), (INDL))) \ + goto WIN; \ +} while (0) + /* If defined, a C expression to determine the base term of address X. This macro is used in only one place: `find_base_term' in alias.c.