[PATCH] Improved RTL simplifications

law@redhat.com law@redhat.com
Fri Jun 7 15:04:00 GMT 2002


 In message <Pine.LNX.4.33.0206070735110.5966-100000@www.eyesopen.com>, Roger 
Sayle writes:
 > Firstly, we now attempt to simplify RTL of the form (ne (comp x y) 0)
 > into the equivalent (comp x y), where comp is a comparison operator
 > such as eq, gt, le, etc....    This sort of construct occurs when
 > substituting the pseudo containing the result of a comparison operation
 > into a jump instruction.  We already simplify the case where comp is
 > COMPARE.  Additionally, the first hunk below also tries to simplify
 > "(eq (comp x y) 0)" to "(revcomp x y)" if the original comparison code
 > comp can be inverted/reversed.  The use of reversed_comparison_code
 > ensures we only do this when safe from IEEE floating point issues.
This part is fine.

 > Secondly, the replacement code in simplify_replace_rtx would only
 > substitute the "new" parameter for the "old" parameter in "x" if
 > the matching subexpression was equal to "new" by pointer comparison.
 > This works for substituting cc0_rtx, for example, because the RTL
 > node is unique.  Alas it doesn't work in the general case of pseudo
 > registers.  The second hunk of the patch below also makes the
 > replacement if x and new are both registers with identical REGNOs.
This doesn't make sense.  Pseudos are supposed to be shared, if they
aren't, then something is badly wrong and needs to be fixed.  It's also
the case that the patch itself looks wrong.

 > *** 328,339 ****
 >   	}
 >         return x;
 > 
 > !     default:
 >         if (GET_CODE (x) == MEM)
 >   	return
 >   	  replace_equiv_address_nv (x,
 >   				    simplify_replace_rtx (XEXP (x, 0),
 >   							  old, new));
 > 
 >         return x;
 >       }
 > --- 349,363 ----
 >   	}
 >         return x;
 > 
 > !     case 'o':
 >         if (GET_CODE (x) == MEM)
 >   	return
 >   	  replace_equiv_address_nv (x,
 >   				    simplify_replace_rtx (XEXP (x, 0),
 >   							  old, new));
 > +
 > +       if (REG_P (x) && REG_P (old) && REGNO (x) == REGNO (old))
 > + 	return new;
 > 
 >         return x;
 >       }

You've eliminated the default case -- while I think the code will continue
to work, you really shouldn't remove the default case.

And as I noted earlier, if you've got pseudos which reference the same
register, but are not pointer equal, then we've got a problem that
needs to be fixed.  A number of places in the compiler (particularly
register allocation and reloading) assume pseudos are shared.

jeff



More information about the Gcc-patches mailing list