From: Segher Boessenkool Date: Sun, 15 Jan 2017 17:03:55 +0000 (+0100) Subject: ifcvt: Don't make invalid insns for a cond trap (PR78751) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=32a8d3f66a4d02b77774a713e5c4ff8d586af4f4;p=gcc.git ifcvt: Don't make invalid insns for a cond trap (PR78751) As shown in the PR, ifcvt will happily make invalid insns when given the chance. This patch teaches it some manners. PR rtl-optimization/78751 * ifcvt.c (find_cond_trap): If we generated a non-existing insn, give up. From-SVN: r244476 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 36982c69df1..c689c58670c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-01-15 Segher Boessenkool + + PR rtl-optimization/78751 + * ifcvt.c (find_cond_trap): If we generated a non-existing insn, + give up. + 2017-01-14 Jeff Law PR tree-optimization/79090 diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index 68c1a1d42c4..6d306392f60 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -4686,6 +4686,11 @@ find_cond_trap (basic_block test_bb, edge then_edge, edge else_edge) if (seq == NULL) return FALSE; + /* If that results in an invalid insn, back out. */ + for (rtx_insn *x = seq; x; x = NEXT_INSN (x)) + if (recog_memoized (x) < 0) + return FALSE; + /* Emit the new insns before cond_earliest. */ emit_insn_before_setloc (seq, cond_earliest, INSN_LOCATION (trap));