From: Richard Sandiford Date: Thu, 28 Jul 2005 16:34:42 +0000 (+0000) Subject: re PR c/20187 (wrong code for ((unsigned char)(unsigned long long)((a?a:1)&(a*b)... X-Git-Tag: releases/gcc-3.4.5~300 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=805732365b9753317e24b5fffaec77796b20e8a8;p=thirdparty%2Fgcc.git re PR c/20187 (wrong code for ((unsigned char)(unsigned long long)((a?a:1)&(a*b)))?0:1)) PR c/20187 * fold-const.c (fold): When shortening comparisons of widened operands, check whether the tree returned by get_unwidened really is wider. From-SVN: r102495 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ec9f065d9b21..017127f47269 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-07-28 Richard Sandiford + + PR c/20187 + * fold-const.c (fold): When shortening comparisons of widened operands, + check whether the tree returned by get_unwidened really is wider. + 2005-07-28 Richard Sandiford PR c/22589 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 64b0b51e11c8..bcc7dcdebbb4 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7500,6 +7500,8 @@ fold (tree expr) else if (TREE_CODE (TREE_TYPE (arg0)) == INTEGER_TYPE && TREE_CODE (arg0) == NOP_EXPR && (tem = get_unwidened (arg0, NULL_TREE)) != arg0 + && (TYPE_PRECISION (TREE_TYPE (tem)) + > TYPE_PRECISION (TREE_TYPE (arg0))) && (code == EQ_EXPR || code == NE_EXPR || TREE_UNSIGNED (TREE_TYPE (arg0)) == TREE_UNSIGNED (TREE_TYPE (tem))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 696d97664c39..e9f90da27348 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-07-28 Richard Sandiford + + PR c/20187 + * gcc.c-torture/execute/pr20187-1.c: New test. + 2005-07-28 Giovanni Bajo Backport: