re PR tree-optimization/35231 (VRP miscompiles libX11)

2008-02-17  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/35231
	* tree-vrp.c (register_edge_assert_for): Do not assume A == 0
	if A | B != 1.

	* gcc.c-torture/execute/pr35231.c: New testcase.

From-SVN: r132378
This commit is contained in:
Richard Guenther 2008-02-17 14:00:48 +00:00 committed by Richard Biener
parent e6528d32a4
commit e09deb1401
4 changed files with 32 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2008-02-17 Richard Guenther <rguenther@suse.de>
PR tree-optimization/35231
* tree-vrp.c (register_edge_assert_for): Do not assume A == 0
if A | B != 1.
2008-02-17 Uros Bizjak <ubizjak@gmail.com>
Revert:

View File

@ -1,3 +1,8 @@
2008-02-17 Richard Guenther <rguenther@suse.de>
PR tree-optimization/35231
* gcc.c-torture/execute/pr35231.c: New testcase.
2008-02-17 Uros Bizjak <ubizjak@gmail.com>
* gcc.target/i386/pr32268.c (test_lt): Add noinline attribute.

View File

@ -0,0 +1,16 @@
extern void abort(void);
int __attribute__((noinline))
foo(int bits_per_pixel, int depth)
{
if ((bits_per_pixel | depth) == 1)
abort ();
return bits_per_pixel;
}
int main()
{
if (foo(2, 0) != 2)
abort ();
return 0;
}

View File

@ -3753,7 +3753,11 @@ register_edge_assert_for (tree name, edge e, block_stmt_iterator si, tree cond)
if (TREE_CODE (def_stmt) == GIMPLE_MODIFY_STMT
&& (TREE_CODE (GIMPLE_STMT_OPERAND (def_stmt, 1)) == TRUTH_OR_EXPR
|| TREE_CODE (GIMPLE_STMT_OPERAND (def_stmt, 1)) == BIT_IOR_EXPR))
/* For BIT_IOR_EXPR only if NAME == 0 both operands have
necessarily zero value. */
|| (comp_code == EQ_EXPR
&& (TREE_CODE (GIMPLE_STMT_OPERAND (def_stmt, 1))
== BIT_IOR_EXPR))))
{
tree op0 = TREE_OPERAND (GIMPLE_STMT_OPERAND (def_stmt, 1), 0);
tree op1 = TREE_OPERAND (GIMPLE_STMT_OPERAND (def_stmt, 1), 1);