[Patch] pr63937: TARGET_USE_BY_PIECES_INFRASTRUCTURE_P should take an unsigned HOST_WIDE_INT size argument

2014-11-18 Thread James Greenhalgh

Hi,

The TARGET_USE_BY_PIECES_INFRASTRUCTURE_P hook takes an unsigned
int for the size of memory operation. This is dangerous, as all the
callers of this hook pass an unsigned HOST_WIDE_INT.

This causes pr63937, where the compiler ends up trying to emit
an unfeasible number of instructions for a word-by-word copy of a  4GB
array (which wraps around and becomes an 8-byte copy that the compiler
momentarily thinks can be done in a single instruction, D'oh).

This target hook should be using unsigned HOST_WIDE_INT in line with
what its callers expect.

Fixed as attached.

An x86_64 bootstrap comes back clean, and I've built cross-compilers
for the other touched targets

Thanks,
James

---
2014-11-18  James Greenhalgh  james.greenha...@arm.com

PR target/63937
* target.def (use_by_pieces_infrastructure_p): Take unsigned
HOST_WIDE_INT as the size parameter.
* targhooks.c (default_use_by_pieces_infrastructure_p): Likewise.
* targhooks.h (default_use_by_pieces_infrastructure_p): Likewise.
* config/arc/arc.c (arc_use_by_pieces_infrastructure_p)): Likewise.
* config/mips/mips.c (mips_use_by_pieces_infrastructure_p)): Likewise.
* config/s390/s390.c (s390_use_by_pieces_infrastructure_p)): Likewise.
* config/sh/sh.c (sh_use_by_pieces_infrastructure_p)): Likewise.
* config/aarch64/aarch64.c
(aarch64_use_by_pieces_infrastructure_p)): Likewise.
* doc/tm.texi: Regenerate.

2014-11-18  James Greenhalgh  james.greenha...@arm.com

* gcc.dg/memset-2.c: New.
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 3548335..fd3c819 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -10196,7 +10196,7 @@ aarch64_asan_shadow_offset (void)
 }
 
 static bool
-aarch64_use_by_pieces_infrastructure_p (unsigned int size,
+aarch64_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT size,
 	unsigned int align,
 	enum by_pieces_operation op,
 	bool speed_p)
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 0f3825e..764f736 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -416,7 +416,7 @@ static void output_short_suffix (FILE *file);
 
 static bool arc_frame_pointer_required (void);
 
-static bool arc_use_by_pieces_infrastructure_p (unsigned int,
+static bool arc_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT,
 		unsigned int,
 		enum by_pieces_operation op,
 		bool);
@@ -9374,7 +9374,7 @@ arc_legitimize_reload_address (rtx *p, machine_mode mode, int opnum,
 /* Implement TARGET_USE_BY_PIECES_INFRASTRUCTURE_P.  */
 
 static bool
-arc_use_by_pieces_infrastructure_p (unsigned int size,
+arc_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT size,
 unsigned int align,
 enum by_pieces_operation op,
 bool speed_p)
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 02268f3..db58d07 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -7235,7 +7235,7 @@ mips_function_ok_for_sibcall (tree decl, tree exp ATTRIBUTE_UNUSED)
 /* Implement TARGET_USE_MOVE_BY_PIECES_INFRASTRUCTURE_P.  */
 
 bool
-mips_use_by_pieces_infrastructure_p (unsigned int size,
+mips_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT size,
  unsigned int align,
  enum by_pieces_operation op,
  bool speed_p)
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 3152762..ae3ffd1 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -12036,7 +12036,7 @@ s390_option_override (void)
 /* Implement TARGET_USE_BY_PIECES_INFRASTRUCTURE_P.  */
 
 static bool
-s390_use_by_pieces_infrastructure_p (unsigned int size,
+s390_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT size,
  unsigned int align ATTRIBUTE_UNUSED,
  enum by_pieces_operation op ATTRIBUTE_UNUSED,
  bool speed_p ATTRIBUTE_UNUSED)
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index 5bac2af..e449121 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -338,7 +338,7 @@ static void sh_conditional_register_usage (void);
 static bool sh_legitimate_constant_p (machine_mode, rtx);
 static int mov_insn_size (machine_mode, bool);
 static int mov_insn_alignment_mask (machine_mode, bool);
-static bool sh_use_by_pieces_infrastructure_p (unsigned int,
+static bool sh_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT,
 	   unsigned int,
 	   enum by_pieces_operation,
 	   bool);
@@ -13680,7 +13680,7 @@ sh_mode_priority (int entity ATTRIBUTE_UNUSED, int n)
 /* Implement TARGET_USE_BY_PIECES_INFRASTRUCTURE_P.  */
 
 static bool
-sh_use_by_pieces_infrastructure_p (unsigned int size,
+sh_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT size,
    unsigned int align,
    enum by_pieces_operation op,
    bool speed_p)
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index c09c510..0d3a9fd 100644
--- a/gcc/doc/tm.texi
+++ 

Re: [Patch] pr63937: TARGET_USE_BY_PIECES_INFRASTRUCTURE_P should take an unsigned HOST_WIDE_INT size argument

2014-11-18 Thread Jakub Jelinek
On Tue, Nov 18, 2014 at 09:57:37PM +, James Greenhalgh wrote:
 2014-11-18  James Greenhalgh  james.greenha...@arm.com
 
   PR target/63937
   * target.def (use_by_pieces_infrastructure_p): Take unsigned
   HOST_WIDE_INT as the size parameter.
   * targhooks.c (default_use_by_pieces_infrastructure_p): Likewise.
   * targhooks.h (default_use_by_pieces_infrastructure_p): Likewise.
   * config/arc/arc.c (arc_use_by_pieces_infrastructure_p)): Likewise.
   * config/mips/mips.c (mips_use_by_pieces_infrastructure_p)): Likewise.
   * config/s390/s390.c (s390_use_by_pieces_infrastructure_p)): Likewise.
   * config/sh/sh.c (sh_use_by_pieces_infrastructure_p)): Likewise.
   * config/aarch64/aarch64.c
   (aarch64_use_by_pieces_infrastructure_p)): Likewise.
   * doc/tm.texi: Regenerate.
 
 2014-11-18  James Greenhalgh  james.greenha...@arm.com
 
   * gcc.dg/memset-2.c: New.

Please mention the PR also in the testsuite/ChangeLog entry.
Ok with that change, thanks.

Jakub