From: Richard Biener Date: Tue, 26 Jul 2016 14:11:21 +0000 (+0000) Subject: re PR rtl-optimization/71984 (wrong code with -O -mavx512cd) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0b64ca40f30eefc43dcfebaaf918a48e1c3b3dcc;p=gcc.git re PR rtl-optimization/71984 (wrong code with -O -mavx512cd) 2016-07-26 Richard Biener PR rtl-optimization/71984 * simplify-rtx.c (simplify_subreg): Use GET_MODE_SIZE and prepare for VOIDmode. * gcc.dg/torture/pr71984.c: New testcase. From-SVN: r238757 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dff649d5679..6c9a3b668e6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-07-26 Richard Biener + + PR rtl-optimization/71984 + * simplify-rtx.c (simplify_subreg): Use GET_MODE_SIZE and prepare + for VOIDmode. + 2016-07-26 Richard Biener PR middle-end/72517 diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index c34f2f55623..691c2c1b678 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -6116,7 +6116,10 @@ simplify_subreg (machine_mode outermode, rtx op, unsigned int part_size, final_offset; rtx part, res; - part_size = GET_MODE_UNIT_SIZE (GET_MODE (XEXP (op, 0))); + enum machine_mode part_mode = GET_MODE (XEXP (op, 0)); + if (part_mode == VOIDmode) + part_mode = GET_MODE_INNER (GET_MODE (op)); + part_size = GET_MODE_SIZE (part_mode); if (byte < part_size) { part = XEXP (op, 0); @@ -6131,7 +6134,7 @@ simplify_subreg (machine_mode outermode, rtx op, if (final_offset + GET_MODE_SIZE (outermode) > part_size) return NULL_RTX; - enum machine_mode part_mode = GET_MODE (part); + part_mode = GET_MODE (part); if (part_mode == VOIDmode) part_mode = GET_MODE_INNER (GET_MODE (op)); res = simplify_subreg (outermode, part, part_mode, final_offset); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5307adfcb97..71d0d84f8cd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-07-26 Richard Biener + + PR rtl-optimization/71984 + * gcc.dg/torture/pr71984.c: New testcase. + 2016-07-26 Robert Suchanek * g++.dg/vect/vect.exp: Add and set new global EFFECTIVE_TARGETS. Call diff --git a/gcc/testsuite/gcc.dg/torture/pr71984.c b/gcc/testsuite/gcc.dg/torture/pr71984.c new file mode 100644 index 00000000000..e1dd04bc568 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr71984.c @@ -0,0 +1,21 @@ +/* { dg-do run { target lp64 } } */ +/* { dg-additional-options "-w -Wno-psabi" } */ + +typedef unsigned char v64u8 __attribute__((vector_size(64))); +typedef unsigned long v64u64 __attribute__((vector_size(64))); +typedef unsigned char u8; + +static u8 __attribute__ ((noinline, noclone)) +foo (v64u64 v64u64_0) +{ + return ((v64u8)(v64u64){0, v64u64_0[0]})[13]; +} + +int +main () +{ + u8 x = foo((v64u64){0x0706050403020100UL}); + if (x != 5) + __builtin_abort (); + return 0; +}