[v2] testsuite: Add new target check for no_alignment_constraints

Message ID 20220627180907.321403-1-dimitar@dinux.eu
State Committed
Commit 5745301983191f5a6fea9d05e36643e339dd2b52
Headers
Series [v2] testsuite: Add new target check for no_alignment_constraints |

Commit Message

Dimitar Dimitrov June 27, 2022, 6:09 p.m. UTC
  A few testcases were marked for avr target, which has no alignment
requirements.  But those tests in fact should filter for any
target having __BIGGEST_ALIGNMENT__=1.

A new effective target check is introduced: no_alignment_constraints.
It checks whether __BIGGEST_ALIGNMENT__ is declared as 1.

This change fixes the testsuite cases for PRU target.  I don't have
environment to test mm32c and cris targets, which also declare
__BIGGEST_ALIGNMENT__=1.

It was regression-tested on x86_64-pc-linux-gnu.

The following two existing macros were considered, but they check for
subtly different target behaviour:
 1. non_strict_align
    If true, non-aligned access is permitted. But it also allows
    variables to be naturally aligned, which is not true for
    no_alignment_constraints.

 2. default_packed
    Whether structures are packed by default is not necessarily
    the same as lacking constraints for non-aggregate types.
    For example, BIGGEST_FIELD_ALIGNMENT or ADJUST_FIELD_ALIGN
    could be defined for a target as something other than
    BIGGEST_ALIGNMENT.

gcc/ChangeLog:

	* doc/sourcebuild.texi: Document new no_alignment_constraints
	effective target check.

gcc/testsuite/ChangeLog:

	* c-c++-common/Wcast-align.c: Silence warnings for targets with
	no_alignment_constraints.
	* gcc.dg/c11-align-4.c: Skip for no_alignment_constraints.
	* gcc.dg/strlenopt-10.c: Replace checks for avr with checks for
	any target with no_alignment_constraints.
	* gcc.dg/strlenopt-11.c: Ditto.
	* gcc.dg/strlenopt-13.c: Ditto.
	* lib/target-supports.exp
	(check_effective_target_no_alignment_constraints): New.


Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
---
Changes since patch V1:
  - Documented the new check in gcc/doc/sourcebuild.texi.

 gcc/doc/sourcebuild.texi                 |  9 +++++++++
 gcc/testsuite/c-c++-common/Wcast-align.c |  4 ++--
 gcc/testsuite/gcc.dg/c11-align-4.c       |  2 +-
 gcc/testsuite/gcc.dg/strlenopt-10.c      |  6 +++---
 gcc/testsuite/gcc.dg/strlenopt-11.c      | 14 +++++++-------
 gcc/testsuite/gcc.dg/strlenopt-13.c      | 16 ++++++++--------
 gcc/testsuite/lib/target-supports.exp    | 13 +++++++++++++
 7 files changed, 43 insertions(+), 21 deletions(-)
  

Comments

Richard Biener June 28, 2022, 7:33 a.m. UTC | #1
On Mon, Jun 27, 2022 at 8:09 PM Dimitar Dimitrov <dimitar@dinux.eu> wrote:
>
> A few testcases were marked for avr target, which has no alignment
> requirements.  But those tests in fact should filter for any
> target having __BIGGEST_ALIGNMENT__=1.
>
> A new effective target check is introduced: no_alignment_constraints.
> It checks whether __BIGGEST_ALIGNMENT__ is declared as 1.
>
> This change fixes the testsuite cases for PRU target.  I don't have
> environment to test mm32c and cris targets, which also declare
> __BIGGEST_ALIGNMENT__=1.
>
> It was regression-tested on x86_64-pc-linux-gnu.
>
> The following two existing macros were considered, but they check for
> subtly different target behaviour:
>  1. non_strict_align
>     If true, non-aligned access is permitted. But it also allows
>     variables to be naturally aligned, which is not true for
>     no_alignment_constraints.
>
>  2. default_packed
>     Whether structures are packed by default is not necessarily
>     the same as lacking constraints for non-aggregate types.
>     For example, BIGGEST_FIELD_ALIGNMENT or ADJUST_FIELD_ALIGN
>     could be defined for a target as something other than
>     BIGGEST_ALIGNMENT.

OK.

Thanks,
Richard.

> gcc/ChangeLog:
>
>         * doc/sourcebuild.texi: Document new no_alignment_constraints
>         effective target check.
>
> gcc/testsuite/ChangeLog:
>
>         * c-c++-common/Wcast-align.c: Silence warnings for targets with
>         no_alignment_constraints.
>         * gcc.dg/c11-align-4.c: Skip for no_alignment_constraints.
>         * gcc.dg/strlenopt-10.c: Replace checks for avr with checks for
>         any target with no_alignment_constraints.
>         * gcc.dg/strlenopt-11.c: Ditto.
>         * gcc.dg/strlenopt-13.c: Ditto.
>         * lib/target-supports.exp
>         (check_effective_target_no_alignment_constraints): New.
>
>
> Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
> ---
> Changes since patch V1:
>   - Documented the new check in gcc/doc/sourcebuild.texi.
>
>  gcc/doc/sourcebuild.texi                 |  9 +++++++++
>  gcc/testsuite/c-c++-common/Wcast-align.c |  4 ++--
>  gcc/testsuite/gcc.dg/c11-align-4.c       |  2 +-
>  gcc/testsuite/gcc.dg/strlenopt-10.c      |  6 +++---
>  gcc/testsuite/gcc.dg/strlenopt-11.c      | 14 +++++++-------
>  gcc/testsuite/gcc.dg/strlenopt-13.c      | 16 ++++++++--------
>  gcc/testsuite/lib/target-supports.exp    | 13 +++++++++++++
>  7 files changed, 43 insertions(+), 21 deletions(-)
>
> diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
> index 3696a58fbf2..760ff9559a6 100644
> --- a/gcc/doc/sourcebuild.texi
> +++ b/gcc/doc/sourcebuild.texi
> @@ -2716,6 +2716,7 @@ Target supports @option{-branch-cost=N}.
>  Target uses @code{__cxa_atexit}.
>
>  @item default_packed
> +@anchor{default_packed}
>  Target has packed layout of structure members by default.
>
>  @item exceptions
> @@ -2786,6 +2787,14 @@ Target uses natural alignment (aligned to type size) for types of
>  Target uses natural alignment (aligned to type size) for types of
>  64 bits or less.
>
> +@item no_alignment_constraints
> +Target defines __BIGGEST_ALIGNMENT__=1.  Hence target imposes
> +no alignment constraints.  This is similar, but not necessarily
> +the same as @ref{default_packed}.  Although @code{BIGGEST_FIELD_ALIGNMENT}
> +defaults to @code{BIGGEST_ALIGNMENT} for most targets, it is possible
> +for a target to set those two with different values and have different
> +alignment constraints for aggregate and non-aggregate types.
> +
>  @item noinit
>  Target supports the @code{noinit} variable attribute.
>
> diff --git a/gcc/testsuite/c-c++-common/Wcast-align.c b/gcc/testsuite/c-c++-common/Wcast-align.c
> index c296c7fd249..1087b10fd99 100644
> --- a/gcc/testsuite/c-c++-common/Wcast-align.c
> +++ b/gcc/testsuite/c-c++-common/Wcast-align.c
> @@ -16,8 +16,8 @@ struct t { double x; } *q;
>  void
>  foo (void)
>  {
> -  y = (c *) x;  /* { dg-warning "7:cast \[^\n\r]* required alignment of target type" } */
> -  z = (d *) x;  /* { dg-warning "7:cast \[^\n\r]* required alignment of target type" } */
> +  y = (c *) x;  /* { dg-warning "7:cast \[^\n\r]* required alignment of target type" "" { target { ! no_alignment_constraints } } } */
> +  z = (d *) x;  /* { dg-warning "7:cast \[^\n\r]* required alignment of target type" "" { target { ! no_alignment_constraints } } } */
>    (long long *) p;  /* { dg-bogus "alignment" } */
>    (double *) q;     /* { dg-bogus "alignment" } */
>  }
> diff --git a/gcc/testsuite/gcc.dg/c11-align-4.c b/gcc/testsuite/gcc.dg/c11-align-4.c
> index 57f93ff05fc..eb9071b9149 100644
> --- a/gcc/testsuite/gcc.dg/c11-align-4.c
> +++ b/gcc/testsuite/gcc.dg/c11-align-4.c
> @@ -2,7 +2,7 @@
>     are at least some alignment constraints).  */
>  /* { dg-do compile } */
>  /* { dg-options "-std=c11 -pedantic-errors" } */
> -/* { dg-skip-if "no alignment constraints" { "avr-*-*" } } */
> +/* { dg-skip-if "no alignment constraints" { no_alignment_constraints } } */
>
>  #include <stddef.h>
>
> diff --git a/gcc/testsuite/gcc.dg/strlenopt-10.c b/gcc/testsuite/gcc.dg/strlenopt-10.c
> index ce959c34a80..6e2c2597b27 100644
> --- a/gcc/testsuite/gcc.dg/strlenopt-10.c
> +++ b/gcc/testsuite/gcc.dg/strlenopt-10.c
> @@ -70,10 +70,10 @@ main ()
>  }
>
>  /* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */
> -/* avr has BIGGEST_ALIGNMENT 8, allowing fold_builtin_memory_op
> +/* Some targets have BIGGEST_ALIGNMENT 8-bits, allowing fold_builtin_memory_op
>     to expand the memcpy call at the end of fn2.  */
> -/* { dg-final { scan-tree-dump-times "memcpy \\(" 8 "strlen1" { target { ! avr-*-* } } } } */
> -/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" { target { avr-*-* } } } } */
> +/* { dg-final { scan-tree-dump-times "memcpy \\(" 8 "strlen1" { target { ! no_alignment_constraints } } } } */
> +/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" { target { no_alignment_constraints} } } } */
>  /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */
>  /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */
>  /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */
> diff --git a/gcc/testsuite/gcc.dg/strlenopt-11.c b/gcc/testsuite/gcc.dg/strlenopt-11.c
> index abd9faebed6..952de0730f1 100644
> --- a/gcc/testsuite/gcc.dg/strlenopt-11.c
> +++ b/gcc/testsuite/gcc.dg/strlenopt-11.c
> @@ -59,17 +59,17 @@ main ()
>  }
>
>  /* { dg-final { scan-tree-dump-times "strlen \\(" 3 "strlen1" } } */
> -/* avr has BIGGEST_ALIGNMENT 8, allowing fold_builtin_memory_op
> +/* Some targets have BIGGEST_ALIGNMENT 8-bits, allowing fold_builtin_memory_op
>     to expand the memcpy call at the end of fn1.  */
> -/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" { target { ! avr-*-* } } } } */
> -/* { dg-final { scan-tree-dump-times "memcpy \\(" 6 "strlen1" { target { avr-*-* } } } } */
> +/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" { target { ! no_alignment_constraints } } } } */
> +/* { dg-final { scan-tree-dump-times "memcpy \\(" 6 "strlen1" { target { no_alignment_constraints } } } } */
>  /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */
>  /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */
>  /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */
>  /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */
>  /* Where the memcpy is expanded, the assignemts to elements of l are
>     propagated.  */
> -/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.0. = " 1 "strlen1" { target { ! avr-*-* } } } } */
> -/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.6. = " 1 "strlen1" { target { ! avr-*-* } } } } */
> -/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.9. = " 1 "strlen1" { target { ! avr-*-* } } } } */
> -/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;" 3 "strlen1" { target { avr-*-* } } } } */
> +/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.0. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */
> +/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.6. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */
> +/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.9. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */
> +/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;" 3 "strlen1" { target { no_alignment_constraints } } } } */
> diff --git a/gcc/testsuite/gcc.dg/strlenopt-13.c b/gcc/testsuite/gcc.dg/strlenopt-13.c
> index 27ecc79c2d9..4c6d5266780 100644
> --- a/gcc/testsuite/gcc.dg/strlenopt-13.c
> +++ b/gcc/testsuite/gcc.dg/strlenopt-13.c
> @@ -56,18 +56,18 @@ main ()
>  }
>
>  /* { dg-final { scan-tree-dump-times "strlen \\(" 4 "strlen1" } } */
> -/* avr has BIGGEST_ALIGNMENT 8, allowing fold_builtin_memory_op
> +/* Some targets have BIGGEST_ALIGNMENT 8-bits, allowing fold_builtin_memory_op
>     to expand the memcpy call at the end of fn1.  */
> -/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" { target { ! avr-*-* } } } } */
> -/* { dg-final { scan-tree-dump-times "memcpy \\(" 6 "strlen1" { target { avr-*-* } } } } */
> +/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" { target { ! no_alignment_constraints } } } } */
> +/* { dg-final { scan-tree-dump-times "memcpy \\(" 6 "strlen1" { target { no_alignment_constraints } } } } */
>  /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */
>  /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */
>  /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */
>  /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */
>  /* Where the memcpy is expanded, the assignemts to elements of l are
>     propagated.  */
> -/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.0. = " 1 "strlen1" { target { ! avr-*-* } } } } */
> -/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.1. = " 1 "strlen1" { target { ! avr-*-* } } } } */
> -/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.5. = " 1 "strlen1" { target { ! avr-*-* } } } } */
> -/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.6. = " 1 "strlen1" { target { ! avr-*-* } } } } */
> -/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;" 4 "strlen1" { target { avr-*-* } } } } */
> +/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.0. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */
> +/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.1. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */
> +/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.5. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */
> +/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.6. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */
> +/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;" 4 "strlen1" { target { no_alignment_constraints } } } } */
> diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
> index e481a2a71ff..48c5dda6a12 100644
> --- a/gcc/testsuite/lib/target-supports.exp
> +++ b/gcc/testsuite/lib/target-supports.exp
> @@ -7549,6 +7549,19 @@ proc check_effective_target_vect_aligned_arrays { } {
>      return $et_vect_aligned_arrays
>  }
>
> +# Return 1 if the biggest alignment required by target is 1 * BITS_PER_UNIT.
> +# In such case the target does not impose any alignment constraints.
> +
> +proc check_effective_target_no_alignment_constraints { } {
> +    return [check_runtime_nocache no_alignment_constraints {
> +        int
> +        main (void)
> +        {
> +          return __BIGGEST_ALIGNMENT__ == 1 ? 0 : 1;
> +        }
> +    }]
> +}
> +
>  # Return 1 if types of size 32 bit or less are naturally aligned
>  # (aligned to their type-size), 0 otherwise.
>  #
> --
> 2.36.1
>
  

Patch

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 3696a58fbf2..760ff9559a6 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2716,6 +2716,7 @@  Target supports @option{-branch-cost=N}.
 Target uses @code{__cxa_atexit}.
 
 @item default_packed
+@anchor{default_packed}
 Target has packed layout of structure members by default.
 
 @item exceptions
@@ -2786,6 +2787,14 @@  Target uses natural alignment (aligned to type size) for types of
 Target uses natural alignment (aligned to type size) for types of
 64 bits or less.
 
+@item no_alignment_constraints
+Target defines __BIGGEST_ALIGNMENT__=1.  Hence target imposes
+no alignment constraints.  This is similar, but not necessarily
+the same as @ref{default_packed}.  Although @code{BIGGEST_FIELD_ALIGNMENT}
+defaults to @code{BIGGEST_ALIGNMENT} for most targets, it is possible
+for a target to set those two with different values and have different
+alignment constraints for aggregate and non-aggregate types.
+
 @item noinit
 Target supports the @code{noinit} variable attribute.
 
diff --git a/gcc/testsuite/c-c++-common/Wcast-align.c b/gcc/testsuite/c-c++-common/Wcast-align.c
index c296c7fd249..1087b10fd99 100644
--- a/gcc/testsuite/c-c++-common/Wcast-align.c
+++ b/gcc/testsuite/c-c++-common/Wcast-align.c
@@ -16,8 +16,8 @@  struct t { double x; } *q;
 void
 foo (void)
 {
-  y = (c *) x;  /* { dg-warning "7:cast \[^\n\r]* required alignment of target type" } */
-  z = (d *) x;  /* { dg-warning "7:cast \[^\n\r]* required alignment of target type" } */
+  y = (c *) x;  /* { dg-warning "7:cast \[^\n\r]* required alignment of target type" "" { target { ! no_alignment_constraints } } } */
+  z = (d *) x;  /* { dg-warning "7:cast \[^\n\r]* required alignment of target type" "" { target { ! no_alignment_constraints } } } */
   (long long *) p;  /* { dg-bogus "alignment" } */
   (double *) q;     /* { dg-bogus "alignment" } */
 }
diff --git a/gcc/testsuite/gcc.dg/c11-align-4.c b/gcc/testsuite/gcc.dg/c11-align-4.c
index 57f93ff05fc..eb9071b9149 100644
--- a/gcc/testsuite/gcc.dg/c11-align-4.c
+++ b/gcc/testsuite/gcc.dg/c11-align-4.c
@@ -2,7 +2,7 @@ 
    are at least some alignment constraints).  */
 /* { dg-do compile } */
 /* { dg-options "-std=c11 -pedantic-errors" } */
-/* { dg-skip-if "no alignment constraints" { "avr-*-*" } } */
+/* { dg-skip-if "no alignment constraints" { no_alignment_constraints } } */
 
 #include <stddef.h>
 
diff --git a/gcc/testsuite/gcc.dg/strlenopt-10.c b/gcc/testsuite/gcc.dg/strlenopt-10.c
index ce959c34a80..6e2c2597b27 100644
--- a/gcc/testsuite/gcc.dg/strlenopt-10.c
+++ b/gcc/testsuite/gcc.dg/strlenopt-10.c
@@ -70,10 +70,10 @@  main ()
 }
 
 /* { dg-final { scan-tree-dump-times "strlen \\(" 2 "strlen1" } } */
-/* avr has BIGGEST_ALIGNMENT 8, allowing fold_builtin_memory_op
+/* Some targets have BIGGEST_ALIGNMENT 8-bits, allowing fold_builtin_memory_op
    to expand the memcpy call at the end of fn2.  */
-/* { dg-final { scan-tree-dump-times "memcpy \\(" 8 "strlen1" { target { ! avr-*-* } } } } */
-/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" { target { avr-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "memcpy \\(" 8 "strlen1" { target { ! no_alignment_constraints } } } } */
+/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" { target { no_alignment_constraints} } } } */
 /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */
 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */
 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */
diff --git a/gcc/testsuite/gcc.dg/strlenopt-11.c b/gcc/testsuite/gcc.dg/strlenopt-11.c
index abd9faebed6..952de0730f1 100644
--- a/gcc/testsuite/gcc.dg/strlenopt-11.c
+++ b/gcc/testsuite/gcc.dg/strlenopt-11.c
@@ -59,17 +59,17 @@  main ()
 }
 
 /* { dg-final { scan-tree-dump-times "strlen \\(" 3 "strlen1" } } */
-/* avr has BIGGEST_ALIGNMENT 8, allowing fold_builtin_memory_op
+/* Some targets have BIGGEST_ALIGNMENT 8-bits, allowing fold_builtin_memory_op
    to expand the memcpy call at the end of fn1.  */
-/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" { target { ! avr-*-* } } } } */
-/* { dg-final { scan-tree-dump-times "memcpy \\(" 6 "strlen1" { target { avr-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" { target { ! no_alignment_constraints } } } } */
+/* { dg-final { scan-tree-dump-times "memcpy \\(" 6 "strlen1" { target { no_alignment_constraints } } } } */
 /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */
 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */
 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */
 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */
 /* Where the memcpy is expanded, the assignemts to elements of l are
    propagated.  */
-/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.0. = " 1 "strlen1" { target { ! avr-*-* } } } } */
-/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.6. = " 1 "strlen1" { target { ! avr-*-* } } } } */
-/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.9. = " 1 "strlen1" { target { ! avr-*-* } } } } */
-/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;" 3 "strlen1" { target { avr-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.0. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */
+/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.6. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */
+/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.9. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */
+/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;" 3 "strlen1" { target { no_alignment_constraints } } } } */
diff --git a/gcc/testsuite/gcc.dg/strlenopt-13.c b/gcc/testsuite/gcc.dg/strlenopt-13.c
index 27ecc79c2d9..4c6d5266780 100644
--- a/gcc/testsuite/gcc.dg/strlenopt-13.c
+++ b/gcc/testsuite/gcc.dg/strlenopt-13.c
@@ -56,18 +56,18 @@  main ()
 }
 
 /* { dg-final { scan-tree-dump-times "strlen \\(" 4 "strlen1" } } */
-/* avr has BIGGEST_ALIGNMENT 8, allowing fold_builtin_memory_op
+/* Some targets have BIGGEST_ALIGNMENT 8-bits, allowing fold_builtin_memory_op
    to expand the memcpy call at the end of fn1.  */
-/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" { target { ! avr-*-* } } } } */
-/* { dg-final { scan-tree-dump-times "memcpy \\(" 6 "strlen1" { target { avr-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "memcpy \\(" 7 "strlen1" { target { ! no_alignment_constraints } } } } */
+/* { dg-final { scan-tree-dump-times "memcpy \\(" 6 "strlen1" { target { no_alignment_constraints } } } } */
 /* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen1" } } */
 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen1" } } */
 /* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen1" } } */
 /* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen1" } } */
 /* Where the memcpy is expanded, the assignemts to elements of l are
    propagated.  */
-/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.0. = " 1 "strlen1" { target { ! avr-*-* } } } } */
-/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.1. = " 1 "strlen1" { target { ! avr-*-* } } } } */
-/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.5. = " 1 "strlen1" { target { ! avr-*-* } } } } */
-/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.6. = " 1 "strlen1" { target { ! avr-*-* } } } } */
-/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;" 4 "strlen1" { target { avr-*-* } } } } */
+/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.0. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */
+/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.1. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */
+/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.5. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */
+/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;\[\n\r\]*  l.6. = " 1 "strlen1" { target { ! no_alignment_constraints } } } } */
+/* { dg-final { scan-tree-dump-times "  _\[0-9\]* = strlen \\(\[^\n\r\]*;" 4 "strlen1" { target { no_alignment_constraints } } } } */
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index e481a2a71ff..48c5dda6a12 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -7549,6 +7549,19 @@  proc check_effective_target_vect_aligned_arrays { } {
     return $et_vect_aligned_arrays
 }
 
+# Return 1 if the biggest alignment required by target is 1 * BITS_PER_UNIT.
+# In such case the target does not impose any alignment constraints.
+
+proc check_effective_target_no_alignment_constraints { } {
+    return [check_runtime_nocache no_alignment_constraints {
+        int
+        main (void)
+        {
+          return __BIGGEST_ALIGNMENT__ == 1 ? 0 : 1;
+        }
+    }]
+}
+
 # Return 1 if types of size 32 bit or less are naturally aligned
 # (aligned to their type-size), 0 otherwise.
 #