Patchwork PATCH: Properly check the end of basic block

login
register
mail settings
Submitter H.J. Lu
Date Nov. 17, 2010, 6:44 a.m.
Message ID <20101117064421.GA30836@intel.com>
Download mbox | patch
Permalink /patch/71530/
State New
Headers show

Comments

H.J. Lu - Nov. 17, 2010, 6:44 a.m.
Hi,

We may have

insn != BB_END (bb) && NEXT_INSN (insn) == NEXT_INSN (BB_END (bb))

We should check NEXT_INSN (insn) != NEXT_INSN (BB_END (bb)) in
move_or_delete_vzeroupper_2.  This patch does it.

OK for trunk?

Thanks.


H.J.
----
2010-11-16  H.J. Lu  <hongjiu.lu@intel.com>

	* config/i386/i386.c (move_or_delete_vzeroupper_2): Properly
	check the end of basic block.
Uros Bizjak - Nov. 17, 2010, 7:51 a.m.
On Wed, Nov 17, 2010 at 7:44 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:

> insn != BB_END (bb) && NEXT_INSN (insn) == NEXT_INSN (BB_END (bb))
>
> We should check NEXT_INSN (insn) != NEXT_INSN (BB_END (bb)) in
> move_or_delete_vzeroupper_2.  This patch does it.

Huh? The loop does simple linear scan of all insns in the bb, so it
can't miss BB_END. IIUC, in your case the bb does not have BB_END
(bb), but it has NEXT_INSN (BB_END (bb))?

Can you please provide a test case that illustrates this?

Uros.

Patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index e52f9b2..704a67d 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -108,7 +108,7 @@  check_avx256_stores (rtx dest, const_rtx set, void *data)
 static void
 move_or_delete_vzeroupper_2 (basic_block bb, bool upper_128bits_set)
 {
-  rtx insn;
+  rtx insn, last;
   rtx vzeroupper_insn = NULL_RTX;
   rtx pat;
   int avx256;
@@ -118,9 +118,12 @@  move_or_delete_vzeroupper_2 (basic_block bb, bool upper_128bits_set)
 	     bb->index, upper_128bits_set);
 
   insn = BB_HEAD (bb);
+  last = NEXT_INSN (BB_END (bb));
   while (insn != BB_END (bb))
     {
       insn = NEXT_INSN (insn);
+      if (insn == last)
+	break;
 
       if (!NONDEBUG_INSN_P (insn))
 	continue;