This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/16795] PowerPC - Divide sequences by negative power of two could be more efficient
- From: "dje at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Sep 2004 03:40:15 -0000
- Subject: [Bug target/16795] PowerPC - Divide sequences by negative power of two could be more efficient
- References: <20040728170038.16795.steinmtz@us.ibm.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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