File nov102315.diff of Package gcc33
Backport of
revision 1.322.2.9
date: 2004/03/23 23:30:48; author: kazu; state: Exp; lines: +3 -0
gcc/
PR optimization/14669
* fold-const.c (fold): Only unwiden integer comparisons for equality
and inequality operators, or when the signedness doesn't change.
gcc/testsuite/
PR optimization/14669
* g++.dg/opt/fold2.C: New test case.
Index: gcc/fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.322.2.8
retrieving revision 1.322.2.9
diff -c -3 -p -r1.322.2.8 -r1.322.2.9
*** gcc/fold-const.c 17 Mar 2004 04:31:07 -0000 1.322.2.8
--- gcc/fold-const.c 23 Mar 2004 23:30:48 -0000 1.322.2.9
*************** fold (tree expr)
*** 7478,7483 ****
--- 7478,7486 ----
else if (TREE_CODE (TREE_TYPE (arg0)) == INTEGER_TYPE
&& TREE_CODE (arg0) == NOP_EXPR
&& (tem = get_unwidened (arg0, NULL_TREE)) != arg0
+ && (code == EQ_EXPR || code == NE_EXPR
+ || TREE_UNSIGNED (TREE_TYPE (arg0))
+ == TREE_UNSIGNED (TREE_TYPE (tem)))
&& (t1 = get_unwidened (arg1, TREE_TYPE (tem))) != 0
&& (TREE_TYPE (t1) == TREE_TYPE (tem)
|| (TREE_CODE (t1) == INTEGER_CST