LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File nov102315.diff of Package gcc33 (Project openSUSE:Factory)

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
===================================================================
--- gcc/fold-const.c.orig	2009-11-20 13:05:56.000000000 +0100
+++ gcc/fold-const.c	2009-11-20 13:06:42.000000000 +0100
@@ -6620,6 +6620,9 @@ fold (expr)
       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