This patch fixes a bundling bug.  When there are consecutive barriers,
the end-of-bundle marker of the last barrier is getting dropped.

Bootstrapped and tested on tilegx hardware, also backported to GCC 6.

2016-11-18  Walter Lee  <w...@tilera.com>

        * config/tilegx/tilegx.c (tilegx_gen_bundles): Preserve
          end-of-bundle marker for consecutive barriers.

diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c
index 76a7455..0403e8e 100644
--- a/gcc/config/tilegx/tilegx.c
+++ b/gcc/config/tilegx/tilegx.c
@@ -4469,8 +4469,7 @@ tilegx_gen_bundles (void)
       rtx_insn *end = NEXT_INSN (BB_END (bb));

       prev = NULL;
-      for (insn = next_insn_to_bundle (BB_HEAD (bb), end); insn;
-          prev = insn, insn = next)
+      for (insn = next_insn_to_bundle (BB_HEAD (bb), end); insn; insn = next)
        {
          next = next_insn_to_bundle (NEXT_INSN (insn), end);

@@ -4506,7 +4505,11 @@ tilegx_gen_bundles (void)
                PUT_MODE (prev, QImode);
              }
            delete_insn (insn);
+
+            // Note: prev remains the same for next iteration.
          }
+          else
+            prev = insn;
        }
     }
 }

Reply via email to