mirror of
https://gcc.gnu.org/git/gcc.git
synced 2026-02-22 03:46:53 -05:00
re PR middle-end/32912 (ICE with vector code)
PR middle-end/32912 * fold-const.c (fold_binary): Only optimize X | ~X and X ^ ~X for integral types. * gcc.dg/pr32912-1.c: New test. * gcc.dg/pr32912-2.c: New test. From-SVN: r127779
This commit is contained in:
committed by
Jakub Jelinek
parent
77379503c5
commit
d97911b915
@@ -9384,6 +9384,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
|
||||
|
||||
/* ~X | X is -1. */
|
||||
if (TREE_CODE (arg0) == BIT_NOT_EXPR
|
||||
&& INTEGRAL_TYPE_P (TREE_TYPE (arg1))
|
||||
&& operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0))
|
||||
{
|
||||
t1 = build_int_cst (type, -1);
|
||||
@@ -9393,6 +9394,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
|
||||
|
||||
/* X | ~X is -1. */
|
||||
if (TREE_CODE (arg1) == BIT_NOT_EXPR
|
||||
&& INTEGRAL_TYPE_P (TREE_TYPE (arg0))
|
||||
&& operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0))
|
||||
{
|
||||
t1 = build_int_cst (type, -1);
|
||||
@@ -9500,6 +9502,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
|
||||
|
||||
/* ~X ^ X is -1. */
|
||||
if (TREE_CODE (arg0) == BIT_NOT_EXPR
|
||||
&& INTEGRAL_TYPE_P (TREE_TYPE (arg1))
|
||||
&& operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0))
|
||||
{
|
||||
t1 = build_int_cst (type, -1);
|
||||
@@ -9509,6 +9512,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
|
||||
|
||||
/* X ^ ~X is -1. */
|
||||
if (TREE_CODE (arg1) == BIT_NOT_EXPR
|
||||
&& INTEGRAL_TYPE_P (TREE_TYPE (arg0))
|
||||
&& operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0))
|
||||
{
|
||||
t1 = build_int_cst (type, -1);
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
2007-08-24 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR middle-end/32912
|
||||
* gcc.dg/pr32912-1.c: New test.
|
||||
* gcc.dg/pr32912-2.c: New test.
|
||||
|
||||
PR c++/31941
|
||||
* g++.dg/parse/crash37.C: New test.
|
||||
|
||||
|
||||
44
gcc/testsuite/gcc.dg/pr32912-1.c
Normal file
44
gcc/testsuite/gcc.dg/pr32912-1.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/* PR middle-end/32912 */
|
||||
/* { dg-do run } */
|
||||
/* { dg-options "-O2 -w" } */
|
||||
|
||||
extern void abort (void);
|
||||
|
||||
typedef int __m128i __attribute__ ((__vector_size__ (16)));
|
||||
|
||||
__m128i a, b, c, d, e, f;
|
||||
|
||||
void
|
||||
foo (__m128i x)
|
||||
{
|
||||
a = x ^ ~x;
|
||||
b = ~x ^ x;
|
||||
c = x | ~x;
|
||||
d = ~x | x;
|
||||
e = x & ~x;
|
||||
f = ~x & x;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
union { __m128i v; int i[sizeof (__m128i) / sizeof (int)]; } u;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof (u.i) / sizeof (u.i[0]); i++)
|
||||
u.i[i] = i * 49 - 36;
|
||||
foo (u.v);
|
||||
#define check(x, val) \
|
||||
u.v = (x); \
|
||||
for (i = 0; i < sizeof (u.i) / sizeof (u.i[0]); i++) \
|
||||
if (u.i[i] != (val)) \
|
||||
abort ()
|
||||
|
||||
check (a, ~0);
|
||||
check (b, ~0);
|
||||
check (c, ~0);
|
||||
check (d, ~0);
|
||||
check (e, 0);
|
||||
check (f, 0);
|
||||
return 0;
|
||||
}
|
||||
45
gcc/testsuite/gcc.dg/pr32912-2.c
Normal file
45
gcc/testsuite/gcc.dg/pr32912-2.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/* { dg-do run } */
|
||||
/* { dg-options "-O2 -w" } */
|
||||
|
||||
extern void abort (void);
|
||||
|
||||
typedef int __m128i __attribute__ ((__vector_size__ (16)));
|
||||
|
||||
__m128i a, b, c, d, e, f;
|
||||
|
||||
__m128i
|
||||
foo (void)
|
||||
{
|
||||
__m128i x = { 0x11111111, 0x22222222, 0x44444444 };
|
||||
return x;
|
||||
}
|
||||
|
||||
__m128i
|
||||
bar (void)
|
||||
{
|
||||
__m128i x = { 0x11111111, 0x22222222, 0x44444444 };
|
||||
return ~x;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
union { __m128i v; int i[sizeof (__m128i) / sizeof (int)]; } u, v;
|
||||
int i;
|
||||
|
||||
u.v = foo ();
|
||||
v.v = bar ();
|
||||
for (i = 0; i < sizeof (u.i) / sizeof (u.i[0]); i++)
|
||||
{
|
||||
if (u.i[i] != ~v.i[i])
|
||||
abort ();
|
||||
if (i < 3)
|
||||
{
|
||||
if (u.i[i] != (0x11111111 << i))
|
||||
abort ();
|
||||
}
|
||||
else if (u.i[i])
|
||||
abort ();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user