diff options
author | Roger Sayle <roger@eyesopen.com> | 2002-01-22 13:35:34 -0800 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2002-01-22 13:35:34 -0800 |
commit | d8086cbb53c533c2b0bbf97dbd353989cb163e94 (patch) | |
tree | ab37f047934f6e0f697e2a023bf75c95dafbdacb /gcc/fold-const.c | |
parent | 11303d15ae2ef463efda87d80619f06dc1c9f8ab (diff) | |
download | gcc-d8086cbb53c533c2b0bbf97dbd353989cb163e94.zip gcc-d8086cbb53c533c2b0bbf97dbd353989cb163e94.tar.gz gcc-d8086cbb53c533c2b0bbf97dbd353989cb163e94.tar.bz2 |
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
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index ce93a03..dec382d 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1,6 +1,6 @@ /* Fold a constant sub-tree into a single node for C-compiler 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. @@ -6753,6 +6753,31 @@ fold (expr) default: 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; + } } } |