mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-18 20:31:00 +08:00
re PR tree-optimization/15784 (fold misses binary optimization)
2005-03-03 James A. Morrison <phython@gcc.gnu.org> PR tree-optimization/15784 * fold-const.c (fold): Fold ~A + 1 to -1. Fold -A - 1 and -1 - A to ~A. From-SVN: r95870
This commit is contained in:
parent
3159b178b0
commit
8d06c80914
@ -1,3 +1,9 @@
|
||||
2005-03-03 James A. Morrison <phython@gcc.gnu.org>
|
||||
|
||||
PR tree-optimization/15784
|
||||
* fold-const.c (fold): Fold ~A + 1 to -1. Fold -A - 1
|
||||
and -1 - A to ~A.
|
||||
|
||||
2005-03-03 David Edelsohn <edelsohn@gnu.org>
|
||||
|
||||
* config/rs6000/predicates.md (branch_comparison_operator):
|
||||
|
@ -7223,6 +7223,11 @@ fold (tree expr)
|
||||
if (TREE_CODE (arg0) == NEGATE_EXPR
|
||||
&& reorder_operands_p (TREE_OPERAND (arg0, 0), arg1))
|
||||
return fold (build2 (MINUS_EXPR, type, arg1, TREE_OPERAND (arg0, 0)));
|
||||
/* Convert ~A + 1 to -A. */
|
||||
if (INTEGRAL_TYPE_P (type)
|
||||
&& TREE_CODE (arg0) == BIT_NOT_EXPR
|
||||
&& integer_onep (arg1))
|
||||
return fold (build1 (NEGATE_EXPR, type, TREE_OPERAND (arg0, 0)));
|
||||
|
||||
if (TREE_CODE (type) == COMPLEX_TYPE)
|
||||
{
|
||||
@ -7661,6 +7666,16 @@ fold (tree expr)
|
||||
&& reorder_operands_p (arg0, arg1))
|
||||
return fold (build2 (MINUS_EXPR, type, negate_expr (arg1),
|
||||
TREE_OPERAND (arg0, 0)));
|
||||
/* Convert -A - 1 to ~A. */
|
||||
if (INTEGRAL_TYPE_P (type)
|
||||
&& TREE_CODE (arg0) == NEGATE_EXPR
|
||||
&& integer_onep (arg1))
|
||||
return fold (build1 (BIT_NOT_EXPR, type, TREE_OPERAND (arg0, 0)));
|
||||
|
||||
/* Convert -1 - A to ~A. */
|
||||
if (INTEGRAL_TYPE_P (type)
|
||||
&& integer_all_onesp (arg0))
|
||||
return fold (build1 (BIT_NOT_EXPR, type, arg1));
|
||||
|
||||
if (TREE_CODE (type) == COMPLEX_TYPE)
|
||||
{
|
||||
|
@ -1,3 +1,7 @@
|
||||
2005-03-03 James A. Morrison <phython@gcc.gnu.org>
|
||||
|
||||
* gcc.dg/pr15784-4.c: New test.
|
||||
|
||||
2005-03-03 Geoffrey Keating <geoffk@apple.com>
|
||||
|
||||
* gcc.c-torture/execute/pr17133.c: New.
|
||||
|
12
gcc/testsuite/gcc.dg/pr15784-4.c
Normal file
12
gcc/testsuite/gcc.dg/pr15784-4.c
Normal file
@ -0,0 +1,12 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -fdump-tree-optimized" } */
|
||||
int a (int x) {
|
||||
return ~x + 1; /* -x */
|
||||
}
|
||||
|
||||
int b (int x) {
|
||||
return -x -1; /* ~x */
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump "~x;" "optimized" } } */
|
||||
/* { dg-final { scan-tree-dump "-x;" "optimized" } } */
|
Loading…
x
Reference in New Issue
Block a user