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: pr37868


On Mon, Oct 21, 2013 at 9:39 PM, Mike Stump <mikestump@comcast.net> wrote:
> Concerning:
>
> 2008-11-20  Richard Guenther  <rguenther@suse.de>
>
>         PR tree-optimization/37868
>         * gcc.dg/torture/pr37868.c: New testcase.
>         * gcc.c-torture/execute/pr38048-1.c: Likewise.
>         * gcc.c-torture/execute/pr38048-2.c: Likewise.
>
> So, is there any reason why we can't make the test case portable as in the below instead of skipping on all the targets that blow on misaligned data?
>
> Ok?

Clearly this was an alias analysis fix so adding a union may no longer
trigger the failure mode.  Please make sure to go back in time
where the testcase failed and see if your adjusted testcase fails _in
the same way_.  Note that you don't adjust the dg-skip-if in your
patch and note
that actually there should be no unaligned accesses performed if you
instead do

typedef unsigned int unaligned_uint __attribute__((aligned(1)));
...
     bad_bits = ((unsigned int)-1) ^ *(1+(unaligned_uint *) &x);

but double-check this adjusted testcase still fails without the fix.

Richard.

> diff --git a/gcc/testsuite/gcc.dg/torture/pr37868.c b/gcc/testsuite/gcc.dg/torture/pr37868.c
> index 380b089..b7ff43f 100644
> --- a/gcc/testsuite/gcc.dg/torture/pr37868.c
> +++ b/gcc/testsuite/gcc.dg/torture/pr37868.c
> @@ -24,15 +24,18 @@ struct X {
>
>  int main (void)
>  {
> -  struct X x;
> +  union {
> +    struct X x;
> +    unsigned int i;
> +  } s;
>    unsigned int bad_bits;
>
> -  x.pad = -1;
> -  x.a = -1;
> -  x.b = -1;
> -  x.c = -1;
> +  s.x.pad = -1;
> +  s.x.a = -1;
> +  s.x.b = -1;
> +  s.x.c = -1;
>
> -  bad_bits = ((unsigned int)-1) ^ *(1+(unsigned int *) &x);
> +  bad_bits = ((unsigned int)-1) ^ *(1+(unsigned int *) &s.x);
>    if (bad_bits != 0)
>      abort ();
>    return 0;
>


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