re PR rtl-optimization/70542 (Wrong code with -O3 -mavx2.)

PR rtl-optimization/70542
	* ree.c (add_removable_extension): For VECTOR_MODE_P punt
	if there are any uses other than insn or debug insns.

	* gcc.dg/torture/pr70542.c: New test.
	* gcc.target/i386/avx2-pr70542.c: New test.

From-SVN: r234756
This commit is contained in:
Jakub Jelinek 2016-04-05 19:05:23 +02:00 committed by Jakub Jelinek
parent 02a49e4f9f
commit 268a0ec4ed
5 changed files with 65 additions and 14 deletions

View File

@ -1,3 +1,9 @@
2016-04-05 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/70542
* ree.c (add_removable_extension): For VECTOR_MODE_P punt
if there are any uses other than insn or debug insns.
2016-04-05 Marc Glisse <marc.glisse@inria.fr>
Jakub Jelinek <jakub@redhat.com>

View File

@ -1025,11 +1025,11 @@ add_removable_extension (const_rtx expr, rtx_insn *insn,
return;
}
/* For vector mode extensions, ensure that all uses of the
XEXP (src, 0) register are the same extension (both code
and to which mode), as unlike integral extensions lowpart
subreg of the sign/zero extended register are not equal
to the original register, so we have to change all uses or
none. */
XEXP (src, 0) register are in insn or debug insns, as unlike
integral extensions lowpart subreg of the sign/zero extended
register are not equal to the original register, so we have
to change all uses or none and the current code isn't able
to change them all at once in one transaction. */
else if (VECTOR_MODE_P (GET_MODE (XEXP (src, 0))))
{
if (idx == 0)
@ -1046,15 +1046,7 @@ add_removable_extension (const_rtx expr, rtx_insn *insn,
break;
}
rtx_insn *use_insn = DF_REF_INSN (ref_link->ref);
const_rtx use_set;
if (use_insn == insn || DEBUG_INSN_P (use_insn))
continue;
if (!(use_set = single_set (use_insn))
|| !REG_P (SET_DEST (use_set))
|| GET_MODE (SET_DEST (use_set)) != GET_MODE (dest)
|| GET_CODE (SET_SRC (use_set)) != code
|| !rtx_equal_p (XEXP (SET_SRC (use_set), 0),
XEXP (src, 0)))
if (use_insn != insn && !DEBUG_INSN_P (use_insn))
{
idx = -1U;
break;

View File

@ -1,3 +1,9 @@
2016-04-05 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/70542
* gcc.dg/torture/pr70542.c: New test.
* gcc.target/i386/avx2-pr70542.c: New test.
2016-04-05 Zdenek Sojka <zsojka@seznam.cz>
PR tree-optimization/70509

View File

@ -0,0 +1,31 @@
/* PR rtl-optimization/70542 */
/* { dg-do run } */
int a[113], d[113];
short b[113], c[113], e[113];
int
main ()
{
int i;
long j;
for (i = 0; i < 113; ++i)
{
a[i] = -636544305;
b[i] = -31804;
}
for (j = 1; j <= 112; ++j)
{
c[j] = b[j] >> ((a[j] & 1587842570) - 1510214139);
if (a[j])
d[j] = j;
e[j] = 7 << ((2312631697 - b[j]) - 2312663500);
}
asm volatile ("" : : : "memory");
if (c[0] || d[0] || e[0])
__builtin_abort ();
for (i = 1; i <= 112; ++i)
if (c[i] != -1 || d[i] != i || e[i] != 14)
__builtin_abort ();
return 0;
}

View File

@ -0,0 +1,16 @@
/* PR tree-optimization/70542 */
/* { dg-do run } */
/* { dg-options "-O3 -mavx2" } */
/* { dg-require-effective-target avx2 } */
#include "avx2-check.h"
#define main() do_main ()
#include "../../gcc.dg/torture/pr70542.c"
static void
avx2_test (void)
{
do_main ();
}