Commit 09a782eb by Richard Guenther Committed by Richard Biener

re PR tree-optimization/40579 (gcc -O2 optimization causes infinite loop and wrong output)

2009-06-29  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/40579
	* tree-vrp.c (vrp_evaluate_conditional): Bail out early if
	the IL to simplify has constants that overflowed.

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

From-SVN: r149046
parent 152413f7
2009-06-29 Richard Guenther <rguenther@suse.de>
PR tree-optimization/40579
* tree-vrp.c (vrp_evaluate_conditional): Bail out early if
the IL to simplify has constants that overflowed.
2009-06-28 Uros Bizjak <ubizjak@gmail.com>
PR tree-optimization/40550
......
2009-06-29 Richard Guenther <rguenther@suse.de>
PR tree-optimization/40579
* gcc.c-torture/execute/pr40579.c: New testcase.
2009-06-28 Uros Bizjak <ubizjak@gmail.com>
PR tree-optimization/40550
......
extern void abort (void);
static char * __attribute__((noinline))
itos(int num)
{
return (char *)0;
}
static void __attribute__((noinline))
foo(int i, const char *x)
{
if (i >= 4)
abort ();
}
int main()
{
int x = -__INT_MAX__ + 3;
int i;
for (i = 0; i < 4; ++i)
{
char *p;
--x;
p = itos(x);
foo(i, p);
}
return 0;
}
......@@ -5679,6 +5679,14 @@ vrp_evaluate_conditional (enum tree_code code, tree op0, tree op1, gimple stmt)
tree ret;
bool only_ranges;
/* Some passes and foldings leak constants with overflow flag set
into the IL. Avoid doing wrong things with these and bail out. */
if ((TREE_CODE (op0) == INTEGER_CST
&& TREE_OVERFLOW (op0))
|| (TREE_CODE (op1) == INTEGER_CST
&& TREE_OVERFLOW (op1)))
return NULL_TREE;
sop = false;
ret = vrp_evaluate_conditional_warnv_with_ops (code, op0, op1, true, &sop,
&only_ranges);
......
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