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
This commit is contained in:
parent
3af836867f
commit
270d43bf1e
4 changed files with 39 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
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.
|
||||
|
|
15
gcc/testsuite/gcc.dg/pr30744-1.c
Normal file
15
gcc/testsuite/gcc.dg/pr30744-1.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* { 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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue