From b13e7b6cfc7ecbdd98cbff22e1b1a394c1f50dbc Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Thu, 8 May 2008 08:19:16 +0000 Subject: [PATCH] re PR middle-end/36172 (ice for legal code with -O3) 2008-05-08 Richard Guenther PR middle-end/36172 * fold-const.c (operand_equal_p): Two objects which types differ in pointerness are not equal. * gcc.c-torture/compile/pr36172.c: New testcase. From-SVN: r135070 --- gcc/ChangeLog | 6 ++++++ gcc/fold-const.c | 7 +++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr36172.c | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr36172.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 681dbb48b63..bdc484612dd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-05-08 Richard Guenther + + PR middle-end/36172 + * fold-const.c (operand_equal_p): Two objects which types + differ in pointerness are not equal. + 2008-05-08 Kai Tietz * calls.c (compute_argument_block_size): Add argument tree fndecl. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index db7be875427..1250d269502 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3033,8 +3033,11 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) /* If both types don't have the same signedness, then we can't consider them equal. We must check this before the STRIP_NOPS calls - because they may change the signedness of the arguments. */ - if (TYPE_UNSIGNED (TREE_TYPE (arg0)) != TYPE_UNSIGNED (TREE_TYPE (arg1))) + because they may change the signedness of the arguments. As pointers + strictly don't have a signedness, require either two pointers or + two non-pointers as well. */ + if (TYPE_UNSIGNED (TREE_TYPE (arg0)) != TYPE_UNSIGNED (TREE_TYPE (arg1)) + || POINTER_TYPE_P (TREE_TYPE (arg0)) != POINTER_TYPE_P (TREE_TYPE (arg1))) return 0; /* If both types don't have the same precision, then it is not safe diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 35eec51b664..68626fdf2f1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-05-08 Richard Guenther + + PR middle-end/36172 + * gcc.c-torture/compile/pr36172.c: New testcase. + 2008-05-08 Uros Bizjak PR target/35714 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr36172.c b/gcc/testsuite/gcc.c-torture/compile/pr36172.c new file mode 100644 index 00000000000..19f0950b16d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr36172.c @@ -0,0 +1,17 @@ +int f(float * ); +unsigned long FcCharSetFreeze (int *fcs, int b) +{ + int i; + int a = 0; + for (i = 0; i < *fcs; i++) + { + float *leaf = (float *)fcs; + int hash = f (leaf); + if (hash) + a = b; + if (!a) + return; + } + return (unsigned long) fcs; +} + -- 2.30.2