This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fixing gcc.c-torture/compile/pr44707.c for CRIS v32 2/2: RFC: CONSTANT_ADDRESS_P and its default are evil!


I think CONSTANT_ADDRESS_P can and should be eliminated,
replaced by something like
 CONSTANT_P (x) && targetm.legitimate_address_p (QImode, x, false)
(or QImode replaced by the known used mode) in the code
currently calling it.

It should, because the default definition is redundant and evil;
easy to miss for targets where (mem (const x)) is not valid for
any arbitrary generic x (symbol_ref, label_ref or const_int,
including offsetted ones; (plus x (const_int N)).

This is the case for CRIS v32, for which only (mem reg) and (mem
(post_inc reg)) are valid.  Like ia64 it has no offsettable
addressing mode.  For example, the constraint in
gcc.c-torture/compile/pr44707.c of "nro" can only match for the
"r" part.

If your target fails gcc.c-torture/compile/pr44707.c, this might
be the reason.

No regressions for cris-elf nor crisv32-elf; fixes
gcc.c-torture/compile/pr44707.c for the latter.  Committed.

	* config/cris/cris-protos.h (cris_legitimate_address_p): Declare.
	* config/cris/cris.h (CONSTANT_ADDRESS_P): Define in terms of
	CONSTANT_P and cris_legitimate_address_p.
	* config/cris/cris.c (cris_legitimate_address_p): Make non-static.

Index: config/cris/cris.c
===================================================================
--- config/cris/cris.c	(revision 189506)
+++ config/cris/cris.c	(working copy)
@@ -127,8 +127,6 @@ static void cris_init_libfuncs (void);
 
 static reg_class_t cris_preferred_reload_class (rtx, reg_class_t);
 
-static bool cris_legitimate_address_p (enum machine_mode, rtx, bool);
-
 static int cris_register_move_cost (enum machine_mode, reg_class_t, reg_class_t);
 static int cris_memory_move_cost (enum machine_mode, reg_class_t, bool);
 static bool cris_rtx_costs (rtx, int, int, int, int *, bool);
@@ -1414,7 +1412,7 @@ cris_biap_index_p (const_rtx x, bool str
    here (but is thankfully a general_operand in itself).  A local PIC
    symbol is valid for the plain "symbol + offset" case.  */
 
-static bool
+bool
 cris_legitimate_address_p (enum machine_mode mode, rtx x, bool strict)
 {
   const_rtx x1, x2;
Index: config/cris/cris.h
===================================================================
--- config/cris/cris.h	(revision 189504)
+++ config/cris/cris.h	(working copy)
@@ -778,6 +778,9 @@ struct cum_args {int regs;};
 
 #define HAVE_POST_INCREMENT 1
 
+#define CONSTANT_ADDRESS_P(X) \
+  (CONSTANT_P (X) && cris_legitimate_address_p (QImode, X, false))
+
 /* Must be a compile-time constant, so we go with the highest value
    among all CRIS variants.  */
 #define MAX_REGS_PER_ADDRESS 2
Index: config/cris/cris-protos.h
===================================================================
--- config/cris/cris-protos.h	(revision 189499)
+++ config/cris/cris-protos.h	(working copy)
@@ -40,6 +40,7 @@ extern bool cris_base_p (const_rtx, bool
 extern bool cris_base_or_autoincr_p (const_rtx, bool);
 extern bool cris_bdap_index_p (const_rtx, bool);
 extern bool cris_biap_index_p (const_rtx, bool);
+extern bool cris_legitimate_address_p (enum machine_mode, rtx, bool);
 extern bool cris_store_multiple_op_p (rtx);
 extern bool cris_movem_load_rest_p (rtx, int);
 extern void cris_asm_output_symbol_ref (FILE *, rtx);

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]