Commit f8ed9a1c by Roger Sayle Committed by Roger Sayle

re PR tree-optimization/15458 (Combine ~ and ^.)


	PR tree-optimization/15458
	* fold-const.c (fold_binary): Optimize ~X ^ C as X ^ ~C, where C
	is a constant.

	* gcc.dg/fold-xornot-1.c: New test case.

From-SVN: r118152
parent 0f8bc3e1
2006-10-29 Roger Sayle <roger@eyesopen.com>
PR tree-optimization/15458
* fold-const.c (fold_binary): Optimize ~X ^ C as X ^ ~C, where C
is a constant.
2006-10-29 Richard Guenther <rguenther@suse.de>
* config/i386/i386-protos.h (ix86_expand_trunc): Declare.
......
......@@ -9506,6 +9506,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
fold_convert (type, TREE_OPERAND (arg0, 0)),
fold_convert (type, TREE_OPERAND (arg1, 0)));
/* Convert ~X ^ C to X ^ ~C. */
if (TREE_CODE (arg0) == BIT_NOT_EXPR
&& TREE_CODE (arg1) == INTEGER_CST)
return fold_build2 (code, type,
fold_convert (type, TREE_OPERAND (arg0, 0)),
fold_build1 (BIT_NOT_EXPR, type, arg1));
/* Fold (X & 1) ^ 1 as (X & 1) == 0. */
if (TREE_CODE (arg0) == BIT_AND_EXPR
&& integer_onep (TREE_OPERAND (arg0, 1))
......
2006-10-29 Roger Sayle <roger@eyesopen.com>
PR tree-optimization/15458
* gcc.dg/fold-xornot-1.c: New test case.
2006-10-29 Richard Guenther <rguenther@suse.de>
* gcc.target/i386/math-torture/trunc.c: New testcase.
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-original" } */
int foo(int x)
{
return ~(x ^ 4);
}
int bar(int y)
{
return ~y ^ 4;
}
/* { dg-final { scan-tree-dump-times "x \\^ -5" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "y \\^ -5" 1 "original" } } */
/* { dg-final { cleanup-tree-dump "original" } } */
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