summaryrefslogtreecommitdiff
path: root/gcc/expmed.c
diff options
context:
space:
mode:
authordje <dje@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-12 20:05:30 +0000
committerdje <dje@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-12 20:05:30 +0000
commitcb2e141eda2b6ea00a0671e451c62e98defe64b2 (patch)
tree64177dd93f46d8007e54530a6263757da7cd383b /gcc/expmed.c
parent8b260754fc952962680981ebf1f3ca7e88dabf3b (diff)
downloadgcc-cb2e141eda2b6ea00a0671e451c62e98defe64b2.tar.gz
PR target/16795
* expmed.c (expand_divmod): If cheap power of 2 divide is available, use it for negative constant as well. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@87403 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/expmed.c')
-rw-r--r--gcc/expmed.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/expmed.c b/gcc/expmed.c
index fe9aeb5c4c9..eb8226da75f 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -3764,7 +3764,19 @@ expand_divmod (int rem_flag, enum tree_code code, enum machine_mode mode,
if (remainder)
return gen_lowpart (mode, remainder);
}
- quotient = expand_sdiv_pow2 (compute_mode, op0, abs_d);
+
+ 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);
/* We have computed OP0 / abs(OP1). If OP1 is negative,
negate the quotient. */