------- Comment #11 from rask at gcc dot gnu dot org 2007-11-29 00:09 ------- In reply to comment #10 from Steven Bosscher 2007-11-28 22:02:
> > + for (defs = DF_INSN_DEFS (insn); > > + *defs && DF_REF_REGNO (*defs) != REGNO (x); > > + defs++) > > + ; > Are you aware of df_find_def() ? Not until now, and it won't work either, because it uses rtx_equal_p() and the mode of DF_REF_REG() doesn't match that of the REG rtx in the insn. See also <URL:http://gcc.gnu.org/ml/gcc/2007-11/msg00719.html>. > IMNSHO, computing DEF-USE chains for this niche optimization loses in the > cost/benefit trade-off. The split of the comparison setter and the comparison user across two insns with no link between them is an interesting case of poor infrastructure. Most back ends can't emit the setter before they know what the user looks like and therefore always emit the two back-to-back. At the same time, several passes need to find one from the other but can't rely on them to be back-to-back and because there's no link between them (except if by DEF-USE/USE-DEF), they have to roll their own means of doing so. (So yes, it's been done without DEF-USE before and it can be done without DEF-USE again.) > I wonder if you can't just integrate this optimization in cse.c as-is by > recording an equivalence "a < b" == "signof(c)" when you process "a - b". That doesn't catch the unsigned comparison. Actually, how would I even know if it is unsigned or not? > In any case, adding this optimization to cse.c is Just Wrong (tm). I > don't understand why you didn't even try to optimize this in one of the > tree optimizers instead. I thought it was clear GCC is trying to reduce > its dependency on RTL optimizations? There's no way to optimize the signed case with -fwrapv (e.g. Java) at the tree level, because we can't arrange for a - b to be computed in the same instruction as a < b. At the RTL level, it is merely difficult. That makes it less interesting to work on this optimization at the tree level. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3507