aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederik Harwath <frederik@codesourcery.com>2019-11-29 15:02:35 +0000
committerFrederik Harwath <frederik@codesourcery.com>2019-11-29 15:02:35 +0000
commitb939eca877d7819d8d8a827bdf1d145a55058bd4 (patch)
tree044542ed3bf35ca0399d591f60710c233294a8fc
parent47d7cc3971e60db7de525934237fb85b1f2e1a56 (diff)
Fix ICE in re-simplification of VEC_COND_EXPR
The function maybe_resimplify_conditional_op uses operation_could_trap_p to check if the resulting operation of a simplification can trap. Because of the changes introduced by revision r276659, this results in an ICE due to a violated assertion in operation_could_trap_p if the operation is a COND_EXPR or a VEC_COND_EXPR. The changes have allowed those expressions to trap and whether they do cannot be determined without considering their condition which is not available to operation_could_trap_p. Change maybe_resimplify_conditional_op to inspect the condition of COND_EXPRs and VEC_COND_EXPRs to determine if they can trap. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@278853 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/gimple-match-head.c18
2 files changed, 21 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ea1a587f80b..2b2cde341fa 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2019-11-29 Frederik Harwath <frederik@codesourcery.com>
+
+ * gimple-match-head.c (maybe_resimplify_conditional_op): Use
+ generic_expr_could_trap_p to check if the condition of COND_EXPR or
+ VEC_COND_EXPR can trap.
+
2019-11-29 Richard Sandiford <richard.sandiford@arm.com>
PR tree-optimization/92677
diff --git a/gcc/gimple-match-head.c b/gcc/gimple-match-head.c
index 2996bade301..9010f11621e 100644
--- a/gcc/gimple-match-head.c
+++ b/gcc/gimple-match-head.c
@@ -144,9 +144,21 @@ maybe_resimplify_conditional_op (gimple_seq *seq, gimple_match_op *res_op,
/* Likewise if the operation would not trap. */
bool honor_trapv = (INTEGRAL_TYPE_P (res_op->type)
&& TYPE_OVERFLOW_TRAPS (res_op->type));
- if (!operation_could_trap_p ((tree_code) res_op->code,
- FLOAT_TYPE_P (res_op->type),
- honor_trapv, res_op->op_or_null (1)))
+ tree_code op_code = (tree_code) res_op->code;
+ bool op_could_trap;
+
+ /* COND_EXPR and VEC_COND_EXPR will trap if, and only if, the condition
+ traps and hence we have to check this. For all other operations, we
+ don't need to consider the operands. */
+ if (op_code == COND_EXPR || op_code == VEC_COND_EXPR)
+ op_could_trap = generic_expr_could_trap_p (res_op->ops[0]);
+ else
+ op_could_trap = operation_could_trap_p ((tree_code) res_op->code,
+ FLOAT_TYPE_P (res_op->type),
+ honor_trapv,
+ res_op->op_or_null (1));
+
+ if (!op_could_trap)
{
res_op->cond.cond = NULL_TREE;
return false;