From patchwork Mon Sep 20 23:45:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 4.4/4.5 PATCH: PR middle-end/45678: [4.4/4.5/4.6 Regression] crash on vector code with -m32 -msse Date: Mon, 20 Sep 2010 13:45:07 -0000 From: "H.J. Lu" X-Patchwork-Id: 65269 Message-Id: To: Richard Henderson , Richard Guenther Cc: Jakub Jelinek , gcc-patches@gcc.gnu.org Here is the patch for 4.4/4.5. fold_builtin_memory_op is very different in 4.4/4.5. Simple backport doesn't work. Does this patch make any senses? Thanks. diff --git a/gcc/builtins.c b/gcc/builtins.c index 08a5578..fb777d5 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -8327,6 +8327,7 @@ fold_builtin_memory_op (location_t loc, tree dest, tree src, src_align = get_pointer_alignment (src, BIGGEST_ALIGNMENT); dest_align = get_pointer_alignment (dest, BIGGEST_ALIGNMENT); if (dest_align < (int) TYPE_ALIGN (desttype) + || src_align < (int) TYPE_ALIGN (desttype) || src_align < (int) TYPE_ALIGN (srctype)) return NULL_TREE; diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 4e44cdb..69c3f5f 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -705,7 +705,7 @@ static void expand_one_stack_var_at (tree decl, HOST_WIDE_INT offset) { /* Alignment is unsigned. */ - unsigned HOST_WIDE_INT align; + unsigned HOST_WIDE_INT align, max_align; rtx x; /* If this fails, we've overflowed the stack frame. Error nicely? */ @@ -722,10 +722,9 @@ expand_one_stack_var_at (tree decl, HOST_WIDE_INT offset) offset -= frame_phase; align = offset & -offset; align *= BITS_PER_UNIT; - if (align == 0) - align = STACK_BOUNDARY; - else if (align > MAX_SUPPORTED_STACK_ALIGNMENT) - align = MAX_SUPPORTED_STACK_ALIGNMENT; + max_align = crtl->max_used_stack_slot_alignment; + if (align == 0 || align > max_align) + align = max_align; DECL_ALIGN (decl) = align; DECL_USER_ALIGN (decl) = 0; --- /dev/null 2010-09-09 09:16:30.485584932 -0700 +++ gcc-release/gcc/testsuite/gcc.dg/torture/pr45678-1.c 2010-09-20 09:11:36.000000000 -0700 @@ -0,0 +1,16 @@ +/* { dg-do run } */ + +typedef float V __attribute__ ((vector_size (16))); +V g; +float d[4] = { 4, 3, 2, 1 }; + +int +main () +{ + V e; + __builtin_memcpy (&e, &d, sizeof (d)); + V f = { 5, 15, 25, 35 }; + e = e * f; + g = e; + return 0; +} --- /dev/null 2010-09-09 09:16:30.485584932 -0700 +++ gcc-release/gcc/testsuite/gcc.dg/torture/pr45678-2.c 2010-09-20 09:11:36.000000000 -0700 @@ -0,0 +1,16 @@ +/* { dg-do run } */ + +typedef float V __attribute__ ((vector_size (16))); +V g; + +int +main () +{ + float d[4] = { 4, 3, 2, 1 }; + V e; + __builtin_memcpy (&e, &d, sizeof (d)); + V f = { 5, 15, 25, 35 }; + e = e * f; + g = e; + return 0; +}