This is the mail archive of the gcc-bugs@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]

[Bug target/16795] PowerPC - Divide sequences by negative power of two could be more efficient


------- Additional Comments From dje at gcc dot gnu dot org  2004-09-12 03:40 -------
For positive power of 2 constants, expand_divmod checks if divide is cheap, but
for negative power of 2 constants, it does not.  The following patch negates the
cheap divide by power of 2 of the absolute value and then negates the result.

*************** expand_divmod (int rem_flag, enum tree_c
*** 3764,3770 ****
                        if (remainder)
                          return gen_lowpart (mode, remainder);
                      }
!                   quotient = expand_sdiv_pow2 (compute_mode, op0, abs_d);
  
                    /* We have computed OP0 / abs(OP1).  If OP1 is negative,
                       negate the quotient.  */
--- 3764,3782 ----
                        if (remainder)
                          return gen_lowpart (mode, remainder);
                      }
! 
!                   if (sdiv_pow2_cheap[compute_mode]
!                       && ((sdiv_optab->handlers[compute_mode].insn_code
!                            != CODE_FOR_nothing)
!                           || (sdivmod_optab->handlers[compute_mode].insn_code
!                               != 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);


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-09-12 03:40:14
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16795


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