This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix PR64878: do not jump thread across two loop iterations


On 02/04/15 14:20, Sebastian Pop wrote:
Hi,

The attached patch stops the recursion in the detection of FSM jump-threads at
loop phi nodes after having visited a loop phi node.  This avoids jump-threading
two iterations forward that were possible due to a flip-flop operation that
exchange the value of the switch control variable as illustrated in the
testcase:

do {
   c = read_from_memory;
   switch (a) {
   case 0:
     if (c == ' ')
      [...]
     else
       a = b;   // flip-flop
     break;
   case 1:
     a = 0;
     b = 15; // this will jump-thread to 15
     break;

   case 15:
   [...]
   }
} while (...);

The patch has passed bootstrap and regression testing on x86_64-linux.
Ok to commit?

Thanks,
Sebastian


0001-PR-64878-do-not-jump-thread-across-more-than-one-bac.patch


 From 59c486720749fc3d5feac2a5364d52eac60ba2d0 Mon Sep 17 00:00:00 2001
From: Sebastian Pop<s.pop@samsung.com>
Date: Wed, 4 Feb 2015 11:17:54 -0600
Subject: [PATCH] PR 64878: do not jump thread across more than one back-edge

2015-02-04  Sebastian Pop<s.pop@samsung.com>
	    Brian Rzycki<b.rzycki@samsung.com>

	PR tree-optimization/64878
	* tree-ssa-threadedge.c: Include tree-ssa-loop.h.
	(fsm_find_control_statement_thread_paths): Add parameter seen_loop_phi.
	Stop recursion at loop phi nodes after having visited a loop phi node.

	* testsuite/gcc.dg/tree-ssa/ssa-dom-thread-8.c: New.

+ /* PR64878: do not take more than a loop phi node: it may be a flip-flop
+	 operation across two latch edges.  */

The comment doesn't make much sense. Shouldn't it be something like "Do not walk through more than one loop PHI node"?

OK for the trunk with the comment clarified.

jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]