Commit 2b2587f5 by Richard Guenther Committed by Richard Biener

re PR middle-end/37289 (ICE after non-trivial conversion at assignment)

2008-08-31  Richard Guenther  <rguenther@suse.de>

	PR middle-end/37289
	* fold-const.c (fold_binary): Retain conversions in folding
	~A + 1 to -A.

	* gcc.dg/pr37289.c: New testcase.

From-SVN: r139831
parent fb2fed03
2008-08-31 Richard Guenther <rguenther@suse.de>
PR middle-end/37289
* fold-const.c (fold_binary): Retain conversions in folding
~A + 1 to -A.
2008-08-31 Jan Hubicka <jh@suse.cz>
* postreload-gcse.c (eliminate_partially_redundant_loads): Use optimize_bb_for_size_p.
......
......@@ -9498,7 +9498,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
/* Convert ~A + 1 to -A. */
if (TREE_CODE (arg0) == BIT_NOT_EXPR
&& integer_onep (arg1))
return fold_build1 (NEGATE_EXPR, type, TREE_OPERAND (arg0, 0));
return fold_build1 (NEGATE_EXPR, type,
fold_convert (type, TREE_OPERAND (arg0, 0)));
/* ~X + X is -1. */
if (TREE_CODE (arg0) == BIT_NOT_EXPR
......
2008-08-31 Richard Guenther <rguenther@suse.de>
PR middle-end/37289
* gcc.dg/pr37289.c: New testcase.
2008-08-31 Jakub Jelinek <jakub@redhat.com>
PR target/37168
......
/* { dg-do compile } */
/* { dg-options "-fdump-tree-original" } */
void f(unsigned long x);
void g(long x)
{
f((unsigned long)(-1-x)+1);
}
/* Make sure we do not lose the conversion. */
/* { dg-final { scan-tree-dump "-\\\(long unsigned int\\\) x" "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