Commit 39c97e41 by Richard Biener Committed by Richard Biener

re PR tree-optimization/68031 (cc1 crashes when compiling newlib / mktm_r.c)

2015-10-21  Richard Biener  <rguenther@suse.de>

	PR middle-end/68031
	* fold-const.c: Include tree-ssa-operands.h and tree-into-ssa.h.
	(tree_ssa_name_nonnegative_warnv_p): Fold into ...
	(tree_single_nonnegative_warnv_p): ... here.  For SSA names
	make sure they are not registered for update.

	* gcc.dg/torture/pr68031.c: New testcase.

From-SVN: r229118
parent 33b35c28
2015-10-21 Richard Biener <rguenther@suse.de> 2015-10-21 Richard Biener <rguenther@suse.de>
PR middle-end/68031
* fold-const.c: Include tree-ssa-operands.h and tree-into-ssa.h.
(tree_ssa_name_nonnegative_warnv_p): Fold into ...
(tree_single_nonnegative_warnv_p): ... here. For SSA names
make sure they are not registered for update.
2015-10-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/68026 PR tree-optimization/68026
* tree-ssa-ccp.c (get_value_for_expr): Zero-extend mask for * tree-ssa-ccp.c (get_value_for_expr): Zero-extend mask for
unsigned VARYING values. unsigned VARYING values.
...@@ -79,6 +79,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -79,6 +79,8 @@ along with GCC; see the file COPYING3. If not see
#include "optabs-query.h" #include "optabs-query.h"
#include "gimple-fold.h" #include "gimple-fold.h"
#include "params.h" #include "params.h"
#include "tree-ssa-operands.h"
#include "tree-into-ssa.h"
#ifndef LOAD_EXTEND_OP #ifndef LOAD_EXTEND_OP
#define LOAD_EXTEND_OP(M) UNKNOWN #define LOAD_EXTEND_OP(M) UNKNOWN
...@@ -12940,25 +12942,6 @@ tree_binary_nonnegative_warnv_p (enum tree_code code, tree type, tree op0, ...@@ -12940,25 +12942,6 @@ tree_binary_nonnegative_warnv_p (enum tree_code code, tree type, tree op0,
return false; return false;
} }
/* Return true if SSA name T is known to be non-negative. If the return
value is based on the assumption that signed overflow is undefined,
set *STRICT_OVERFLOW_P to true; otherwise, don't change
*STRICT_OVERFLOW_P. DEPTH is the current nesting depth of the query. */
static bool
tree_ssa_name_nonnegative_warnv_p (tree t, bool *strict_overflow_p, int depth)
{
/* Limit the depth of recursion to avoid quadratic behavior.
This is expected to catch almost all occurrences in practice.
If this code misses important cases that unbounded recursion
would not, passes that need this information could be revised
to provide it through dataflow propagation. */
if (depth < PARAM_VALUE (PARAM_MAX_SSA_NAME_QUERY_DEPTH))
return gimple_stmt_nonnegative_warnv_p (SSA_NAME_DEF_STMT (t),
strict_overflow_p, depth);
return tree_simple_nonnegative_warnv_p (TREE_CODE (t), TREE_TYPE (t));
}
/* Return true if T is known to be non-negative. If the return /* Return true if T is known to be non-negative. If the return
value is based on the assumption that signed overflow is undefined, value is based on the assumption that signed overflow is undefined,
set *STRICT_OVERFLOW_P to true; otherwise, don't change set *STRICT_OVERFLOW_P to true; otherwise, don't change
...@@ -12967,6 +12950,10 @@ tree_ssa_name_nonnegative_warnv_p (tree t, bool *strict_overflow_p, int depth) ...@@ -12967,6 +12950,10 @@ tree_ssa_name_nonnegative_warnv_p (tree t, bool *strict_overflow_p, int depth)
bool bool
tree_single_nonnegative_warnv_p (tree t, bool *strict_overflow_p, int depth) tree_single_nonnegative_warnv_p (tree t, bool *strict_overflow_p, int depth)
{ {
if (TREE_CODE (t) == SSA_NAME
&& name_registered_for_update_p (t))
return false;
if (TYPE_UNSIGNED (TREE_TYPE (t))) if (TYPE_UNSIGNED (TREE_TYPE (t)))
return true; return true;
...@@ -12985,8 +12972,16 @@ tree_single_nonnegative_warnv_p (tree t, bool *strict_overflow_p, int depth) ...@@ -12985,8 +12972,16 @@ tree_single_nonnegative_warnv_p (tree t, bool *strict_overflow_p, int depth)
return RECURSE (TREE_OPERAND (t, 1)) && RECURSE (TREE_OPERAND (t, 2)); return RECURSE (TREE_OPERAND (t, 1)) && RECURSE (TREE_OPERAND (t, 2));
case SSA_NAME: case SSA_NAME:
return tree_ssa_name_nonnegative_warnv_p (t, strict_overflow_p, depth); /* Limit the depth of recursion to avoid quadratic behavior.
This is expected to catch almost all occurrences in practice.
If this code misses important cases that unbounded recursion
would not, passes that need this information could be revised
to provide it through dataflow propagation. */
if (depth < PARAM_VALUE (PARAM_MAX_SSA_NAME_QUERY_DEPTH))
return gimple_stmt_nonnegative_warnv_p (SSA_NAME_DEF_STMT (t),
strict_overflow_p, depth);
/* Fallthru. */
default: default:
return tree_simple_nonnegative_warnv_p (TREE_CODE (t), TREE_TYPE (t)); return tree_simple_nonnegative_warnv_p (TREE_CODE (t), TREE_TYPE (t));
} }
......
2015-10-21 Richard Biener <rguenther@suse.de> 2015-10-21 Richard Biener <rguenther@suse.de>
PR middle-end/68031
* gcc.dg/torture/pr68031.c: New testcase.
2015-10-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/68026 PR tree-optimization/68026
* gcc.dg/tree-ssa/ssa-ccp-39.c: New testcase. * gcc.dg/tree-ssa/ssa-ccp-39.c: New testcase.
......
/* { dg-do compile } */
void _mktm_r (long lcltime, int *res)
{
long rem = lcltime % ((60L * 60L) * 24L);
if (rem < 0)
return;
while (rem >= ((60L * 60L) * 24L))
rem -= ((60L * 60L) * 24L);
*res = (int) (rem % 60L);
}
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