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]

Re: Don't query the frontend for unsupported types


Richard Biener <richard.guenther@gmail.com> writes:
> On Thu, Sep 21, 2017 at 2:56 PM, Richard Sandiford
> <richard.sandiford@linaro.org> wrote:
>> Richard Biener <richard.guenther@gmail.com> writes:
>>> On September 20, 2017 2:36:03 PM GMT+02:00, Richard Sandiford
>>> <richard.sandiford@linaro.org> wrote:
>>>>When forcing a constant of mode MODE into memory, force_const_mem
>>>>asks the frontend to provide the type associated with that mode.
>>>>In principle type_for_mode is allowed to return null, and although
>>>>one use site correctly handled that, the other didn't.
>>>>
>>>>I think there's agreement that it's bogus to use type_for_mode for
>>>>this kind of thing, since it forces frontends to handle types that
>>>>don't exist in that language.  See e.g. http://gcc.gnu.org/PR46805
>>>>where the Go frontend was forced to handle vector types even though
>>>>Go doesn't have vector types.
>>>>
>>>>Also, the frontends use code like:
>>>>
>>>>  else if (VECTOR_MODE_P (mode))
>>>>    {
>>>>      machine_mode inner_mode = GET_MODE_INNER (mode);
>>>>      tree inner_type = c_common_type_for_mode (inner_mode, unsignedp);
>>>>      if (inner_type != NULL_TREE)
>>>>        return build_vector_type_for_mode (inner_type, mode);
>>>>    }
>>>>
>>>>and there's no guarantee that every vector mode M used by backend
>>>>rtl has an associated vector type whose TYPE_MODE is M.  I think
>>>>really the type_for_mode hook should only return trees that _do_ have
>>>>the requested TYPE_MODE, but PR46805 linked above shows that this is
>>>>likely to have too many knock-on consequences.  It doesn't make sense
>>>>for force_const_mem to ask about vector modes that aren't valid for
>>>>vector types, so this patch handles the condition there instead.
>>>>
>>>>This is needed for SVE multi-register modes, which are modelled as
>>>>vector modes but are not usable as vector types.
>>>>
>>>>Tested on aarch64-linux-gnu, x86_64-linux-gnu and
>>>>powerpc64le-linus-gnu.
>>>>OK to install?
>>>
>>> I think we should get rid of the use entirely.
>>
>> I first read this as not using type_for_mode at all in force_const_mem,
>> which sounded like a good thing :-)
>
> That's what I meant ;)  A mode doesn't really have a type...
>
>   I tried it overnight on the usual
>> at-least-one-target-per-CPU set and diffing the before and after
>> assembly for the testsuite.  And it looks like i686 relies on this
>> to get an alignment of 16 rather than 4 for XFmode constants:
>> GET_MODE_ALIGNMENT (XFmode) == 32 (as requested by i386-modes.def),
>> but i386's CONSTANT_ALIGNMENT increases it to 128 for static constants.
>
> Then the issue is that CONSTANT_ALIGNMENT takes a tree and not a mode...
> even worse than type_for_mode is a use of make_tree!  Incidentially
> ix86_constant_alignment _does_ look at the mode in the end...

OK, I guess this means another target hook conversion.  The patch
below converts CONSTANT_ALIGNMENT with its current interface.
The definition:

  #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
    (TREE_CODE (EXP) == STRING_CST \
     && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))

was very common, so the patch adds a canned definition for that,
called constant_alignment_word_strings.  Some ports had a variation
that used a port-local FASTEST_ALIGNMENT instead of BITS_PER_WORD;
the patch uses constant_alignment_word_strings if FASTEST_ALIGNMENT
was always BITS_PER_WORD and a port-local hook function otherwise.

Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu.
Also tested by comparing the testsuite assembly output on at least one
target per CPU directory.  I don't think this comes under Jeff's
preapproval due to the constant_alignment_word_strings thing, so:
OK to install?

If so, then I'll follow up with a separate hook for rtl modes, which
varasm, default_constant_alignment and constant_alignment_word_strings
can all use.

Thanks,
Richard


2017-09-22  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
	* target.def (constant_alignment): New hook.
	* defaults.h (CONSTANT_ALIGNMENT): Delete.
	* doc/tm.texi.in (CONSTANT_ALIGNMENT): Replace with...
	(TARGET_CONSTANT_ALIGNMENT): ...this new hook.
	* doc/tm.texi: Regenerate.
	* targhooks.h (default_constant_alignment): Declare.
	(constant_alignment_word_strings): Likewise.
	* targhooks.c (default_constant_alignment): New function.
	(constant_alignment_word_strings): Likewise.
	* builtins.c (get_object_alignment_2): Use targetm.constant_alignment
	instead of CONSTANT_ALIGNMENT.
	* varasm.c (align_variable, get_variable_align, build_constant_desc)
	(force_const_mem): Likewise.
	* config/aarch64/aarch64.h (CONSTANT_ALIGNMENT): Delete.
	* config/aarch64/aarch64.c (aarch64_constant_alignment): New function.
	(aarch64_classify_address): Call it instead of CONSTANT_ALIGNMENT.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/alpha/alpha.h (CONSTANT_ALIGNMENT): Delete commented-out
	definition.
	* config/arc/arc.h (CONSTANT_ALIGNMENT): Delete.
	* config/arc/arc.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/arm/arm.h (CONSTANT_ALIGNMENT_FACTOR): Delete.
	(CONSTANT_ALIGNMENT): Likewise.
	* config/arm/arm.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(arm_constant_alignment): New function.
	* config/bfin/bfin.h (CONSTANT_ALIGNMENT): Delete.
	* config/bfin/bfin.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/cr16/cr16.h (CONSTANT_ALIGNMENT): Delete.
	* config/cr16/cr16.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/cris/cris.h (CONSTANT_ALIGNMENT): Delete.
	* config/cris/cris.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(cris_constant_alignment): New function.
	* config/epiphany/epiphany.h (CONSTANT_ALIGNMENT): Delete.
	* config/epiphany/epiphany.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(epiphany_constant_alignment): New function.
	* config/fr30/fr30.h (CONSTANT_ALIGNMENT): Delete.
	* config/fr30/fr30.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/frv/frv.h (CONSTANT_ALIGNMENT): Delete.
	* config/frv/frv.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/ft32/ft32.h (CONSTANT_ALIGNMENT): Delete.
	* config/ft32/ft32.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/i386/i386.h (CONSTANT_ALIGNMENT): Delete.
	* config/i386/i386-protos.h (ix86_constant_alignment): Delete.
	* config/i386/i386.c (ix86_constant_alignment): Make static.
	Use the same interface as the target hook.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/ia64/ia64.h (CONSTANT_ALIGNMENT): Delete.
	* config/ia64/ia64.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/iq2000/iq2000.h (CONSTANT_ALIGNMENT): Delete.
	* config/iq2000/iq2000.c (iq2000_constant_alignment): New function.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/lm32/lm32.h (CONSTANT_ALIGNMENT): Delete.
	* config/lm32/lm32.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/m32r/m32r.h (CONSTANT_ALIGNMENT): Delete.
	* config/m32r/m32r.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/mcore/mcore.h (CONSTANT_ALIGNMENT): Delete.
	* config/mcore/mcore.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/microblaze/microblaze.h (CONSTANT_ALIGNMENT): Delete.
	* config/microblaze/microblaze.c (microblaze_constant_alignment):
	New function.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/mips/mips.h (CONSTANT_ALIGNMENT): Delete.
	* config/mips/mips.c (mips_constant_alignment): New function.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/mmix/mmix.h (CONSTANT_ALIGNMENT): Delete.
	* config/mmix/mmix-protos.h (mmix_constant_alignment): Delete.
	* config/mmix/mmix.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(mmix_constant_alignment): Make static.  Use the same interface
	as the target hook.
	* config/moxie/moxie.h (CONSTANT_ALIGNMENT): Delete.
	* config/moxie/moxie.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/nios2/nios2.h (CONSTANT_ALIGNMENT): Delete.
	* config/nios2/nios2.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/pa/pa.h (CONSTANT_ALIGNMENT): Delete.
	* config/pa/pa.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/powerpcspe/powerpcspe.h (CONSTANT_ALIGNMENT): Delete.
	* config/powerpcspe/powerpcspe.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(rs6000_constant_alignment): New function.
	* config/riscv/riscv.h (CONSTANT_ALIGNMENT): Delete.
	* config/riscv/riscv.c (riscv_constant_alignment): New function.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/rs6000/rs6000.h (CONSTANT_ALIGNMENT): Delete.
	* config/rs6000/rs6000.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(rs6000_constant_alignment): New function.
	* config/s390/s390.h (CONSTANT_ALIGNMENT): Delete.
	* config/s390/s390.c (s390_constant_alignment): New function.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/sh/sh.h (CONSTANT_ALIGNMENT): Delete.
	* config/sh/sh.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/sparc/sparc.h (CONSTANT_ALIGNMENT): Delete.
	* config/sparc/sparc.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(sparc_constant_alignment): New function.
	* config/spu/spu.h (CONSTANT_ALIGNMENT): Delete.
	* config/spu/spu.c (spu_constant_alignment): New function.
	(TARGET_CONSTANT_ALIGNMENT): Redefine.
	* config/stormy16/stormy16.h (CONSTANT_ALIGNMENT): Delete.
	* config/stormy16/stormy16.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/tilegx/tilegx.h (CONSTANT_ALIGNMENT): Delete.
	* config/tilegx/tilegx.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/tilepro/tilepro.h (CONSTANT_ALIGNMENT): Delete.
	* config/tilepro/tilepro.c (TARGET_CONSTANT_ALIGNMENT): Redefine to
	constant_alignment_word_strings.
	* config/visium/visium.h (CONSTANT_ALIGNMENT): Delete.
	* config/visium/visium.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(visium_constant_alignment): New function.
	* config/xtensa/xtensa.h (CONSTANT_ALIGNMENT): Delete.
	* config/xtensa/xtensa.c (TARGET_CONSTANT_ALIGNMENT): Redefine.
	(xtensa_constant_alignment): New function.
	* system.h (CONSTANT_ALIGNMENT): Poison.

Index: gcc/target.def
===================================================================
--- gcc/target.def	2017-09-22 17:31:56.428954480 +0100
+++ gcc/target.def	2017-09-22 17:37:26.791614385 +0100
@@ -3335,6 +3335,21 @@ HOOK_VECTOR_END (addr_space)
 #undef HOOK_PREFIX
 #define HOOK_PREFIX "TARGET_"
 
+DEFHOOK
+(constant_alignment,
+ "This hook returns the alignment in bits of a constant that is being\n\
+placed in memory.  @var{constant} is the constant and @var{basic_align}\n\
+is the alignment that the object would ordinarily have.\n\
+\n\
+The default definition just returns @var{basic_align}.\n\
+\n\
+The typical use of this hook is to increase alignment for string\n\
+constants to be word aligned so that @code{strcpy} calls that copy\n\
+constants can be done inline.  The function\n\
+@code{constant_alignment_word_strings} provides such a definition.",
+ HOST_WIDE_INT, (const_tree constant, HOST_WIDE_INT basic_align),
+ default_constant_alignment)
+
 /* True if MODE is valid for the target.  By "valid", we mean able to
    be manipulated in non-trivial ways.  In particular, this means all
    the arithmetic is supported.  */
Index: gcc/defaults.h
===================================================================
--- gcc/defaults.h	2017-09-12 14:27:14.524325620 +0100
+++ gcc/defaults.h	2017-09-22 17:37:26.788614385 +0100
@@ -1265,10 +1265,6 @@ #define WORD_REGISTER_OPERATIONS 0
 #define LOAD_EXTEND_OP(M) UNKNOWN
 #endif
 
-#ifndef CONSTANT_ALIGNMENT
-#define CONSTANT_ALIGNMENT(EXP, ALIGN) ALIGN
-#endif
-
 #ifndef INITIAL_FRAME_ADDRESS_RTX
 #define INITIAL_FRAME_ADDRESS_RTX NULL
 #endif
Index: gcc/doc/tm.texi.in
===================================================================
--- gcc/doc/tm.texi.in	2017-09-22 17:31:36.934389276 +0100
+++ gcc/doc/tm.texi.in	2017-09-22 17:37:26.790614385 +0100
@@ -1050,19 +1050,7 @@ must be aligned to 16 byte boundaries.
 If this macro is not defined, then @var{basic-align} is used.
 @end defmac
 
-@defmac CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align})
-If defined, a C expression to compute the alignment given to a constant
-that is being placed in memory.  @var{constant} is the constant and
-@var{basic-align} is the alignment that the object would ordinarily
-have.  The value of this macro is used instead of that alignment to
-align the object.
-
-The default definition just returns @var{basic-align}.
-
-The typical use of this macro is to increase alignment for string
-constants to be word aligned so that @code{strcpy} calls that copy
-constants can be done inline.
-@end defmac
+@hook TARGET_CONSTANT_ALIGNMENT
 
 @defmac LOCAL_ALIGNMENT (@var{type}, @var{basic-align})
 If defined, a C expression to compute the alignment for a variable in
Index: gcc/doc/tm.texi
===================================================================
--- gcc/doc/tm.texi	2017-09-22 17:31:56.428006577 +0100
+++ gcc/doc/tm.texi	2017-09-22 17:37:26.789614385 +0100
@@ -1102,19 +1102,18 @@ must be aligned to 16 byte boundaries.
 If this macro is not defined, then @var{basic-align} is used.
 @end defmac
 
-@defmac CONSTANT_ALIGNMENT (@var{constant}, @var{basic-align})
-If defined, a C expression to compute the alignment given to a constant
-that is being placed in memory.  @var{constant} is the constant and
-@var{basic-align} is the alignment that the object would ordinarily
-have.  The value of this macro is used instead of that alignment to
-align the object.
+@deftypefn {Target Hook} HOST_WIDE_INT TARGET_CONSTANT_ALIGNMENT (const_tree @var{constant}, HOST_WIDE_INT @var{basic_align})
+This hook returns the alignment in bits of a constant that is being
+placed in memory.  @var{constant} is the constant and @var{basic_align}
+is the alignment that the object would ordinarily have.
 
-The default definition just returns @var{basic-align}.
+The default definition just returns @var{basic_align}.
 
-The typical use of this macro is to increase alignment for string
+The typical use of this hook is to increase alignment for string
 constants to be word aligned so that @code{strcpy} calls that copy
-constants can be done inline.
-@end defmac
+constants can be done inline.  The function
+@code{constant_alignment_word_strings} provides such a definition.
+@end deftypefn
 
 @defmac LOCAL_ALIGNMENT (@var{type}, @var{basic-align})
 If defined, a C expression to compute the alignment for a variable in
Index: gcc/targhooks.h
===================================================================
--- gcc/targhooks.h	2017-09-22 17:31:36.935337179 +0100
+++ gcc/targhooks.h	2017-09-22 17:37:26.791614385 +0100
@@ -93,6 +93,9 @@ extern int default_builtin_vectorization
 
 extern tree default_builtin_reciprocal (tree);
 
+extern HOST_WIDE_INT default_constant_alignment (const_tree, HOST_WIDE_INT);
+extern HOST_WIDE_INT constant_alignment_word_strings (const_tree,
+						      HOST_WIDE_INT);
 extern HOST_WIDE_INT default_vector_alignment (const_tree);
 
 extern HOST_WIDE_INT default_preferred_vector_alignment (const_tree);
Index: gcc/targhooks.c
===================================================================
--- gcc/targhooks.c	2017-09-22 17:31:36.935337179 +0100
+++ gcc/targhooks.c	2017-09-22 17:37:26.791614385 +0100
@@ -1165,6 +1165,25 @@ tree default_mangle_decl_assembler_name
    return id;
 }
 
+/* The default implementation of TARGET_CONSTANT_ALIGNMENT.  */
+
+HOST_WIDE_INT
+default_constant_alignment (const_tree, HOST_WIDE_INT align)
+{
+  return align;
+}
+
+/* An implementation of TARGET_CONSTANT_ALIGNMENT that aligns strings
+   to at least BITS_PER_WORD but otherwise makes no changes.  */
+
+HOST_WIDE_INT
+constant_alignment_word_strings (const_tree exp, HOST_WIDE_INT align)
+{
+  if (TREE_CODE (exp) == STRING_CST)
+    return MAX (align, BITS_PER_WORD);
+  return align;
+}
+
 /* Default to natural alignment for vector types.  */
 HOST_WIDE_INT
 default_vector_alignment (const_tree type)
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c	2017-09-05 20:56:49.744887619 +0100
+++ gcc/builtins.c	2017-09-22 17:37:26.746614388 +0100
@@ -283,7 +283,7 @@ get_object_alignment_2 (tree exp, unsign
       exp = DECL_INITIAL (exp);
       align = TYPE_ALIGN (TREE_TYPE (exp));
       if (CONSTANT_CLASS_P (exp))
-	align = (unsigned) CONSTANT_ALIGNMENT (exp, align);
+	align = targetm.constant_alignment (exp, align);
 
       known_alignment = true;
     }
@@ -359,7 +359,7 @@ get_object_alignment_2 (tree exp, unsign
          wrapped inside a CONST_DECL.  */
       align = TYPE_ALIGN (TREE_TYPE (exp));
       if (CONSTANT_CLASS_P (exp))
-	align = (unsigned) CONSTANT_ALIGNMENT (exp, align);
+	align = targetm.constant_alignment (exp, align);
 
       known_alignment = true;
     }
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c	2017-09-21 22:34:52.782138953 +0100
+++ gcc/varasm.c	2017-09-22 17:37:26.792614385 +0100
@@ -1055,7 +1055,7 @@ align_variable (tree decl, bool dont_out
 	      && (in_lto_p || DECL_INITIAL (decl) != error_mark_node))
 	    {
 	      unsigned int const_align
-		= CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
+		= targetm.constant_alignment (DECL_INITIAL (decl), align);
 	      /* Don't increase alignment too much for TLS variables - TLS
 		 space is too precious.  */
 	      if (! DECL_THREAD_LOCAL_P (decl) || const_align <= BITS_PER_WORD)
@@ -1106,8 +1106,8 @@ get_variable_align (tree decl)
 	     to mark offlined constructors.  */
 	  && (in_lto_p || DECL_INITIAL (decl) != error_mark_node))
 	{
-	  unsigned int const_align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl),
-							 align);
+	  unsigned int const_align
+	    = targetm.constant_alignment (DECL_INITIAL (decl), align);
 	  /* Don't increase alignment too much for TLS variables - TLS space
 	     is too precious.  */
 	  if (! DECL_THREAD_LOCAL_P (decl) || const_align <= BITS_PER_WORD)
@@ -3326,12 +3326,10 @@ build_constant_desc (tree exp)
      Instead we set the flag that will be recognized in make_decl_rtl.  */
   DECL_IN_CONSTANT_POOL (decl) = 1;
   DECL_INITIAL (decl) = desc->value;
-  /* ??? CONSTANT_ALIGNMENT hasn't been updated for vector types on most
-     architectures so use DATA_ALIGNMENT as well, except for strings.  */
+  /* ??? targetm.constant_alignment hasn't been updated for vector types on
+     most architectures so use DATA_ALIGNMENT as well, except for strings.  */
   if (TREE_CODE (exp) == STRING_CST)
-    {
-      SET_DECL_ALIGN (decl, CONSTANT_ALIGNMENT (exp, DECL_ALIGN (decl)));
-    }
+    SET_DECL_ALIGN (decl, targetm.constant_alignment (exp, DECL_ALIGN (decl)));
   else
     align_variable (decl, 0);
 
@@ -3790,7 +3788,7 @@ force_const_mem (machine_mode mode, rtx
 
   tree type = lang_hooks.types.type_for_mode (mode, 0);
   if (type != NULL_TREE)
-    align = CONSTANT_ALIGNMENT (make_tree (type, x), align);
+    align = targetm.constant_alignment (make_tree (type, x), align);
 
   pool->offset += (align / BITS_PER_UNIT) - 1;
   pool->offset &= ~ ((align / BITS_PER_UNIT) - 1);
Index: gcc/config/aarch64/aarch64.h
===================================================================
--- gcc/config/aarch64/aarch64.h	2017-09-21 22:35:16.977238356 +0100
+++ gcc/config/aarch64/aarch64.h	2017-09-22 17:37:26.747614388 +0100
@@ -90,14 +90,6 @@ #define LONG_DOUBLE_TYPE_SIZE	128
    port.  */
 #define TARGET_PTRMEMFUNC_VBIT_LOCATION ptrmemfunc_vbit_in_delta
 
-/* Make strings word-aligned so that strcpy from constants will be
-   faster.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)		\
-  ((TREE_CODE (EXP) == STRING_CST		\
-    && !optimize_size				\
-    && (ALIGN) < BITS_PER_WORD)			\
-   ? BITS_PER_WORD : ALIGN)
-
 /* Align definitions of arrays, unions and structures so that
    initializations and copies can be made more efficient.  This is not
    ABI-changing, so it only affects places where we can see the
Index: gcc/config/aarch64/aarch64.c
===================================================================
--- gcc/config/aarch64/aarch64.c	2017-09-22 17:35:22.483794044 +0100
+++ gcc/config/aarch64/aarch64.c	2017-09-22 17:37:26.747614388 +0100
@@ -1142,6 +1142,17 @@ aarch64_hard_regno_caller_save_mode (uns
     return choose_hard_reg_mode (regno, nregs, false);
 }
 
+/* Implement TARGET_CONSTANT_ALIGNMENT.  Make strings word-aligned so
+   that strcpy from constants will be faster.  */
+
+static HOST_WIDE_INT
+aarch64_constant_alignment (const_tree exp, HOST_WIDE_INT align)
+{
+  if (TREE_CODE (exp) == STRING_CST && !optimize_size)
+    return MAX (align, BITS_PER_WORD);
+  return align;
+}
+
 /* Return true if calls to DECL should be treated as
    long-calls (ie called via a register).  */
 static bool
@@ -4622,7 +4633,7 @@ aarch64_classify_address (struct aarch64
 		{
 		  tree exp = SYMBOL_REF_DECL (sym);
 		  align = TYPE_ALIGN (TREE_TYPE (exp));
-		  align = CONSTANT_ALIGNMENT (exp, align);
+		  align = aarch64_constant_alignment (exp, align);
 		}
 	      else if (SYMBOL_REF_DECL (sym))
 		align = DECL_ALIGN (SYMBOL_REF_DECL (sym));
@@ -15687,6 +15698,9 @@ #define TARGET_MODES_TIEABLE_P aarch64_m
 #define TARGET_HARD_REGNO_CALL_PART_CLOBBERED \
   aarch64_hard_regno_call_part_clobbered
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT aarch64_constant_alignment
+
 #if CHECKING_P
 #undef TARGET_RUN_TARGET_SELFTESTS
 #define TARGET_RUN_TARGET_SELFTESTS selftest::aarch64_run_selftests
Index: gcc/config/alpha/alpha.h
===================================================================
--- gcc/config/alpha/alpha.h	2017-09-15 14:47:33.167333414 +0100
+++ gcc/config/alpha/alpha.h	2017-09-22 17:37:26.748614388 +0100
@@ -289,7 +289,6 @@ #define MINIMUM_ATOMIC_ALIGNMENT ((unsig
 /* ??? Only if block-move stuff knows about different source/destination
    alignment.  */
 #if 0
-#define CONSTANT_ALIGNMENT(EXP, ALIGN) MAX ((ALIGN), BITS_PER_WORD)
 #define DATA_ALIGNMENT(EXP, ALIGN) MAX ((ALIGN), BITS_PER_WORD)
 #endif
 
Index: gcc/config/arc/arc.h
===================================================================
--- gcc/config/arc/arc.h	2017-09-15 14:47:33.167333414 +0100
+++ gcc/config/arc/arc.h	2017-09-22 17:37:26.749614388 +0100
@@ -271,13 +271,6 @@ #define BIGGEST_ALIGNMENT 32
 /* The best alignment to use in cases where we have a choice.  */
 #define FASTEST_ALIGNMENT 32
 
-/* Make strings word-aligned so strcpy from constants will be faster.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
-  ((TREE_CODE (EXP) == STRING_CST	\
-    && (ALIGN) < FASTEST_ALIGNMENT)	\
-   ? FASTEST_ALIGNMENT : (ALIGN))
-
-
 /* Make arrays of chars word-aligned for the same reasons.  */
 #define LOCAL_ALIGNMENT(TYPE, ALIGN)             \
   (TREE_CODE (TYPE) == ARRAY_TYPE               \
Index: gcc/config/arc/arc.c
===================================================================
--- gcc/config/arc/arc.c	2017-09-12 14:29:25.225531070 +0100
+++ gcc/config/arc/arc.c	2017-09-22 17:37:26.749614388 +0100
@@ -10657,6 +10657,9 @@ arc_use_anchors_for_symbol_p (const_rtx
 #undef TARGET_USE_ANCHORS_FOR_SYMBOL_P
 #define TARGET_USE_ANCHORS_FOR_SYMBOL_P arc_use_anchors_for_symbol_p
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-arc.h"
Index: gcc/config/arm/arm.h
===================================================================
--- gcc/config/arm/arm.h	2017-09-22 17:22:08.191305805 +0100
+++ gcc/config/arm/arm.h	2017-09-22 17:37:26.752614387 +0100
@@ -592,15 +592,6 @@ #define MALLOC_ABI_ALIGNMENT  BIGGEST_AL
 #define BIGGEST_FIELD_ALIGNMENT 64
 #endif
 
-/* Make strings word-aligned so strcpy from constants will be faster.  */
-#define CONSTANT_ALIGNMENT_FACTOR (TARGET_THUMB || ! arm_tune_xscale ? 1 : 2)
-
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)				\
-   ((TREE_CODE (EXP) == STRING_CST				\
-     && !optimize_size						\
-     && (ALIGN) < BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR)	\
-    ? BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR : (ALIGN))
-
 /* Align definitions of arrays, unions and structures so that
    initializations and copies can be made more efficient.  This is not
    ABI-changing, so it only affects places where we can see the
Index: gcc/config/arm/arm.c
===================================================================
--- gcc/config/arm/arm.c	2017-09-22 17:35:22.486794044 +0100
+++ gcc/config/arm/arm.c	2017-09-22 17:37:26.751614388 +0100
@@ -316,6 +316,7 @@ static opt_scalar_float_mode arm_floatn_
 static unsigned int arm_hard_regno_nregs (unsigned int, machine_mode);
 static bool arm_hard_regno_mode_ok (unsigned int, machine_mode);
 static bool arm_modes_tieable_p (machine_mode, machine_mode);
+static HOST_WIDE_INT arm_constant_alignment (const_tree, HOST_WIDE_INT);
 
 /* Table of machine attributes.  */
 static const struct attribute_spec arm_attribute_table[] =
@@ -795,6 +796,9 @@ #define TARGET_MODES_TIEABLE_P arm_modes
 
 #undef TARGET_CAN_CHANGE_MODE_CLASS
 #define TARGET_CAN_CHANGE_MODE_CLASS arm_can_change_mode_class
+
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT arm_constant_alignment
 
 /* Obstack for minipool constant handling.  */
 static struct obstack minipool_obstack;
@@ -31276,6 +31280,18 @@ arm_can_change_mode_class (machine_mode
   return true;
 }
 
+/* Implement TARGET_CONSTANT_ALIGNMENT.  Make strings word-aligned so
+   strcpy from constants will be faster.  */
+
+static HOST_WIDE_INT
+arm_constant_alignment (const_tree exp, HOST_WIDE_INT align)
+{
+  unsigned int factor = (TARGET_THUMB || ! arm_tune_xscale ? 1 : 2);
+  if (TREE_CODE (exp) == STRING_CST && !optimize_size)
+    return MAX (align, BITS_PER_WORD * factor);
+  return align;
+}
+
 #if CHECKING_P
 namespace selftest {
 
Index: gcc/config/bfin/bfin.h
===================================================================
--- gcc/config/bfin/bfin.h	2017-09-15 14:47:33.168333307 +0100
+++ gcc/config/bfin/bfin.h	2017-09-22 17:37:26.753614387 +0100
@@ -321,11 +321,6 @@ #define ACCUMULATE_OUTGOING_ARGS 1
 
 #define LOCAL_ALIGNMENT(TYPE, ALIGN) bfin_local_alignment ((TYPE), (ALIGN))
 
-/* Make strings word-aligned so strcpy from constants will be faster.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
-  (TREE_CODE (EXP) == STRING_CST        \
-   && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))    
-
 #define TRAMPOLINE_SIZE (TARGET_FDPIC ? 30 : 18)
 
 /* Definitions for register eliminations.
Index: gcc/config/bfin/bfin.c
===================================================================
--- gcc/config/bfin/bfin.c	2017-09-12 14:29:25.228530938 +0100
+++ gcc/config/bfin/bfin.c	2017-09-22 17:37:26.752614387 +0100
@@ -5882,4 +5882,7 @@ #define TARGET_HARD_REGNO_MODE_OK bfin_h
 #undef TARGET_MODES_TIEABLE_P
 #define TARGET_MODES_TIEABLE_P bfin_modes_tieable_p
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
 struct gcc_target targetm = TARGET_INITIALIZER;
Index: gcc/config/cr16/cr16.h
===================================================================
--- gcc/config/cr16/cr16.h	2017-09-15 14:47:33.168333307 +0100
+++ gcc/config/cr16/cr16.h	2017-09-22 17:37:26.753614387 +0100
@@ -114,11 +114,6 @@ #define DATA_ALIGNMENT(TYPE, ALIGN)
      && ((ALIGN) < BITS_PER_WORD))               \
      ? (BITS_PER_WORD) : (ALIGN))
 
-/* In CR16 strings are word-aligned; strcpy from constants will be faster.  */
-#define CONSTANT_ALIGNMENT(CONSTANT, ALIGN)                            \
-  (((TREE_CODE (CONSTANT) == STRING_CST) && ((ALIGN) < BITS_PER_WORD)) \
-     ? (BITS_PER_WORD) : (ALIGN))
-
 #define STRICT_ALIGNMENT 0
 
 #define PCC_BITFIELD_TYPE_MATTERS 1
Index: gcc/config/cr16/cr16.c
===================================================================
--- gcc/config/cr16/cr16.c	2017-09-12 14:29:25.229530894 +0100
+++ gcc/config/cr16/cr16.c	2017-09-22 17:37:26.753614387 +0100
@@ -200,6 +200,9 @@ #define TARGET_REGISTER_MOVE_COST 	cr16_
 #undef TARGET_MEMORY_MOVE_COST
 #define TARGET_MEMORY_MOVE_COST 	cr16_memory_move_cost
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT	constant_alignment_word_strings
+
 /* Table of machine attributes.  */
 static const struct attribute_spec cr16_attribute_table[] = {
   /* ISRs have special prologue and epilogue requirements.  */
Index: gcc/config/cris/cris.h
===================================================================
--- gcc/config/cris/cris.h	2017-09-15 14:47:33.169333199 +0100
+++ gcc/config/cris/cris.h	2017-09-22 17:37:26.754614387 +0100
@@ -368,17 +368,6 @@ #define DATA_ALIGNMENT(TYPE, BASIC_ALIGN
      ? (BASIC_ALIGN < 32 ? 32 : BASIC_ALIGN)			\
      : (BASIC_ALIGN < 16 ? 16 : BASIC_ALIGN)) : BASIC_ALIGN)
 
-/* Note that CONSTANT_ALIGNMENT has the effect of making gcc believe that
-   ALL references to constant stuff (in code segment, like strings) has
-   this alignment.  That is a rather rushed assumption.  Luckily we do not
-   care about the "alignment" operand to builtin memcpy (only place where
-   it counts), so it doesn't affect any bad spots.  */
-#define CONSTANT_ALIGNMENT(CONSTANT, BASIC_ALIGN)		\
- (TARGET_CONST_ALIGN						\
-  ? (TARGET_ALIGN_BY_32						\
-     ? (BASIC_ALIGN < 32 ? 32 : BASIC_ALIGN)			\
-     : (BASIC_ALIGN < 16 ? 16 : BASIC_ALIGN)) : BASIC_ALIGN)
-
 /* FIXME: Define LOCAL_ALIGNMENT for word and dword or arrays and
    structures (if -mstack-align=), and check that it is good.  */
 
Index: gcc/config/cris/cris.c
===================================================================
--- gcc/config/cris/cris.c	2017-09-12 14:29:25.229530894 +0100
+++ gcc/config/cris/cris.c	2017-09-22 17:37:26.754614387 +0100
@@ -165,6 +165,7 @@ static bool cris_function_value_regno_p
 static void cris_file_end (void);
 static unsigned int cris_hard_regno_nregs (unsigned int, machine_mode);
 static bool cris_hard_regno_mode_ok (unsigned int, machine_mode);
+static HOST_WIDE_INT cris_constant_alignment (const_tree, HOST_WIDE_INT);
 
 /* This is the parsed result of the "-max-stack-stackframe=" option.  If
    it (still) is zero, then there was no such option given.  */
@@ -287,6 +288,9 @@ #define TARGET_HARD_REGNO_NREGS cris_har
 #undef TARGET_HARD_REGNO_MODE_OK
 #define TARGET_HARD_REGNO_MODE_OK cris_hard_regno_mode_ok
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT cris_constant_alignment
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Helper for cris_load_multiple_op and cris_ret_movem_op.  */
@@ -4325,6 +4329,23 @@ cris_hard_regno_mode_ok (unsigned int re
 	      || (regno != CRIS_MOF_REGNUM && regno != CRIS_ACR_REGNUM)));
 }
 
+/* Implement TARGET_CONSTANT_ALIGNMENT.  Note that this hook has the
+   effect of making gcc believe that ALL references to constant stuff
+   (in code segment, like strings) have this alignment.  That is a rather
+   rushed assumption.  Luckily we do not care about the "alignment"
+   operand to builtin memcpy (only place where it counts), so it doesn't
+   affect any bad spots.  */
+
+static HOST_WIDE_INT
+cris_constant_alignment (const_tree, HOST_WIDE_INT basic_align)
+{
+  if (!TARGET_CONST_ALIGN)
+    return basic_align;
+  if (TARGET_ALIGN_BY_32)
+    return MAX (basic_align, 32);
+  return MAX (basic_align, 16);
+}
+
 #if 0
 /* Various small functions to replace macros.  Only called from a
    debugger.  They might collide with gcc functions or system functions,
Index: gcc/config/epiphany/epiphany.h
===================================================================
--- gcc/config/epiphany/epiphany.h	2017-09-15 14:47:33.169333199 +0100
+++ gcc/config/epiphany/epiphany.h	2017-09-22 17:37:26.754614387 +0100
@@ -147,12 +147,6 @@ #define FASTEST_ALIGNMENT 64
 
 #define MALLOC_ABI_ALIGNMENT BIGGEST_ALIGNMENT
 
-/* Make strings dword-aligned so strcpy from constants will be faster.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
-  ((TREE_CODE (EXP) == STRING_CST	\
-    && (ALIGN) < FASTEST_ALIGNMENT)	\
-   ? FASTEST_ALIGNMENT : (ALIGN))
-
 /* Make arrays of chars dword-aligned for the same reasons.
    Also, align arrays of SImode items.  */
 #define DATA_ALIGNMENT(TYPE, ALIGN)		\
Index: gcc/config/epiphany/epiphany.c
===================================================================
--- gcc/config/epiphany/epiphany.c	2017-09-04 11:49:42.897500726 +0100
+++ gcc/config/epiphany/epiphany.c	2017-09-22 17:37:26.754614387 +0100
@@ -173,6 +173,9 @@ #define TARGET_ASM_ALIGNED_SI_OP "\t.wor
 
 #undef TARGET_HARD_REGNO_MODE_OK
 #define TARGET_HARD_REGNO_MODE_OK epiphany_hard_regno_mode_ok
+
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT epiphany_constant_alignment
 
 bool
 epiphany_is_interrupt_p (tree decl)
@@ -3014,4 +3017,15 @@ epiphany_start_function (FILE *file, con
   ASM_OUTPUT_FUNCTION_LABEL (file, name, decl);
 }
 
+
+/* Implement TARGET_CONSTANT_ALIGNMENT.  */
+
+static HOST_WIDE_INT
+epiphany_constant_alignment (const_tree exp, HOST_WIDE_INT align)
+{
+  if (TREE_CODE (exp) == STRING_CST)
+    return MAX (align, FASTEST_ALIGNMENT);
+  return align;
+}
+
 struct gcc_target targetm = TARGET_INITIALIZER;
Index: gcc/config/fr30/fr30.h
===================================================================
--- gcc/config/fr30/fr30.h	2017-09-15 14:47:33.169333199 +0100
+++ gcc/config/fr30/fr30.h	2017-09-22 17:37:26.755614387 +0100
@@ -88,10 +88,6 @@ #define DATA_ALIGNMENT(TYPE, ALIGN)		\
    && TYPE_MODE (TREE_TYPE (TYPE)) == QImode	\
    && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
 
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
-  (TREE_CODE (EXP) == STRING_CST	\
-   && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
-
 #define STRICT_ALIGNMENT 1
 
 #define PCC_BITFIELD_TYPE_MATTERS 1
Index: gcc/config/fr30/fr30.c
===================================================================
--- gcc/config/fr30/fr30.c	2017-08-10 14:36:08.721447283 +0100
+++ gcc/config/fr30/fr30.c	2017-09-22 17:37:26.754614387 +0100
@@ -190,6 +190,9 @@ #define TARGET_ASM_TRAMPOLINE_TEMPLATE f
 #undef TARGET_TRAMPOLINE_INIT
 #define TARGET_TRAMPOLINE_INIT fr30_trampoline_init
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 
Index: gcc/config/frv/frv.h
===================================================================
--- gcc/config/frv/frv.h	2017-09-15 14:47:33.169333199 +0100
+++ gcc/config/frv/frv.h	2017-09-22 17:37:26.756614387 +0100
@@ -351,20 +351,6 @@ #define DATA_ALIGNMENT(TYPE, ALIGN)		\
    && TYPE_MODE (TREE_TYPE (TYPE)) == QImode	\
    && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
 
-/* If defined, a C expression to compute the alignment given to a constant that
-   is being placed in memory.  CONSTANT is the constant and ALIGN is the
-   alignment that the object would ordinarily have.  The value of this macro is
-   used instead of that alignment to align the object.
-
-   If this macro is not defined, then ALIGN is used.
-
-   The typical use of this macro is to increase alignment for string constants
-   to be word aligned so that `strcpy' calls that copy constants can be done
-   inline.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
-  (TREE_CODE (EXP) == STRING_CST	\
-   && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
-
 /* Define this macro to be the value 1 if instructions will fail to work if
    given data not on the nominal alignment.  If instructions will merely go
    slower in that case, define this macro as 0.  */
Index: gcc/config/frv/frv.c
===================================================================
--- gcc/config/frv/frv.c	2017-09-12 14:29:25.231530806 +0100
+++ gcc/config/frv/frv.c	2017-09-22 17:37:26.756614387 +0100
@@ -523,6 +523,8 @@ #define TARGET_HARD_REGNO_NREGS frv_hard
 #define TARGET_HARD_REGNO_MODE_OK frv_hard_regno_mode_ok
 #undef TARGET_MODES_TIEABLE_P
 #define TARGET_MODES_TIEABLE_P frv_modes_tieable_p
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
 
 struct gcc_target targetm = TARGET_INITIALIZER;
 
Index: gcc/config/ft32/ft32.h
===================================================================
--- gcc/config/ft32/ft32.h	2017-09-15 14:47:33.169333199 +0100
+++ gcc/config/ft32/ft32.h	2017-09-22 17:37:26.756614387 +0100
@@ -354,12 +354,6 @@ #define PCC_BITFIELD_TYPE_MATTERS
    is GET_MODE_SIZE(DImode).  */
 #define MAX_FIXED_MODE_SIZE 32
 
-/* Make strings word-aligned so strcpy from constants will be faster.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
-  ((TREE_CODE (EXP) == STRING_CST       \
-    && (ALIGN) < FASTEST_ALIGNMENT)     \
-   ? FASTEST_ALIGNMENT : (ALIGN))
-
 /* Set this nonzero if move instructions will actually fail to work
    when given unaligned data.  */
 #define STRICT_ALIGNMENT 1
Index: gcc/config/ft32/ft32.c
===================================================================
--- gcc/config/ft32/ft32.c	2017-08-30 12:18:46.608141057 +0100
+++ gcc/config/ft32/ft32.c	2017-09-22 17:37:26.756614387 +0100
@@ -940,6 +940,9 @@ ft32_elf_encode_section_info (tree decl,
     }
 }
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-ft32.h"
Index: gcc/config/i386/i386.h
===================================================================
--- gcc/config/i386/i386.h	2017-09-21 11:53:16.598005975 +0100
+++ gcc/config/i386/i386.h	2017-09-22 17:37:26.761614387 +0100
@@ -848,20 +848,6 @@ #define ADJUST_FIELD_ALIGN(FIELD, TYPE,
   x86_field_alignment ((TYPE), (COMPUTED))
 #endif
 
-/* If defined, a C expression to compute the alignment given to a
-   constant that is being placed in memory.  EXP is the constant
-   and ALIGN is the alignment that the object would ordinarily have.
-   The value of this macro is used instead of that alignment to align
-   the object.
-
-   If this macro is not defined, then ALIGN is used.
-
-   The typical use of this macro is to increase alignment for string
-   constants to be word aligned so that `strcpy' calls that copy
-   constants can be done inline.  */
-
-#define CONSTANT_ALIGNMENT(EXP, ALIGN) ix86_constant_alignment ((EXP), (ALIGN))
-
 /* If defined, a C expression to compute the alignment for a static
    variable.  TYPE is the data type, and ALIGN is the alignment that
    the object would ordinarily have.  The value of this macro is used
Index: gcc/config/i386/i386-protos.h
===================================================================
--- gcc/config/i386/i386-protos.h	2017-09-15 13:56:20.266148661 +0100
+++ gcc/config/i386/i386-protos.h	2017-09-22 17:37:26.756614387 +0100
@@ -209,7 +209,6 @@ extern unsigned int ix86_local_alignment
 					  unsigned int);
 extern unsigned int ix86_minimum_alignment (tree, machine_mode,
 					    unsigned int);
-extern int ix86_constant_alignment (tree, int);
 extern tree ix86_handle_shared_attribute (tree *, tree, tree, int, bool *);
 extern tree ix86_handle_selectany_attribute (tree *, tree, tree, int, bool *);
 extern int x86_field_alignment (tree, int);
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c	2017-09-22 17:31:56.418527551 +0100
+++ gcc/config/i386/i386.c	2017-09-22 17:37:26.760614387 +0100
@@ -31555,14 +31555,10 @@ ix86_sched_init_global (FILE *, int, int
 }
 
 
-/* Compute the alignment given to a constant that is being placed in memory.
-   EXP is the constant and ALIGN is the alignment that the object would
-   ordinarily have.
-   The value of this function is used instead of that alignment to align
-   the object.  */
+/* Implement TARGET_CONSTANT_ALIGNMENT.  */
 
-int
-ix86_constant_alignment (tree exp, int align)
+static HOST_WIDE_INT
+ix86_constant_alignment (const_tree exp, HOST_WIDE_INT align)
 {
   if (TREE_CODE (exp) == REAL_CST || TREE_CODE (exp) == VECTOR_CST
       || TREE_CODE (exp) == INTEGER_CST)
@@ -53601,6 +53597,9 @@ #define TARGET_HARD_REGNO_CALL_PART_CLOB
 #undef TARGET_CAN_CHANGE_MODE_CLASS
 #define TARGET_CAN_CHANGE_MODE_CLASS ix86_can_change_mode_class
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT ix86_constant_alignment
+
 #if CHECKING_P
 #undef TARGET_RUN_TARGET_SELFTESTS
 #define TARGET_RUN_TARGET_SELFTESTS selftest::ix86_run_selftests
Index: gcc/config/ia64/ia64.h
===================================================================
--- gcc/config/ia64/ia64.h	2017-09-15 14:47:33.170333092 +0100
+++ gcc/config/ia64/ia64.h	2017-09-22 17:37:26.762614387 +0100
@@ -185,15 +185,6 @@ #define DATA_ALIGNMENT(TYPE, ALIGN)		\
    && TYPE_MODE (TREE_TYPE (TYPE)) == QImode	\
    && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
 
-/* If defined, a C expression to compute the alignment given to a constant that
-   is being placed in memory.  CONSTANT is the constant and ALIGN is the
-   alignment that the object would ordinarily have.  The value of this macro is
-   used instead of that alignment to align the object.  */
-
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
-  (TREE_CODE (EXP) == STRING_CST	\
-   && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
-
 #define STRICT_ALIGNMENT 1
 
 /* Define this if you wish to imitate the way many other C compilers handle
Index: gcc/config/ia64/ia64.c
===================================================================
--- gcc/config/ia64/ia64.c	2017-09-22 17:31:56.419475454 +0100
+++ gcc/config/ia64/ia64.c	2017-09-22 17:37:26.762614387 +0100
@@ -672,6 +672,9 @@ #define TARGET_MODES_TIEABLE_P ia64_mode
 #undef TARGET_CAN_CHANGE_MODE_CLASS
 #define TARGET_CAN_CHANGE_MODE_CLASS ia64_can_change_mode_class
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Returns TRUE iff the target attribute indicated by ATTR_ID takes a plain
Index: gcc/config/iq2000/iq2000.h
===================================================================
--- gcc/config/iq2000/iq2000.h	2017-09-15 14:47:33.170333092 +0100
+++ gcc/config/iq2000/iq2000.h	2017-09-22 17:37:26.763614387 +0100
@@ -96,10 +96,6 @@ #define DATA_ALIGNMENT(TYPE, ALIGN)
 	|| TREE_CODE (TYPE) == UNION_TYPE				\
 	|| TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
 
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)					\
-  ((TREE_CODE (EXP) == STRING_CST  || TREE_CODE (EXP) == CONSTRUCTOR)	\
-   && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
-
 #define EMPTY_FIELD_BOUNDARY 32
 
 #define STRUCTURE_SIZE_BOUNDARY 8
Index: gcc/config/iq2000/iq2000.c
===================================================================
--- gcc/config/iq2000/iq2000.c	2017-09-04 11:50:24.548966298 +0100
+++ gcc/config/iq2000/iq2000.c	2017-09-22 17:37:26.762614387 +0100
@@ -180,6 +180,7 @@ static void iq2000_print_operand_address
 static bool iq2000_print_operand_punct_valid_p (unsigned char code);
 static bool iq2000_hard_regno_mode_ok (unsigned int, machine_mode);
 static bool iq2000_modes_tieable_p (machine_mode, machine_mode);
+static HOST_WIDE_INT iq2000_constant_alignment (const_tree, HOST_WIDE_INT);
 
 #undef  TARGET_INIT_BUILTINS
 #define TARGET_INIT_BUILTINS 		iq2000_init_builtins
@@ -264,6 +265,9 @@ #define TARGET_HARD_REGNO_MODE_OK	iq2000
 #undef  TARGET_MODES_TIEABLE_P
 #define TARGET_MODES_TIEABLE_P		iq2000_modes_tieable_p
 
+#undef  TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT	iq2000_constant_alignment
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Return nonzero if we split the address into high and low parts.  */
@@ -3532,4 +3536,14 @@ iq2000_modes_tieable_p (machine_mode mod
 	      || GET_MODE_CLASS (mode2) == MODE_COMPLEX_FLOAT));
 }
 
+/* Implement TARGET_CONSTANT_ALIGNMENT.  */
+
+static HOST_WIDE_INT
+iq2000_constant_alignment (const_tree exp, HOST_WIDE_INT align)
+{
+  if (TREE_CODE (exp) == STRING_CST || TREE_CODE (exp) == CONSTRUCTOR)
+    return MAX (align, BITS_PER_WORD);
+  return align;
+}
+
 #include "gt-iq2000.h"
Index: gcc/config/lm32/lm32.h
===================================================================
--- gcc/config/lm32/lm32.h	2017-09-15 14:47:33.171332984 +0100
+++ gcc/config/lm32/lm32.h	2017-09-22 17:37:26.763614387 +0100
@@ -99,11 +99,6 @@ #define STRICT_ALIGNMENT 1
 
 #define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT
 
-/* Make strings word-aligned so strcpy from constants will be faster.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
-  (TREE_CODE (EXP) == STRING_CST	\
-   && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
-
 /* Make arrays and structures word-aligned to allow faster copying etc.  */
 #define DATA_ALIGNMENT(TYPE, ALIGN)					\
   ((((ALIGN) < BITS_PER_WORD)						\
Index: gcc/config/lm32/lm32.c
===================================================================
--- gcc/config/lm32/lm32.c	2017-09-05 20:56:49.753937121 +0100
+++ gcc/config/lm32/lm32.c	2017-09-22 17:37:26.763614387 +0100
@@ -113,6 +113,9 @@ #define TARGET_HARD_REGNO_MODE_OK lm32_h
 #undef TARGET_MODES_TIEABLE_P
 #define TARGET_MODES_TIEABLE_P lm32_modes_tieable_p
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Current frame information calculated by lm32_compute_frame_size.  */
Index: gcc/config/m32r/m32r.h
===================================================================
--- gcc/config/m32r/m32r.h	2017-09-15 14:47:33.171332984 +0100
+++ gcc/config/m32r/m32r.h	2017-09-22 17:37:26.766614387 +0100
@@ -260,12 +260,6 @@ #define BIGGEST_ALIGNMENT 32
 /* The best alignment to use in cases where we have a choice.  */
 #define FASTEST_ALIGNMENT 32
 
-/* Make strings word-aligned so strcpy from constants will be faster.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)	\
-  ((TREE_CODE (EXP) == STRING_CST	\
-    && (ALIGN) < FASTEST_ALIGNMENT)	\
-   ? FASTEST_ALIGNMENT : (ALIGN))
-
 /* Make arrays of chars word-aligned for the same reasons.  */
 #define DATA_ALIGNMENT(TYPE, ALIGN)					\
   (TREE_CODE (TYPE) == ARRAY_TYPE					\
Index: gcc/config/m32r/m32r.c
===================================================================
--- gcc/config/m32r/m32r.c	2017-09-04 11:50:08.518432217 +0100
+++ gcc/config/m32r/m32r.c	2017-09-22 17:37:26.765614387 +0100
@@ -217,6 +217,9 @@ #define TARGET_HARD_REGNO_MODE_OK m32r_h
 #undef TARGET_MODES_TIEABLE_P
 #define TARGET_MODES_TIEABLE_P m32r_modes_tieable_p
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Called by m32r_option_override to initialize various things.  */
Index: gcc/config/mcore/mcore.h
===================================================================
--- gcc/config/mcore/mcore.h	2017-09-15 14:47:33.171332984 +0100
+++ gcc/config/mcore/mcore.h	2017-09-22 17:37:26.766614387 +0100
@@ -148,12 +148,6 @@ #define	PCC_BITFIELD_TYPE_MATTERS	1
    is GET_MODE_SIZE(DImode).  */
 #define MAX_FIXED_MODE_SIZE 32
 
-/* Make strings word-aligned so strcpy from constants will be faster.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
-  ((TREE_CODE (EXP) == STRING_CST	\
-    && (ALIGN) < FASTEST_ALIGNMENT)	\
-   ? FASTEST_ALIGNMENT : (ALIGN))
-
 /* Make arrays of chars word-aligned for the same reasons.  */
 #define DATA_ALIGNMENT(TYPE, ALIGN)		\
   (TREE_CODE (TYPE) == ARRAY_TYPE		\
Index: gcc/config/mcore/mcore.c
===================================================================
--- gcc/config/mcore/mcore.c	2017-09-04 11:50:08.519332606 +0100
+++ gcc/config/mcore/mcore.c	2017-09-22 17:37:26.766614387 +0100
@@ -248,6 +248,9 @@ #define TARGET_HARD_REGNO_MODE_OK mcore_
 #undef TARGET_MODES_TIEABLE_P
 #define TARGET_MODES_TIEABLE_P mcore_modes_tieable_p
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Adjust the stack and return the number of bytes taken to do it.  */
Index: gcc/config/microblaze/microblaze.h
===================================================================
--- gcc/config/microblaze/microblaze.h	2017-09-15 14:47:33.172332877 +0100
+++ gcc/config/microblaze/microblaze.h	2017-09-22 17:37:26.767614387 +0100
@@ -234,12 +234,6 @@ #define SIZE_TYPE "unsigned int"
 #undef PTRDIFF_TYPE
 #define PTRDIFF_TYPE "int"
 
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)					\
-  ((TREE_CODE (EXP) == STRING_CST  || TREE_CODE (EXP) == CONSTRUCTOR)	\
-   && (ALIGN) < BITS_PER_WORD						\
-	? BITS_PER_WORD							\
-	: (ALIGN))
-
 #define DATA_ALIGNMENT(TYPE, ALIGN)					\
   ((((ALIGN) < BITS_PER_WORD)						\
     && (TREE_CODE (TYPE) == ARRAY_TYPE					\
Index: gcc/config/microblaze/microblaze.c
===================================================================
--- gcc/config/microblaze/microblaze.c	2017-09-05 20:56:49.754842071 +0100
+++ gcc/config/microblaze/microblaze.c	2017-09-22 17:37:26.767614387 +0100
@@ -3800,6 +3800,16 @@ microblaze_machine_dependent_reorg (void
       return;
     }
 }
+
+/* Implement TARGET_CONSTANT_ALIGNMENT.  */
+
+static HOST_WIDE_INT
+microblaze_constant_alignment (const_tree exp, HOST_WIDE_INT align)
+{
+  if (TREE_CODE (exp) == STRING_CST || TREE_CODE (exp) == CONSTRUCTOR)
+    return MAX (align, BITS_PER_WORD);
+  return align;
+}
 
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO      microblaze_encode_section_info
@@ -3904,6 +3914,9 @@ #define TARGET_HARD_REGNO_MODE_OK microb
 #undef TARGET_MODES_TIEABLE_P
 #define TARGET_MODES_TIEABLE_P microblaze_modes_tieable_p
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT microblaze_constant_alignment
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-microblaze.h"
Index: gcc/config/mips/mips.h
===================================================================
--- gcc/config/mips/mips.h	2017-09-15 14:47:33.174332662 +0100
+++ gcc/config/mips/mips.h	2017-09-22 17:37:26.769614386 +0100
@@ -1636,22 +1636,6 @@ #define STRICT_ALIGNMENT 1
 
 #define PCC_BITFIELD_TYPE_MATTERS 1
 
-/* If defined, a C expression to compute the alignment given to a
-   constant that is being placed in memory.  CONSTANT is the constant
-   and ALIGN is the alignment that the object would ordinarily have.
-   The value of this macro is used instead of that alignment to align
-   the object.
-
-   If this macro is not defined, then ALIGN is used.
-
-   The typical use of this macro is to increase alignment for string
-   constants to be word aligned so that `strcpy' calls that copy
-   constants can be done inline.  */
-
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)					\
-  ((TREE_CODE (EXP) == STRING_CST  || TREE_CODE (EXP) == CONSTRUCTOR)	\
-   && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
-
 /* If defined, a C expression to compute the alignment for a static
    variable.  TYPE is the data type, and ALIGN is the alignment that
    the object would ordinarily have.  The value of this macro is used
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2017-09-22 17:31:56.421371259 +0100
+++ gcc/config/mips/mips.c	2017-09-22 17:37:26.769614386 +0100
@@ -22336,6 +22336,16 @@ mips_truly_noop_truncation (unsigned int
 {
   return !TARGET_64BIT || inprec <= 32 || outprec > 32;
 }
+
+/* Implement TARGET_CONSTANT_ALIGNMENT.  */
+
+static HOST_WIDE_INT
+mips_constant_alignment (const_tree exp, HOST_WIDE_INT align)
+{
+  if (TREE_CODE (exp) == STRING_CST || TREE_CODE (exp) == CONSTRUCTOR)
+    return MAX (align, BITS_PER_WORD);
+  return align;
+}
 
 /* Initialize the GCC target structure.  */
 #undef TARGET_ASM_ALIGNED_HI_OP
@@ -22634,6 +22644,9 @@ #define TARGET_CAN_CHANGE_MODE_CLASS mip
 #undef TARGET_TRULY_NOOP_TRUNCATION
 #define TARGET_TRULY_NOOP_TRUNCATION mips_truly_noop_truncation
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT mips_constant_alignment
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-mips.h"
Index: gcc/config/mmix/mmix.h
===================================================================
--- gcc/config/mmix/mmix.h	2017-09-15 14:47:33.174332662 +0100
+++ gcc/config/mmix/mmix.h	2017-09-22 17:37:26.770614386 +0100
@@ -167,9 +167,6 @@ #define MAX_OFILE_ALIGNMENT (32768 * 8)
 #define DATA_ABI_ALIGNMENT(TYPE, BASIC_ALIGN) \
  mmix_data_alignment (TYPE, BASIC_ALIGN)
 
-#define CONSTANT_ALIGNMENT(CONSTANT, BASIC_ALIGN) \
- mmix_constant_alignment (CONSTANT, BASIC_ALIGN)
-
 #define LOCAL_ALIGNMENT(TYPE, BASIC_ALIGN) \
  mmix_local_alignment (TYPE, BASIC_ALIGN)
 
Index: gcc/config/mmix/mmix-protos.h
===================================================================
--- gcc/config/mmix/mmix-protos.h	2017-02-23 19:54:26.000000000 +0000
+++ gcc/config/mmix/mmix-protos.h	2017-09-22 17:37:26.769614386 +0100
@@ -47,7 +47,6 @@ extern unsigned mmix_dbx_register_number
 extern int mmix_use_simple_return (void);
 extern void mmix_make_decl_one_only (tree);
 extern int mmix_data_alignment (tree, int);
-extern int mmix_constant_alignment (tree, int);
 extern unsigned mmix_local_alignment (tree, unsigned);
 extern void mmix_asm_output_pool_prologue (FILE *, const char *, tree, int);
 extern void mmix_asm_output_aligned_common (FILE *, const char *, int, int);
Index: gcc/config/mmix/mmix.c
===================================================================
--- gcc/config/mmix/mmix.c	2017-08-30 12:08:01.655417455 +0100
+++ gcc/config/mmix/mmix.c	2017-09-22 17:37:26.770614386 +0100
@@ -168,6 +168,7 @@ static void mmix_print_operand (FILE *,
 static void mmix_print_operand_address (FILE *, machine_mode, rtx);
 static bool mmix_print_operand_punct_valid_p (unsigned char);
 static void mmix_conditional_register_usage (void);
+static HOST_WIDE_INT mmix_constant_alignment (const_tree, HOST_WIDE_INT);
 
 /* Target structure macros.  Listed by node.  See `Using and Porting GCC'
    for a general description.  */
@@ -282,6 +283,9 @@ #define TARGET_TRAMPOLINE_INIT mmix_tram
 #undef TARGET_OPTION_OVERRIDE
 #define TARGET_OPTION_OVERRIDE mmix_option_override
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT mmix_constant_alignment
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Functions that are expansions for target macros.
@@ -334,10 +338,10 @@ mmix_data_alignment (tree type ATTRIBUTE
   return basic_align;
 }
 
-/* CONSTANT_ALIGNMENT.  */
+/* Implement tARGET_CONSTANT_ALIGNMENT.  */
 
-int
-mmix_constant_alignment (tree constant ATTRIBUTE_UNUSED, int basic_align)
+static HOST_WIDE_INT
+mmix_constant_alignment (const_tree, HOST_WIDE_INT basic_align)
 {
   if (basic_align < 32)
     return 32;
Index: gcc/config/moxie/moxie.h
===================================================================
--- gcc/config/moxie/moxie.h	2017-09-15 14:47:33.175332555 +0100
+++ gcc/config/moxie/moxie.h	2017-09-22 17:37:26.770614386 +0100
@@ -317,12 +317,6 @@ #define	PCC_BITFIELD_TYPE_MATTERS	1
    is GET_MODE_SIZE(DImode).  */
 #define MAX_FIXED_MODE_SIZE 32
 
-/* Make strings word-aligned so strcpy from constants will be faster.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
-  ((TREE_CODE (EXP) == STRING_CST	\
-    && (ALIGN) < FASTEST_ALIGNMENT)	\
-   ? FASTEST_ALIGNMENT : (ALIGN))
-
 /* Make arrays of chars word-aligned for the same reasons.  */
 #define DATA_ALIGNMENT(TYPE, ALIGN)		\
   (TREE_CODE (TYPE) == ARRAY_TYPE		\
Index: gcc/config/moxie/moxie.c
===================================================================
--- gcc/config/moxie/moxie.c	2017-08-10 14:36:08.735446777 +0100
+++ gcc/config/moxie/moxie.c	2017-09-22 17:37:26.770614386 +0100
@@ -667,6 +667,9 @@ #define TARGET_PRINT_OPERAND moxie_print
 #undef  TARGET_PRINT_OPERAND_ADDRESS
 #define TARGET_PRINT_OPERAND_ADDRESS moxie_print_operand_address
 
+#undef  TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-moxie.h"
Index: gcc/config/nios2/nios2.h
===================================================================
--- gcc/config/nios2/nios2.h	2017-09-15 14:47:33.175332555 +0100
+++ gcc/config/nios2/nios2.h	2017-09-22 17:37:26.771614386 +0100
@@ -92,10 +92,6 @@ #define STACK_BOUNDARY 32
 #define PREFERRED_STACK_BOUNDARY 32
 #define MAX_FIXED_MODE_SIZE 64
 
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)                          \
-  ((TREE_CODE (EXP) == STRING_CST)                              \
-   && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
-
 #define LABEL_ALIGN(LABEL) nios2_label_align (LABEL)
 
 /* Layout of source language data types.  */
Index: gcc/config/nios2/nios2.c
===================================================================
--- gcc/config/nios2/nios2.c	2017-09-04 11:50:24.551667467 +0100
+++ gcc/config/nios2/nios2.c	2017-09-22 17:37:26.771614386 +0100
@@ -5116,6 +5116,9 @@ #define TARGET_ASM_OUTPUT_MI_THUNK nios2
 #undef TARGET_MACHINE_DEPENDENT_REORG
 #define TARGET_MACHINE_DEPENDENT_REORG nios2_reorg
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-nios2.h"
Index: gcc/config/pa/pa.h
===================================================================
--- gcc/config/pa/pa.h	2017-09-15 14:47:33.176332447 +0100
+++ gcc/config/pa/pa.h	2017-09-22 17:37:26.772614386 +0100
@@ -309,11 +309,6 @@ #define BIGGEST_ALIGNMENT (2 * BITS_PER_
    atomic operations.  */
 #define MALLOC_ABI_ALIGNMENT (TARGET_SOM ? 64 : 128)
 
-/* Get around hp-ux assembler bug, and make strcpy of constants fast.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)		\
-  (TREE_CODE (EXP) == STRING_CST		\
-   && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
-
 /* Make arrays of chars word-aligned for the same reasons.  */
 #define DATA_ALIGNMENT(TYPE, ALIGN)		\
   (TREE_CODE (TYPE) == ARRAY_TYPE		\
Index: gcc/config/pa/pa.c
===================================================================
--- gcc/config/pa/pa.c	2017-09-15 13:56:20.276148823 +0100
+++ gcc/config/pa/pa.c	2017-09-22 17:37:26.772614386 +0100
@@ -425,6 +425,9 @@ #define TARGET_MODES_TIEABLE_P pa_modes_
 #undef TARGET_CAN_CHANGE_MODE_CLASS
 #define TARGET_CAN_CHANGE_MODE_CLASS pa_can_change_mode_class
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Parse the -mfixed-range= option string.  */
Index: gcc/config/powerpcspe/powerpcspe.h
===================================================================
--- gcc/config/powerpcspe/powerpcspe.h	2017-09-15 14:47:33.176332447 +0100
+++ gcc/config/powerpcspe/powerpcspe.h	2017-09-22 17:37:26.775614386 +0100
@@ -978,14 +978,6 @@ enum data_align { align_abi, align_opt,
 #define LOCAL_ALIGNMENT(TYPE, ALIGN)				\
   rs6000_data_alignment (TYPE, ALIGN, align_both)
 
-/* Make strings word-aligned so strcpy from constants will be faster.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)                           \
-  (TREE_CODE (EXP) == STRING_CST	                         \
-   && (STRICT_ALIGNMENT || !optimize_size)                       \
-   && (ALIGN) < BITS_PER_WORD                                    \
-   ? BITS_PER_WORD                                               \
-   : (ALIGN))
-
 /* Make arrays of chars word-aligned for the same reasons.  */
 #define DATA_ALIGNMENT(TYPE, ALIGN) \
   rs6000_data_alignment (TYPE, ALIGN, align_opt)
Index: gcc/config/powerpcspe/powerpcspe.c
===================================================================
--- gcc/config/powerpcspe/powerpcspe.c	2017-09-22 17:31:56.424214967 +0100
+++ gcc/config/powerpcspe/powerpcspe.c	2017-09-22 17:37:26.775614386 +0100
@@ -1984,6 +1984,9 @@ #define TARGET_SLOW_UNALIGNED_ACCESS rs6
 
 #undef TARGET_CAN_CHANGE_MODE_CLASS
 #define TARGET_CAN_CHANGE_MODE_CLASS rs6000_can_change_mode_class
+
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT rs6000_constant_alignment
 
 
 /* Processor table.  */
@@ -43752,6 +43755,17 @@ rs6000_optab_supported_p (int op, machin
       return true;
     }
 }
+
+/* Implement TARGET_CONSTANT_ALIGNMENT.  */
+
+static HOST_WIDE_INT
+rs6000_constant_alignment (const_tree exp, HOST_WIDE_INT align)
+{
+  if (TREE_CODE (exp) == STRING_CST
+      && (STRICT_ALIGNMENT || !optimize_size))
+    return MAX (align, BITS_PER_WORD);
+  return align;
+}
 
 struct gcc_target targetm = TARGET_INITIALIZER;
 
Index: gcc/config/riscv/riscv.h
===================================================================
--- gcc/config/riscv/riscv.h	2017-09-15 14:47:33.176332447 +0100
+++ gcc/config/riscv/riscv.h	2017-09-22 17:37:26.776614386 +0100
@@ -152,22 +152,6 @@ #define STRICT_ALIGNMENT TARGET_STRICT_A
 
 #define PCC_BITFIELD_TYPE_MATTERS 1
 
-/* If defined, a C expression to compute the alignment given to a
-   constant that is being placed in memory.  CONSTANT is the constant
-   and ALIGN is the alignment that the object would ordinarily have.
-   The value of this macro is used instead of that alignment to align
-   the object.
-
-   If this macro is not defined, then ALIGN is used.
-
-   The typical use of this macro is to increase alignment for string
-   constants to be word aligned so that `strcpy' calls that copy
-   constants can be done inline.  */
-
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)					\
-  ((TREE_CODE (EXP) == STRING_CST  || TREE_CODE (EXP) == CONSTRUCTOR)	\
-   && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
-
 /* If defined, a C expression to compute the alignment for a static
    variable.  TYPE is the data type, and ALIGN is the alignment that
    the object would ordinarily have.  The value of this macro is used
Index: gcc/config/riscv/riscv.c
===================================================================
--- gcc/config/riscv/riscv.c	2017-09-15 13:56:20.282148920 +0100
+++ gcc/config/riscv/riscv.c	2017-09-22 17:37:26.776614386 +0100
@@ -3995,6 +3995,17 @@ riscv_can_change_mode_class (machine_mod
   return !reg_classes_intersect_p (FP_REGS, rclass);
 }
 
+
+/* Implement TARGET_CONSTANT_ALIGNMENT.  */
+
+static HOST_WIDE_INT
+riscv_constant_alignment (const_tree exp, HOST_WIDE_INT align)
+{
+  if (TREE_CODE (exp) == STRING_CST || TREE_CODE (exp) == CONSTRUCTOR)
+    return MAX (align, BITS_PER_WORD);
+  return align;
+}
+
 /* Initialize the GCC target structure.  */
 #undef TARGET_ASM_ALIGNED_HI_OP
 #define TARGET_ASM_ALIGNED_HI_OP "\t.half\t"
@@ -4142,6 +4153,9 @@ #define TARGET_SECONDARY_MEMORY_NEEDED r
 #undef TARGET_CAN_CHANGE_MODE_CLASS
 #define TARGET_CAN_CHANGE_MODE_CLASS riscv_can_change_mode_class
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT riscv_constant_alignment
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-riscv.h"
Index: gcc/config/rs6000/rs6000.h
===================================================================
--- gcc/config/rs6000/rs6000.h	2017-09-15 14:47:33.177332340 +0100
+++ gcc/config/rs6000/rs6000.h	2017-09-22 17:37:26.779614386 +0100
@@ -950,14 +950,6 @@ enum data_align { align_abi, align_opt,
 #define LOCAL_ALIGNMENT(TYPE, ALIGN)				\
   rs6000_data_alignment (TYPE, ALIGN, align_both)
 
-/* Make strings word-aligned so strcpy from constants will be faster.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)                           \
-  (TREE_CODE (EXP) == STRING_CST	                         \
-   && (STRICT_ALIGNMENT || !optimize_size)                       \
-   && (ALIGN) < BITS_PER_WORD                                    \
-   ? BITS_PER_WORD                                               \
-   : (ALIGN))
-
 /* Make arrays of chars word-aligned for the same reasons.  */
 #define DATA_ALIGNMENT(TYPE, ALIGN) \
   rs6000_data_alignment (TYPE, ALIGN, align_opt)
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	2017-09-22 17:31:56.427058675 +0100
+++ gcc/config/rs6000/rs6000.c	2017-09-22 17:37:26.779614386 +0100
@@ -1974,6 +1974,9 @@ #define TARGET_SLOW_UNALIGNED_ACCESS rs6
 
 #undef TARGET_CAN_CHANGE_MODE_CLASS
 #define TARGET_CAN_CHANGE_MODE_CLASS rs6000_can_change_mode_class
+
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT rs6000_constant_alignment
 
 
 /* Processor table.  */
@@ -39128,6 +39131,17 @@ rs6000_optab_supported_p (int op, machin
       return true;
     }
 }
+
+/* Implement TARGET_CONSTANT_ALIGNMENT.  */
+
+static HOST_WIDE_INT
+rs6000_constant_alignment (const_tree exp, HOST_WIDE_INT align)
+{
+  if (TREE_CODE (exp) == STRING_CST
+      && (STRICT_ALIGNMENT || !optimize_size))
+    return MAX (align, BITS_PER_WORD);
+  return align;
+}
 
 struct gcc_target targetm = TARGET_INITIALIZER;
 
Index: gcc/config/s390/s390.h
===================================================================
--- gcc/config/s390/s390.h	2017-09-15 14:47:33.178332233 +0100
+++ gcc/config/s390/s390.h	2017-09-22 17:37:26.781614386 +0100
@@ -315,7 +315,6 @@ #define BIGGEST_ALIGNMENT 64
 #define EMPTY_FIELD_BOUNDARY 32
 
 /* Alignment on even addresses for LARL instruction.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
 #define DATA_ABI_ALIGNMENT(TYPE, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
 
 /* Alignment is not required by the hardware.  */
Index: gcc/config/s390/s390.c
===================================================================
--- gcc/config/s390/s390.c	2017-09-21 11:53:16.508848803 +0100
+++ gcc/config/s390/s390.c	2017-09-22 17:37:26.781614386 +0100
@@ -15906,6 +15906,15 @@ s390_vector_alignment (const_tree type)
   return MIN (64, tree_to_shwi (TYPE_SIZE (type)));
 }
 
+/* Implement TARGET_CONSTANT_ALIGNMENT.  Alignment on even addresses for
+   LARL instruction.  */
+
+static HOST_WIDE_INT
+s390_constant_alignment (const_tree, HOST_WIDE_INT align)
+{
+  return MAX (align, 16);
+}
+
 #ifdef HAVE_AS_MACHINE_MACHINEMODE
 /* Implement TARGET_ASM_FILE_START.  */
 static void
@@ -16325,6 +16334,9 @@ #define TARGET_OPTION_RESTORE s390_funct
 #undef TARGET_CAN_CHANGE_MODE_CLASS
 #define TARGET_CAN_CHANGE_MODE_CLASS s390_can_change_mode_class
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT s390_constant_alignment
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-s390.h"
Index: gcc/config/sh/sh.h
===================================================================
--- gcc/config/sh/sh.h	2017-09-15 14:47:33.178332233 +0100
+++ gcc/config/sh/sh.h	2017-09-22 17:37:26.782614386 +0100
@@ -462,12 +462,6 @@ #define BIGGEST_ALIGNMENT  (TARGET_ALIGN
 /* The best alignment to use in cases where we have a choice.  */
 #define FASTEST_ALIGNMENT (32)
 
-/* Make strings word-aligned so strcpy from constants will be faster.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)	\
-  ((TREE_CODE (EXP) == STRING_CST	\
-    && (ALIGN) < FASTEST_ALIGNMENT)	\
-    ? FASTEST_ALIGNMENT : (ALIGN))
-
 /* get_mode_alignment assumes complex values are always held in multiple
    registers, but that is not the case on the SH; CQImode and CHImode are
    held in a single integer register.  */
Index: gcc/config/sh/sh.c
===================================================================
--- gcc/config/sh/sh.c	2017-09-15 13:56:20.288149017 +0100
+++ gcc/config/sh/sh.c	2017-09-22 17:37:26.782614386 +0100
@@ -657,6 +657,9 @@ #define TARGET_MODES_TIEABLE_P sh_modes_
 #undef TARGET_CAN_CHANGE_MODE_CLASS
 #define TARGET_CAN_CHANGE_MODE_CLASS sh_can_change_mode_class
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 
Index: gcc/config/sparc/sparc.h
===================================================================
--- gcc/config/sparc/sparc.h	2017-09-15 14:47:33.178332233 +0100
+++ gcc/config/sparc/sparc.h	2017-09-22 17:37:26.784614385 +0100
@@ -579,12 +579,6 @@ #define MAX_FIXED_MODE_SIZE GET_MODE_BIT
 #define STACK_SAVEAREA_MODE(LEVEL) \
   ((LEVEL) == SAVE_NONLOCAL ? (TARGET_ARCH64 ? TImode : DImode) : Pmode)
 
-/* Make strings word-aligned so strcpy from constants will be faster.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
-  ((TREE_CODE (EXP) == STRING_CST	\
-    && (ALIGN) < FASTEST_ALIGNMENT)	\
-   ? FASTEST_ALIGNMENT : (ALIGN))
-
 /* Make arrays of chars word-aligned for the same reasons.  */
 #define DATA_ALIGNMENT(TYPE, ALIGN)		\
   (TREE_CODE (TYPE) == ARRAY_TYPE		\
Index: gcc/config/sparc/sparc.c
===================================================================
--- gcc/config/sparc/sparc.c	2017-09-21 11:53:16.532263818 +0100
+++ gcc/config/sparc/sparc.c	2017-09-22 17:37:26.784614385 +0100
@@ -684,6 +684,7 @@ static bool sparc_hard_regno_mode_ok (un
 static bool sparc_modes_tieable_p (machine_mode, machine_mode);
 static bool sparc_can_change_mode_class (machine_mode, machine_mode,
 					 reg_class_t);
+static HOST_WIDE_INT sparc_constant_alignment (const_tree, HOST_WIDE_INT);
 
 #ifdef SUBTARGET_ATTRIBUTE_TABLE
 /* Table of valid machine attributes.  */
@@ -925,6 +926,9 @@ #define TARGET_MODES_TIEABLE_P sparc_mod
 #undef TARGET_CAN_CHANGE_MODE_CLASS
 #define TARGET_CAN_CHANGE_MODE_CLASS sparc_can_change_mode_class
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT sparc_constant_alignment
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Return the memory reference contained in X if any, zero otherwise.  */
@@ -13429,4 +13433,14 @@ sparc_can_change_mode_class (machine_mod
   return true;
 }
 
+/* Implement TARGET_CONSTANT_ALIGNMENT.  */
+
+static HOST_WIDE_INT
+sparc_constant_alignment (const_tree exp, HOST_WIDE_INT align)
+{
+  if (TREE_CODE (exp) == STRING_CST)
+    return MAX (align, FASTEST_ALIGNMENT);
+  return align;
+}
+
 #include "gt-sparc.h"
Index: gcc/config/spu/spu.h
===================================================================
--- gcc/config/spu/spu.h	2017-09-15 15:37:22.133931616 +0100
+++ gcc/config/spu/spu.h	2017-09-22 17:37:26.785614385 +0100
@@ -96,7 +96,6 @@ #define MINIMUM_ATOMIC_ALIGNMENT 128
    on the stack.  (Except a bug (?) allows some stack objects to be
    unaligned.)  */
 #define DATA_ALIGNMENT(TYPE,ALIGN) ((ALIGN) > 128 ? (ALIGN) : 128)
-#define CONSTANT_ALIGNMENT(TYPE,ALIGN) ((ALIGN) > 128 ? (ALIGN) : 128)
 #define LOCAL_ALIGNMENT(TYPE,ALIGN) ((ALIGN) > 128 ? (ALIGN) : 128)
 
 #define EMPTY_FIELD_BOUNDARY 32
Index: gcc/config/spu/spu.c
===================================================================
--- gcc/config/spu/spu.c	2017-09-21 22:36:18.178401236 +0100
+++ gcc/config/spu/spu.c	2017-09-22 17:37:26.785614385 +0100
@@ -4159,7 +4159,7 @@ spu_encode_section_info (tree decl, rtx
    which is both 16-byte aligned and padded to a 16-byte boundary.  This
    would make it safe to store with a single instruction. 
    We guarantee the alignment and padding for static objects by aligning
-   all of them to 16-bytes. (DATA_ALIGNMENT and CONSTANT_ALIGNMENT.)
+   all of them to 16-bytes. (DATA_ALIGNMENT and TARGET_CONSTANT_ALIGNMENT.)
    FIXME: We currently cannot guarantee this for objects on the stack
    because assign_parm_setup_stack calls assign_stack_local with the
    alignment of the parameter mode and in that case the alignment never
@@ -7193,6 +7193,18 @@ spu_truly_noop_truncation (unsigned int
 {
   return inprec <= 32 && outprec <= inprec;
 }
+
+/* Implement TARGET_CONSTANT_ALIGNMENT.
+
+   Make all static objects 16-byte aligned.  This allows us to assume
+   they are also padded to 16 bytes, which means we can use a single
+   load or store instruction to access them.  */
+
+static HOST_WIDE_INT
+spu_constant_alignment (const_tree, HOST_WIDE_INT align)
+{
+  return MAX (align, 128);
+}
 
 /*  Table of machine attributes.  */
 static const struct attribute_spec spu_attribute_table[] =
@@ -7433,6 +7445,9 @@ #define TARGET_CAN_CHANGE_MODE_CLASS spu
 #undef TARGET_TRULY_NOOP_TRUNCATION
 #define TARGET_TRULY_NOOP_TRUNCATION spu_truly_noop_truncation
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT spu_constant_alignment
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-spu.h"
Index: gcc/config/stormy16/stormy16.h
===================================================================
--- gcc/config/stormy16/stormy16.h	2017-09-15 14:47:33.179332125 +0100
+++ gcc/config/stormy16/stormy16.h	2017-09-22 17:37:26.785614385 +0100
@@ -87,10 +87,6 @@ #define DATA_ALIGNMENT(TYPE, ALIGN)		\
    && TYPE_MODE (TREE_TYPE (TYPE)) == QImode	\
    && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
 
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
-  (TREE_CODE (EXP) == STRING_CST	\
-   && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
-
 #define STRICT_ALIGNMENT 1
 
 #define PCC_BITFIELD_TYPE_MATTERS 1
Index: gcc/config/stormy16/stormy16.c
===================================================================
--- gcc/config/stormy16/stormy16.c	2017-09-04 11:50:08.540041564 +0100
+++ gcc/config/stormy16/stormy16.c	2017-09-22 17:37:26.785614385 +0100
@@ -2715,6 +2715,9 @@ #define TARGET_HARD_REGNO_MODE_OK xstorm
 #undef TARGET_MODES_TIEABLE_P
 #define TARGET_MODES_TIEABLE_P xstormy16_modes_tieable_p
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-stormy16.h"
Index: gcc/config/tilegx/tilegx.h
===================================================================
--- gcc/config/tilegx/tilegx.h	2017-09-15 14:47:33.180332018 +0100
+++ gcc/config/tilegx/tilegx.h	2017-09-22 17:37:26.786614385 +0100
@@ -94,13 +94,6 @@ #define FASTEST_ALIGNMENT 64
 #define BIGGEST_FIELD_ALIGNMENT 128
 #define WIDEST_HARDWARE_FP_SIZE 64
 
-/* Make strings word-aligned so strcpy from constants will be
-   faster.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
-  ((TREE_CODE (EXP) == STRING_CST	\
-    && (ALIGN) < FASTEST_ALIGNMENT)	\
-   ? FASTEST_ALIGNMENT : (ALIGN))
-
 /* Make arrays of chars word-aligned for the same reasons.  */
 #define DATA_ALIGNMENT(TYPE, ALIGN)		\
   (TREE_CODE (TYPE) == ARRAY_TYPE		\
Index: gcc/config/tilegx/tilegx.c
===================================================================
--- gcc/config/tilegx/tilegx.c	2017-09-15 14:47:33.180332018 +0100
+++ gcc/config/tilegx/tilegx.c	2017-09-22 17:37:26.786614385 +0100
@@ -5734,6 +5734,9 @@ #define TARGET_CAN_USE_DOLOOP_P can_use_
 #undef  TARGET_TRULY_NOOP_TRUNCATION
 #define TARGET_TRULY_NOOP_TRUNCATION tilegx_truly_noop_truncation
 
+#undef  TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-tilegx.h"
Index: gcc/config/tilepro/tilepro.h
===================================================================
--- gcc/config/tilepro/tilepro.h	2017-09-15 14:47:33.180332018 +0100
+++ gcc/config/tilepro/tilepro.h	2017-09-22 17:37:26.787614385 +0100
@@ -58,13 +58,6 @@ #define PCC_BITFIELD_TYPE_MATTERS 1
 #define FASTEST_ALIGNMENT 32
 #define BIGGEST_FIELD_ALIGNMENT 64
 
-/* Make strings word-aligned so strcpy from constants will be
-   faster.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
-  ((TREE_CODE (EXP) == STRING_CST	\
-    && (ALIGN) < FASTEST_ALIGNMENT)	\
-   ? FASTEST_ALIGNMENT : (ALIGN))
-
 /* Make arrays of chars word-aligned for the same reasons.  */
 #define DATA_ALIGNMENT(TYPE, ALIGN)		\
   (TREE_CODE (TYPE) == ARRAY_TYPE		\
Index: gcc/config/tilepro/tilepro.c
===================================================================
--- gcc/config/tilepro/tilepro.c	2017-09-04 08:30:09.354408112 +0100
+++ gcc/config/tilepro/tilepro.c	2017-09-22 17:37:26.786614385 +0100
@@ -5091,6 +5091,9 @@ #define TARGET_ASM_FILE_END tilepro_file
 #undef  TARGET_CAN_USE_DOLOOP_P
 #define TARGET_CAN_USE_DOLOOP_P can_use_doloop_if_innermost
 
+#undef  TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-tilepro.h"
Index: gcc/config/visium/visium.h
===================================================================
--- gcc/config/visium/visium.h	2017-09-15 14:47:33.181331910 +0100
+++ gcc/config/visium/visium.h	2017-09-22 17:37:26.787614385 +0100
@@ -236,16 +236,6 @@ #define BIGGEST_ALIGNMENT 32
    this macro is used instead of that alignment to align the object. */
 #define DATA_ALIGNMENT(TYPE,ALIGN) visium_data_alignment (TYPE, ALIGN)
 
-/* `CONSTANT_ALIGNMENT (CONSTANT, BASIC-ALIGN)`
-
-   If defined, a C expression to compute the alignment given to a
-   constant that is being placed in memory.  CONSTANT is the constant
-   and BASIC-ALIGN is the alignment that the object would ordinarily
-   have.  The value of this macro is used instead of that alignment to
-   align the object. */
-#define CONSTANT_ALIGNMENT(EXP,ALIGN) \
-  visium_data_alignment (TREE_TYPE (EXP), ALIGN)
-
 /* `LOCAL_ALIGNMENT (TYPE, BASIC-ALIGN)`
 
    If defined, a C expression to compute the alignment for a variable
Index: gcc/config/visium/visium.c
===================================================================
--- gcc/config/visium/visium.c	2017-09-15 13:56:20.293149098 +0100
+++ gcc/config/visium/visium.c	2017-09-22 17:37:26.787614385 +0100
@@ -237,6 +237,8 @@ static bool visium_modes_tieable_p (mach
 static bool visium_can_change_mode_class (machine_mode, machine_mode,
 					  reg_class_t);
 
+static HOST_WIDE_INT visium_constant_alignment (const_tree, HOST_WIDE_INT);
+
 /* Setup the global target hooks structure.  */
 
 #undef  TARGET_MAX_ANCHOR_OFFSET
@@ -360,6 +362,9 @@ #define TARGET_MODES_TIEABLE_P visium_mo
 #undef TARGET_CAN_CHANGE_MODE_CLASS
 #define TARGET_CAN_CHANGE_MODE_CLASS visium_can_change_mode_class
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT visium_constant_alignment
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 namespace {
@@ -834,6 +839,14 @@ visium_data_alignment (tree type, unsign
   return align;
 }
 
+/* Implement TARGET_CONSTANT_ALIGNMENT.  */
+
+static HOST_WIDE_INT
+visium_constant_alignment (const_tree exp, HOST_WIDE_INT align)
+{
+  return visium_data_alignment (TREE_TYPE (exp), align);
+}
+
 /* Helper function for HARD_REGNO_RENAME_OK (FROM, TO).  Return non-zero if
    it is OK to rename a hard register FROM to another hard register TO.  */
 
Index: gcc/config/xtensa/xtensa.h
===================================================================
--- gcc/config/xtensa/xtensa.h	2017-09-15 14:47:33.181331910 +0100
+++ gcc/config/xtensa/xtensa.h	2017-09-22 17:37:26.788614385 +0100
@@ -169,17 +169,6 @@ #define PROMOTE_MODE(MODE, UNSIGNEDP, TY
    bitfields and the structures that contain them.  */
 #define PCC_BITFIELD_TYPE_MATTERS 1
 
-/* Align string constants and constructors to at least a word boundary.
-   The typical use of this macro is to increase alignment for string
-   constants to be word aligned so that 'strcpy' calls that copy
-   constants can be done inline.  */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN)					\
-  (!optimize_size &&							\
-   (TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR)	\
-   && (ALIGN) < BITS_PER_WORD						\
-	? BITS_PER_WORD							\
-	: (ALIGN))
-
 /* Align arrays, unions and records to at least a word boundary.
    One use of this macro is to increase alignment of medium-size
    data to make it all fit in fewer cache lines.  Another is to
Index: gcc/config/xtensa/xtensa.c
===================================================================
--- gcc/config/xtensa/xtensa.c	2017-09-12 14:29:25.261529490 +0100
+++ gcc/config/xtensa/xtensa.c	2017-09-22 17:37:26.788614385 +0100
@@ -181,6 +181,7 @@ static void xtensa_conditional_register_
 static unsigned int xtensa_hard_regno_nregs (unsigned int, machine_mode);
 static bool xtensa_hard_regno_mode_ok (unsigned int, machine_mode);
 static bool xtensa_modes_tieable_p (machine_mode, machine_mode);
+static HOST_WIDE_INT xtensa_constant_alignment (const_tree, HOST_WIDE_INT);
 
 
 
@@ -317,6 +318,9 @@ #define TARGET_HARD_REGNO_MODE_OK xtensa
 #undef TARGET_MODES_TIEABLE_P
 #define TARGET_MODES_TIEABLE_P xtensa_modes_tieable_p
 
+#undef TARGET_CONSTANT_ALIGNMENT
+#define TARGET_CONSTANT_ALIGNMENT xtensa_constant_alignment
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 
@@ -4380,4 +4384,19 @@ enum reg_class xtensa_regno_to_class (in
     return regno_to_class[regno];
 }
 
+/* Implement TARGET_CONSTANT_ALIGNMENT.  Align string constants and
+   constructors to at least a word boundary.  The typical use of this
+   macro is to increase alignment for string constants to be word
+   aligned so that 'strcpy' calls that copy constants can be done
+   inline.  */
+
+static HOST_WIDE_INT
+xtensa_constant_alignment (const_tree exp, HOST_WIDE_INT align)
+{
+  if ((TREE_CODE (exp) == STRING_CST || TREE_CODE (exp) == CONSTRUCTOR)
+      && !optimize_size)
+    return MAX (align, BITS_PER_WORD);
+  return align;
+}
+
 #include "gt-xtensa.h"
Index: gcc/system.h
===================================================================
--- gcc/system.h	2017-09-15 15:37:22.136931501 +0100
+++ gcc/system.h	2017-09-22 17:37:26.790614385 +0100
@@ -915,7 +915,7 @@ #define realloc xrealloc
 	MODES_TIEABLE_P FUNCTION_ARG_PADDING SLOW_UNALIGNED_ACCESS	\
 	HARD_REGNO_NREGS SECONDARY_MEMORY_NEEDED_MODE			\
 	SECONDARY_MEMORY_NEEDED CANNOT_CHANGE_MODE_CLASS		\
-	TRULY_NOOP_TRUNCATION FUNCTION_ARG_OFFSET
+	TRULY_NOOP_TRUNCATION FUNCTION_ARG_OFFSET CONSTANT_ALIGNMENT
 
 /* Target macros only used for code built for the target, that have
    moved to libgcc-tm.h or have never been present elsewhere.  */


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