From 0f510c9a06acc854f80a606f34c8f2b6bc8ef237 Mon Sep 17 00:00:00 2001 From: pinskia Date: Sun, 31 Aug 2008 02:40:13 +0000 Subject: [PATCH] #define vector __attribute__((vector_size(16) )) struct struct1 { union { float a[3]; } vmx; struct struct2 { struct2(const struct2& r) {} } w; } __attribute__((aligned(16))); struct struct3 { vector float vmx; operator const struct1& () const{ return *reinterpret_cast(this); } }; struct3 func3( struct3 V1); struct3 func2( void ); void func1( ) { struct1 vVec = func2() ; func3 ( (struct3&)vVec ); } git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139820 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/expmed.c | 2 +- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/torture/pr36444.C | 21 +++++++++++++++++++++ gcc/testsuite/gcc.c-torture/compile/vector-4.c | 10 ++++++++++ 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr36444.C create mode 100644 gcc/testsuite/gcc.c-torture/compile/vector-4.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5b5c833..9d386fc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-08-30 Andrew Pinski + + PR middle-end/36444 + * expmed.c (extract_bit_field_1): Check the mode size to make + sure the vector modes have the same size. + 2008-08-29 Michael Meissner * dojump.c (top level): Include basic-block.h to declare diff --git a/gcc/expmed.c b/gcc/expmed.c index 399139b..83a8760 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -1204,7 +1204,7 @@ extract_bit_field_1 (rtx str_rtx, unsigned HOST_WIDE_INT bitsize, for (; new_mode != VOIDmode ; new_mode = GET_MODE_WIDER_MODE (new_mode)) if (GET_MODE_NUNITS (new_mode) == nunits - && GET_MODE_INNER (new_mode) == tmode + && GET_MODE_SIZE (new_mode) == GET_MODE_SIZE (GET_MODE (op0)) && targetm.vector_mode_supported_p (new_mode)) break; if (new_mode != VOIDmode) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5f940c1..405e0f3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-08-30 Andrew Pinski + + PR middle-end/36444 + * g++.dg/torture/pr36444.C: New testcase. + * gcc.c-torture/compile/vector-4.c: New testcase. + 2008-08-30 Jerry DeLisle PR libfortran/36895 diff --git a/gcc/testsuite/g++.dg/torture/pr36444.C b/gcc/testsuite/g++.dg/torture/pr36444.C new file mode 100644 index 0000000..fd20bde --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr36444.C @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +#define vector __attribute__((vector_size(16) )) +struct struct1 { + union {} vmx; + struct struct2 { + struct2(const struct2& r) {} + } w; +} __attribute__((aligned(16))); +struct struct3 { + vector float vmx; + operator const struct1& () const{ + return *reinterpret_cast(this); + } +}; +struct3 func3( struct3 V1); +struct3 func2( void ); +void func1( ) { + struct1 vVec = func2() ; + func3 ( (struct3&)vVec ); +} + diff --git a/gcc/testsuite/gcc.c-torture/compile/vector-4.c b/gcc/testsuite/gcc.c-torture/compile/vector-4.c new file mode 100644 index 0000000..b0d8e81 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/vector-4.c @@ -0,0 +1,10 @@ +/* Make sure that vector of size 8 of signed char works. This used to crash with AVX on x86 + as we would produce try to extract the chars inside the vector mode using the vector mode of V8SI + which was wrong. */ +__attribute__ ((vector_size (8))) signed char v4, v5, v6; +void +two (void) +{ + v4 = v5 + v6; +} + -- 2.7.4