From: Chen Gang <cheng...@emindsoft.com.cn>

When check bundle, gcc may still need modify the prev insn. Original
implementation will lose the prev insn.

Also correct the coding styles of relate code.

2016-12-10  Chen Gang <gang.chen.5...@gmail.com>

        gcc/
        PR target/78222
        * tilegx.c (tilegx_gen_bundle): Reserve prev insn when delete
        useless insn.
---
 gcc/config/tilegx/tilegx.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c
index 76a7455..f846ca7 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);
 
@@ -4499,14 +4498,17 @@ tilegx_gen_bundles (void)
          /* Delete barrier insns, because they can mess up the
             emitting of bundle braces.  If it is end-of-bundle, then
             the previous insn must be marked end-of-bundle.  */
-         if (get_attr_type (insn) == TYPE_NOTHING) {
-           if (GET_MODE (insn) == QImode && prev != NULL
-               && GET_MODE (prev) == SImode)
-             {
-               PUT_MODE (prev, QImode);
-             }
-           delete_insn (insn);
-         }
+         if (get_attr_type (insn) == TYPE_NOTHING)
+           {
+             if (GET_MODE (insn) == QImode && prev != NULL
+                 && GET_MODE (prev) == SImode)
+               {
+                 PUT_MODE (prev, QImode);
+               }
+               delete_insn (insn);
+           }
+         else
+           prev = insn;
        }
     }
 }
-- 
2.5.0

Reply via email to