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: Speedup CSE by 5%


On Thu, 2005-01-27 at 18:33 -0500, Kazu Hirata wrote:
> Hi Jeff,
> 
> > The NOT/NEG case could probably be handled with something like this:
> > 
> > return fold_rtx (insn ? copy_rtx (XEXP (new, 0)) : XEXP (new, 0), insn);
> > 
> > The MINUS case assumes that plus_constant doesn't modify RTL in-place,
> > which AFAIK is a safe assumption.
> > 
> > I'll give those two tweaks a spin and see what happens...  Even if we
> > can't measure a speedup, we save memory when we can avoid the copy.
> 
> FYI, these two optimizations don't trigger while compiling cc1-i
> files.
> 
>         -: 3468:    case NOT:
>         -: 3469:    case NEG:
>         -: 3470:      /* If we have (NOT Y), see if Y is known to be (NOT Z).
>         -: 3471:	 If so, (NOT Y) simplifies to Z.  Similarly for NEG.  */
>      9061: 3472:      new = lookup_as_function (XEXP (x, 0), code);
>      9061: 3473:      if (new)
>     #####: 3474:	return fold_rtx (copy_rtx (XEXP (new, 0)), insn);
>         -: 3475:      break;
> 
>         -: 4107:	case MINUS:
>         -: 4108:	  /* If we have (MINUS Y C), see if Y is known to be (PLUS Z C2).
>         -: 4109:	     If so, produce (PLUS Z C2-C).  */
>     20841: 4110:	  if (const_arg1 != 0 && GET_CODE (const_arg1) == CONST_INT)
>         -: 4111:	    {
>         3: 4112:	      rtx y = lookup_as_function (XEXP (x, 0), PLUS);
>         3: 4113:	      if (y && GET_CODE (XEXP (y, 1)) == CONST_INT)
>     #####: 4114:		return fold_rtx (plus_constant (copy_rtx (y),
>         -: 4115:						-INTVAL (const_arg1)),
>         -: 4116:				 NULL_RTX);
>         -: 4117:	    }
> 
> So if you are changing these, you might also want to make sure that
> fold_rtx there are reachable with some testcase.
> 
> In case you wonder where three occurrences in the MINUS case come
> from, I've filed a PR 19643.
I wouldn't be terribly surprised since DOM will optimize both of these
cases.  To trigger in CSE we'd have to have a case which appears as
a result of lowering from trees to rtl or some rtl optimization.

jeff



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