https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92768

            Bug ID: 92768
           Summary: Maybe a wrong code for vector constants
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
  Target Milestone: ---

I have a test-case from graphene package that started to fail with r273194:

$ cat matrix.c
#include <xmmintrin.h>

#define GRAPHENE_ALIGN16  __attribute__((aligned(16)))

typedef int v4si __attribute__((vector_size(16)));
typedef float v4sf __attribute__((vector_size(16)));

typedef __m128 graphene_simd4f_t;
typedef struct {
  int f[4];
} graphene_simd4f_uif_t;

__m128
graphene_simd4x4f_inverse(__m128 r1_sum)
{
  const graphene_simd4f_uif_t __pnpn = { {0x00000000, 0x80000000, 0x00000000,
0x80000000}};
  return (graphene_simd4f_t) _mm_xor_ps((r1_sum), _mm_load_ps(__pnpn.f));
}

int main()
{
  __m128 a = { -1.0f, -1.0f, -1.0f, -1.0f };
  if (graphene_simd4x4f_inverse (a)[1] != 1.0)
    __builtin_abort ();

  return 0;
}

$ gcc -O2 matrix.c -ffast-math && ./a.out 
matrix.c: In function ‘graphene_simd4x4f_inverse’:
matrix.c:17:69: warning: passing argument 1 of ‘_mm_load_ps’ from incompatible
pointer type [-Wincompatible-pointer-types]
   17 |   return (graphene_simd4f_t) _mm_xor_ps((r1_sum),
_mm_load_ps(__pnpn.f));
      |                                                               ~~~~~~^~
      |                                                                     |
      |                                                                    
const int *
In file included from matrix.c:1:
/home/marxin/bin/gcc2/lib64/gcc/x86_64-pc-linux-gnu/10.0.0/include/xmmintrin.h:925:27:
note: expected ‘const float *’ but argument is of type ‘const int *’
  925 | _mm_load_ps (float const *__P)
      |              ~~~~~~~~~~~~~^~~
Aborted (core dumped)

But without -ffast-math it's fine:

$ gcc -O2 matrix.c  && ./a.out 
matrix.c: In function ‘graphene_simd4x4f_inverse’:
matrix.c:17:69: warning: passing argument 1 of ‘_mm_load_ps’ from incompatible
pointer type [-Wincompatible-pointer-types]
   17 |   return (graphene_simd4f_t) _mm_xor_ps((r1_sum),
_mm_load_ps(__pnpn.f));
      |                                                               ~~~~~~^~
      |                                                                     |
      |                                                                    
const int *
In file included from matrix.c:1:
/home/marxin/bin/gcc2/lib64/gcc/x86_64-pc-linux-gnu/10.0.0/include/xmmintrin.h:925:27:
note: expected ‘const float *’ but argument is of type ‘const int *’
  925 | _mm_load_ps (float const *__P)
      |              ~~~~~~~~~~~~~^~~

Reply via email to