Commit d8086cbb by Roger Sayle Committed by Richard Henderson

re PR rtl-optimization/3640 (small lost optimization of "x==0 || x==1")

        PR opt/3640
        * fold-const.c (fold): Optimize unsigned comparisons against
        UINT_MAX (and similar unsigned constants).

From-SVN: r49096
parent 11303d15
2002-01-22 Roger Sayle <roger@eyesopen.com>
Richard Henderson <rth@redhat.com>
PR opt/3640
* fold-const.c (fold): Optimize unsigned comparisons against
UINT_MAX (and similar unsigned constants).
2002-01-22 Janis Johnson <janis187@us.ibm.com> 2002-01-22 Janis Johnson <janis187@us.ibm.com>
* Makefile.in (loop.o): Depend on OPTABS_H. * Makefile.in (loop.o): Depend on OPTABS_H.
......
/* Fold a constant sub-tree into a single node for C-compiler /* Fold a constant sub-tree into a single node for C-compiler
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001 Free Software Foundation, Inc. 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -6753,6 +6753,31 @@ fold (expr) ...@@ -6753,6 +6753,31 @@ fold (expr)
default: default:
break; break;
} }
else if (TREE_UNSIGNED (TREE_TYPE (arg1))
&& tree_int_cst_equal (TYPE_MAX_VALUE (TREE_TYPE (arg1)),
arg1))
switch (TREE_CODE (t))
{
case GT_EXPR:
return omit_one_operand (type,
convert (type, integer_zero_node),
arg0);
case GE_EXPR:
TREE_SET_CODE (t, EQ_EXPR);
break;
case LE_EXPR:
return omit_one_operand (type,
convert (type, integer_one_node),
arg0);
case LT_EXPR:
TREE_SET_CODE (t, NE_EXPR);
break;
default:
break;
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment