This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] 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.

Bootstrapped and tested on powerpc64-linux.  Is this okay for trunk?


Segher


2017-01-15  Segher Boessenkool  <segher@kernel.crashing.org>

	PR rtl-optimization/78751
	* ifcvt.c (find_cond_trap): If we generated a non-existing insn,
	give up.

---
 gcc/ifcvt.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 68c1a1d..6d30639 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));
 
-- 
1.9.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]