]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR rtl-optimization/88904
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 22 Jan 2019 09:12:31 +0000 (09:12 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 22 Jan 2019 09:12:31 +0000 (09:12 +0000)
* cfgcleanup.c (thread_jump): Verify cond2 doesn't mention
any nonequal registers before processing BB_END (b).

* gcc.c-torture/execute/pr88904.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@268140 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cfgcleanup.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr88904.c [new file with mode: 0644]

index 0b0402aa7ef2c9afadd11c901da7b94cc405b5ff..64f920ece339eb40480bfdad55868406f5e6e4fb 100644 (file)
@@ -1,5 +1,9 @@
 2019-01-22  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/88904
+       * cfgcleanup.c (thread_jump): Verify cond2 doesn't mention
+       any nonequal registers before processing BB_END (b).
+
        PR target/88905
        * optabs.c (add_equal_note): Add op0_mode argument, use it instead of
        GET_MODE (op0).
index b5c828fe3e518a863ce966f683e9e3ff54ddecfb..fd27fd6d21255ce2c710ba34ebb092a1e705e9e7 100644 (file)
@@ -338,6 +338,13 @@ thread_jump (edge e, basic_block b)
        insn != NEXT_INSN (BB_END (b)) && !failed;
        insn = NEXT_INSN (insn))
     {
+      /* cond2 must not mention any register that is not equal to the
+        former block.  Check this before processing that instruction,
+        as BB_END (b) could contain also clobbers.  */
+      if (insn == BB_END (b)
+         && mentions_nonequal_regs (cond2, nonequal))
+       goto failed_exit;
+
       if (INSN_P (insn))
        {
          rtx pat = PATTERN (insn);
@@ -362,11 +369,6 @@ thread_jump (edge e, basic_block b)
       goto failed_exit;
     }
 
-  /* cond2 must not mention any register that is not equal to the
-     former block.  */
-  if (mentions_nonequal_regs (cond2, nonequal))
-    goto failed_exit;
-
   EXECUTE_IF_SET_IN_REG_SET (nonequal, 0, i, rsi)
     goto failed_exit;
 
index 807c7188ff2016acaf86d6718befcdc457449490..5dce351975d4cee269ca3e3ca57d2882163a1ab2 100644 (file)
@@ -1,5 +1,8 @@
 2019-01-22  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/88904
+       * gcc.c-torture/execute/pr88904.c: New test.
+
        PR target/88905
        * gcc.dg/pr88905.c: New test.
 
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr88904.c b/gcc/testsuite/gcc.c-torture/execute/pr88904.c
new file mode 100644 (file)
index 0000000..8c28567
--- /dev/null
@@ -0,0 +1,38 @@
+/* PR rtl-optimization/88904 */
+
+volatile int v;
+
+__attribute__((noipa)) void
+bar (const char *x, const char *y, int z)
+{
+  if (!v)
+    __builtin_abort ();
+  asm volatile ("" : "+g" (x));
+  asm volatile ("" : "+g" (y));
+  asm volatile ("" : "+g" (z));
+}
+
+#define my_assert(e) ((e) ? (void) 0 : bar (#e, __FILE__, __LINE__))
+
+typedef struct {
+  unsigned M1;
+  unsigned M2 : 1;
+  int : 0;
+  unsigned M3 : 1;
+} S;
+
+S
+foo ()
+{
+  S result = {0, 0, 1};
+  return result;
+}
+
+int
+main ()
+{
+  S ret = foo ();
+  my_assert (ret.M2 == 0);
+  my_assert (ret.M3 == 1);
+  return 0;
+}