From 87a72aa8f9a533b3d885b04be81b1c81d526f542 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Thu, 27 Mar 2008 01:55:50 -0700 Subject: [PATCH] re PR tree-optimization/35429 (ICE with complex arithmetic) 2008-03-27 Andrew Pinski PR middle-end/35429 * fold-const.c (fold_truthop): Check for integeral types when folding a == 0 && b == 0 and a != 0 || b != 0 . 2008-03-27 Andrew Pinski PR middle-end/35429 * gcc.c-torture/compile/complex-5.c: New test. From-SVN: r133631 --- gcc/ChangeLog | 6 ++++++ gcc/fold-const.c | 6 ++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/complex-5.c | 9 +++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/complex-5.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f62d553bba29..8eca39fde41d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-03-27 Andrew Pinski + + PR middle-end/35429 + * fold-const.c (fold_truthop): Check for integeral types when folding + a == 0 && b == 0 and a != 0 || b != 0 . + 2008-03-26 Eric Botcazou * tree.c (get_unwidened): Remove code fiddling with COMPONENT_REF. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 3bfe52e0081f..896a9838e142 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -5357,7 +5357,8 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) if (code == TRUTH_OR_EXPR && lcode == NE_EXPR && integer_zerop (lr_arg) && rcode == NE_EXPR && integer_zerop (rr_arg) - && TREE_TYPE (ll_arg) == TREE_TYPE (rl_arg)) + && TREE_TYPE (ll_arg) == TREE_TYPE (rl_arg) + && INTEGRAL_TYPE_P (TREE_TYPE (ll_arg))) return build2 (NE_EXPR, truth_type, build2 (BIT_IOR_EXPR, TREE_TYPE (ll_arg), ll_arg, rl_arg), @@ -5367,7 +5368,8 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) if (code == TRUTH_AND_EXPR && lcode == EQ_EXPR && integer_zerop (lr_arg) && rcode == EQ_EXPR && integer_zerop (rr_arg) - && TREE_TYPE (ll_arg) == TREE_TYPE (rl_arg)) + && TREE_TYPE (ll_arg) == TREE_TYPE (rl_arg) + && INTEGRAL_TYPE_P (TREE_TYPE (ll_arg))) return build2 (EQ_EXPR, truth_type, build2 (BIT_IOR_EXPR, TREE_TYPE (ll_arg), ll_arg, rl_arg), diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 55916d14f9d0..e7f0cbe0608e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-03-27 Andrew Pinski + + PR middle-end/35429 + * gcc.c-torture/compile/complex-5.c: New test. + 2008-03-26 Kaveh R. Ghazi * gcc.dg/uninit-16.c (decode_reloc): Mark static. diff --git a/gcc/testsuite/gcc.c-torture/compile/complex-5.c b/gcc/testsuite/gcc.c-torture/compile/complex-5.c new file mode 100644 index 000000000000..59ddf68be849 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/complex-5.c @@ -0,0 +1,9 @@ +int foo(__complex__ int z0, __complex__ int z1) +{ + return z0 != 0 || z1 != 0; +} + +int foo1(__complex__ int z0, __complex__ int z1) +{ + return z0 == 0 && z1 == 0; +} -- 2.43.5