Commit 270d43bf by Roger Sayle Committed by Roger Sayle

re PR middle-end/30744 (ICE in compare_values, at tree-vrp.c:466)


	PR middle-end/30744
	* fold-const.c (fold_comparison): Enforce type consistency when
	transforming ~X op ~Y to Y op X, and ~X op C to X op' ~C.

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

From-SVN: r122531
parent 3af83686
2007-03-04 Roger Sayle <roger@eyesopen.com>
PR middle-end/30744
* fold-const.c (fold_comparison): Enforce type consistency when
transforming ~X op ~Y to Y op X, and ~X op C to X op' ~C.
2007-03-04 Zdenek Dvorak <dvorakz@suse.cz>
* tree-ssa-address.c (create_mem_ref): Do not put an expression
......
......@@ -8921,16 +8921,23 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1)
/* Fold ~X op ~Y as Y op X. */
if (TREE_CODE (arg0) == BIT_NOT_EXPR
&& TREE_CODE (arg1) == BIT_NOT_EXPR)
return fold_build2 (code, type,
TREE_OPERAND (arg1, 0),
TREE_OPERAND (arg0, 0));
{
tree cmp_type = TREE_TYPE (TREE_OPERAND (arg0, 0));
return fold_build2 (code, type,
fold_convert (cmp_type, TREE_OPERAND (arg1, 0)),
TREE_OPERAND (arg0, 0));
}
/* Fold ~X op C as X op' ~C, where op' is the swapped comparison. */
if (TREE_CODE (arg0) == BIT_NOT_EXPR
&& TREE_CODE (arg1) == INTEGER_CST)
return fold_build2 (swap_tree_comparison (code), type,
TREE_OPERAND (arg0, 0),
fold_build1 (BIT_NOT_EXPR, TREE_TYPE (arg1), arg1));
{
tree cmp_type = TREE_TYPE (TREE_OPERAND (arg0, 0));
return fold_build2 (swap_tree_comparison (code), type,
TREE_OPERAND (arg0, 0),
fold_build1 (BIT_NOT_EXPR, cmp_type,
fold_convert (cmp_type, arg1)));
}
return NULL_TREE;
}
......
2007-03-04 Roger Sayle <roger@eyesopen.com>
PR middle-end/30744
* gcc.dg/pr30744-1.c: New test case.
2007-03-04 Tobias Burnus <burnus@net-b.de>
* gfortran.dg/c_by_val.c: Use _Complex instead of a struct.
/* { dg-do compile } */
/* { dg-options "-O2" } */
typedef struct {
unsigned long unique;
} G;
void r(G* n)
{
unsigned long p;
if (((G *) ((void *)((~(unsigned long)(p))))) != ((void *)0)) {
((G *) ((void *)((~(unsigned long)(p)))))->unique = n->unique;
}
}
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