[tree-ssa] DCE and conditionals

law@redhat.com law@redhat.com
Mon May 5 22:30:00 GMT 2003


In message <1052137908.19625.1223.camel@p4>, Andrew MacLeod writes:
 >That means we want someone, perhaps a very fast little pass of its own
 >that we can call when we want it, that goes into PHI nodes, looks at
 >them, and decides when they can be replaced with a copy.
Yes, this can be done very quickly.  It looks something like this:


  FOR_EACH_BB (bb)
    FOR_EACH_PHI (phi)
      FOR_EACH_PHI_ARG (phi_arg)
        if (phi_arg == phi_result)
	  continue;
        if (phi_arg == seen_arg)
          continue;
        if (seen_arg == NULL)
	  seen_arg = arg
        else
          FAIL

      if (!FAIL)
	remove phi & insert copy at start of basic block


The only trick is dealing with dependencies between arguments/results
of PHI nodes.

Jeff




More information about the Gcc mailing list