All,
 
The DIV/MOD expansion performed in expmed is basically driven by RTX costs/-Os
that are provided by the backend.In a few instances these costs and or _os 
appear to be ignored.
 
One senerio  is divsion by a constant in a mode whose size <= 
HOST_BITS_PER_WIDE_INT
it will always expand the DIV/MOD using multiplation (Montgomery) when 
optimizing for size.
 
Shouldn't this expansion be be guarded by  !speed and the expansion skipped 
allowing
the backend open coding an DIV/MOD sequence or libcall.
 
Is guarding this with a !speed guard the best thing to do for most backends or 
should this be 
controlled with a new target hook with the default hook returning true for yes 
expand maintaining
the status quo giving the backends to override.
 
Another senerio is signed divison of a power-of-2  if the backend dosn't have 
optabs for sdiv
and sdivmod then  expand_sdiv_pow2 will be choosen even if otimizing for size 
and
sdiv_pow2_cheap() retuns true!
 
     if (sdiv_pow2_cheap (speed, compute_mode)
   && ((optab_handler (sdiv_optab, compute_mode)
        != CODE_FOR_nothing)
       || (optab_handler (sdivmod_optab, compute_mode)
    != CODE_FOR_nothing)))
        quotient = expand_divmod (0, TRUNC_DIV_EXPR,
      compute_mode, op0,
      gen_int_mode (abs_d,
             compute_mode),
      NULL_RTX, 0);
      else
        quotient = expand_sdiv_pow2 (compute_mode, op0, abs_d);
 
When optimizing for size (!speed) and sdiv_pow2_cheap() is true we ideally 
don't want to use 
expand_sdiv_pow2 but instead let the back end opend code the DIV.
 
Question how can one determine if a backend can open code a DIV/MOD
 
 Graham

Reply via email to