public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][compare-elim] Fix PR rtl-optimization/82597
@ 2017-10-20  4:42 Michael Collison
  2017-10-31  9:41 ` Jakub Jelinek
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Collison @ 2017-10-20  4:42 UTC (permalink / raw)
  To: GCC Patches; +Cc: nd

[-- Attachment #1: Type: text/plain, Size: 533 bytes --]

This patch fixes an ICE on x86 because we were not constraining the operands
of a recognized insn. Bootstrapped and tested on aarch64-none-linux-gnu and x86_64.

Also successfully compiled the failing test cases in 82597 and duplicate 82592.

Ok for trunk?

2017-10-18  Michael Collison  <michael.collison@arm.com>

	PR rtl-optimization/82597
	* compare-elim.c: (try_validate_parallel): Constrain operands
	of recognized insn.

2017-10-18  Michael Collison  <michael.collison@arm.com>
	* gcc.dg/pr82597.c: New test.


[-- Attachment #2: rb8338.patch --]
[-- Type: application/octet-stream, Size: 1542 bytes --]

diff --git a/gcc/compare-elim.c b/gcc/compare-elim.c
index 086fbc7..ed841a1 100644
--- a/gcc/compare-elim.c
+++ b/gcc/compare-elim.c
@@ -631,7 +631,16 @@ try_validate_parallel (rtx set_a, rtx set_b)
   rtx_insn *insn;
   insn = gen_rtx_INSN (VOIDmode, 0, 0, 0, par, 0, -1, 0);
 
-  return recog_memoized (insn) > 0 ? par : NULL_RTX;
+  if (recog_memoized (insn) > 0)
+    {
+      extract_insn (insn);
+
+      return constrain_operands (reload_completed,
+				 get_enabled_alternatives (insn))
+	? par : NULL_RTX;
+    }
+
+  return NULL_RTX;
 }
 
 /* For a comparison instruction described by CMP check if it compares a
diff --git a/gcc/testsuite/gcc.dg/pr82597.c b/gcc/testsuite/gcc.dg/pr82597.c
new file mode 100644
index 0000000..98ae264
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr82597.c
@@ -0,0 +1,40 @@
+/* PR rtl-optimization/82597 */
+/* { dg-do compile  }*/
+/* { dg-options "-O2 -funroll-loops" } */
+
+int pb;
+
+void
+ch (unsigned char np, char fc)
+{
+  unsigned char *y6 = &np;
+
+  if (fc != 0)
+    {
+      unsigned char *z1 = &np;
+
+      for (;;)
+        if (*y6 != 0)
+          for (fc = 0; fc < 12; ++fc)
+            {
+              int hh;
+              int tp;
+
+              if (fc != 0)
+                hh = (*z1 != 0) ? fc : 0;
+              else
+                hh = pb;
+
+              tp = fc > 0;
+              if (hh == tp)
+                *y6 = 1;
+            }
+    }
+
+  if (np != 0)
+    y6 = (unsigned char *)&fc;
+  if (pb != 0 && *y6 != 0)
+    for (;;)
+      {
+      }
+}
-- 
1.9.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-11-01 20:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-20  4:42 [PATCH][compare-elim] Fix PR rtl-optimization/82597 Michael Collison
2017-10-31  9:41 ` Jakub Jelinek
2017-10-31 11:02   ` Jakub Jelinek
2017-10-31 23:20     ` Jakub Jelinek
2017-11-01 13:32     ` Eric Botcazou
2017-11-01 13:40       ` Jakub Jelinek
2017-11-01 13:49         ` Eric Botcazou
2017-11-01 13:54           ` Jakub Jelinek
2017-11-01 20:58             ` Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).