Commit 853ce7c0 by Jakub Jelinek Committed by Jakub Jelinek

re PR middle-end/92063 (ICE in operation_could_trap_p, at tree-eh.c:2528 when…

re PR middle-end/92063 (ICE in operation_could_trap_p, at tree-eh.c:2528 when compiling Python's Python/_warnings.c)

	PR middle-end/92063
	* tree-eh.c (operation_could_trap_helper_p) <case COND_EXPR>
	<case VEC_COND_EXPR>: Return false with *handled = false.
	(tree_could_trap_p): For {,VEC_}COND_EXPR return false instead of
	recursing on the first operand.
	* fold-const.c (simple_operand_p_2): Use generic_expr_could_trap_p
	instead of tree_could_trap_p.
	* tree-ssa-sccvn.c (vn_nary_may_trap): Formatting fixes.

	* gcc.c-torture/compile/pr92063.c: New test.

From-SVN: r276915
parent 20de9568
2019-10-12 Jakub Jelinek <jakub@redhat.com>
PR middle-end/92063
* tree-eh.c (operation_could_trap_helper_p) <case COND_EXPR>
<case VEC_COND_EXPR>: Return false with *handled = false.
(tree_could_trap_p): For {,VEC_}COND_EXPR return false instead of
recursing on the first operand.
* fold-const.c (simple_operand_p_2): Use generic_expr_could_trap_p
instead of tree_could_trap_p.
* tree-ssa-sccvn.c (vn_nary_may_trap): Formatting fixes.
2019-10-11 Jim Wilson <jimw@sifive.com> 2019-10-11 Jim Wilson <jimw@sifive.com>
PR rtl-optimization/91860 PR rtl-optimization/91860
......
...@@ -4447,8 +4447,7 @@ simple_operand_p_2 (tree exp) ...@@ -4447,8 +4447,7 @@ simple_operand_p_2 (tree exp)
{ {
enum tree_code code; enum tree_code code;
if (TREE_SIDE_EFFECTS (exp) if (TREE_SIDE_EFFECTS (exp) || generic_expr_could_trap_p (exp))
|| tree_could_trap_p (exp))
return false; return false;
while (CONVERT_EXPR_P (exp)) while (CONVERT_EXPR_P (exp))
......
2019-10-12 Jakub Jelinek <jakub@redhat.com> 2019-10-12 Jakub Jelinek <jakub@redhat.com>
PR middle-end/92063
* gcc.c-torture/compile/pr92063.c: New test.
* c-c++-common/gomp/declare-variant-2.c: Adjust for error recovery * c-c++-common/gomp/declare-variant-2.c: Adjust for error recovery
improvements. Add new tests. improvements. Add new tests.
* c-c++-common/gomp/declare-variant-4.c: New test. * c-c++-common/gomp/declare-variant-4.c: New test.
......
/* PR middle-end/92063 */
int
foo (int a, int b, int *c, short *d)
{
return (c[0] ? b : 0) == 'y' && ((a ? d[0] : c[0]) ? b : 0) == 'c';
}
...@@ -2499,6 +2499,14 @@ operation_could_trap_helper_p (enum tree_code op, ...@@ -2499,6 +2499,14 @@ operation_could_trap_helper_p (enum tree_code op,
/* Constructing an object cannot trap. */ /* Constructing an object cannot trap. */
return false; return false;
case COND_EXPR:
case VEC_COND_EXPR:
/* Whether *COND_EXPR can trap depends on whether the
first argument can trap, so signal it as not handled.
Whether lhs is floating or not doesn't matter. */
*handled = false;
return false;
default: default:
/* Any floating arithmetic may trap. */ /* Any floating arithmetic may trap. */
if (fp_operation && flag_trapping_math) if (fp_operation && flag_trapping_math)
...@@ -2614,9 +2622,12 @@ tree_could_trap_p (tree expr) ...@@ -2614,9 +2622,12 @@ tree_could_trap_p (tree expr)
if (!expr) if (!expr)
return false; return false;
/* For COND_EXPR and VEC_COND_EXPR only the condition may trap. */ /* In COND_EXPR and VEC_COND_EXPR only the condition may trap, but
they won't appear as operands in GIMPLE form, so this is just for the
GENERIC uses where it needs to recurse on the operands and so
*COND_EXPR itself doesn't trap. */
if (TREE_CODE (expr) == COND_EXPR || TREE_CODE (expr) == VEC_COND_EXPR) if (TREE_CODE (expr) == COND_EXPR || TREE_CODE (expr) == VEC_COND_EXPR)
expr = TREE_OPERAND (expr, 0); return false;
code = TREE_CODE (expr); code = TREE_CODE (expr);
t = TREE_TYPE (expr); t = TREE_TYPE (expr);
......
...@@ -5105,18 +5105,15 @@ vn_nary_may_trap (vn_nary_op_t nary) ...@@ -5105,18 +5105,15 @@ vn_nary_may_trap (vn_nary_op_t nary)
honor_nans = flag_trapping_math && !flag_finite_math_only; honor_nans = flag_trapping_math && !flag_finite_math_only;
honor_snans = flag_signaling_nans != 0; honor_snans = flag_signaling_nans != 0;
} }
else if (INTEGRAL_TYPE_P (type) else if (INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_TRAPS (type))
&& TYPE_OVERFLOW_TRAPS (type))
honor_trapv = true; honor_trapv = true;
} }
if (nary->length >= 2) if (nary->length >= 2)
rhs2 = nary->op[1]; rhs2 = nary->op[1];
ret = operation_could_trap_helper_p (nary->opcode, fp_operation, ret = operation_could_trap_helper_p (nary->opcode, fp_operation,
honor_trapv, honor_trapv, honor_nans, honor_snans,
honor_nans, honor_snans, rhs2, rhs2, &handled);
&handled); if (handled && ret)
if (handled
&& ret)
return true; return true;
for (i = 0; i < nary->length; ++i) for (i = 0; i < nary->length; ++i)
......
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