[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#267206: gcc-3.4: vector op code generation regression



Daniel Jacobowitz <dan@debian.org> writes:

> On Sat, Aug 21, 2004 at 12:44:03AM -0500, Matthew Dempsky wrote:
>> No warning, but the generated code seems incorrect (or at least a
>> regression from 3.3) unless ((int *)&val)[x] isn't the correct
>> portable way to access a vector element, but there doesn't seem to be
>> an alternative that I've been able to deduce (and the documentation
>> doesn't list any).
>
> It isn't correct.  Use a union; you're violating the strict-aliasing
> rules.

Alright, I tried changing print_v4si to this (rest of the code the
same):

    static void
    print_v4si (const char * name, v4si val)
    {
      union foo
      {
        v4si vector;
        int array[4];
      } l;
      int x;
    
      l.vector = val;
    
      printf ("%s:\n", name);
      for (x = 0; x < 4; ++x)
        printf ("  vals[%d] = %d\n", x, l.array[x]);
      printf ("\n");
    }

And it still generates bogus values for the third and fourth vector
elements.  I also just noticed that compiling with -march=athlon-xp
causes all of the values to be zero.

Or did I still not get the strict aliasing rules right?
(-Wstrict-aliasing doesn't seem to generate a warning with either old
or new code either.)



Reply to: