summaryrefslogtreecommitdiff
path: root/gcc/expmed.c
diff options
context:
space:
mode:
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1997-02-15 13:42:02 +0000
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>1997-02-15 13:42:02 +0000
commit22971e4a4d3d3db0f3146ea23b6fd243f1cb3e14 (patch)
tree2d59a46a1e5e307b82faf9ba6fd616174a93749a /gcc/expmed.c
parent9086de6afa38cd76d40970bbc20150bbf62cf9d5 (diff)
downloadgcc-22971e4a4d3d3db0f3146ea23b6fd243f1cb3e14.tar.gz
(expand_divmod): prefer divmod in same mode over div in wider mode.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@13638 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/expmed.c')
-rw-r--r--gcc/expmed.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/gcc/expmed.c b/gcc/expmed.c
index 4b569b1557c..65fb007da57 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -3661,11 +3661,18 @@ expand_divmod (rem_flag, code, mode, op0, op1, target, unsignedp)
return gen_lowpart (mode, remainder);
}
- /* Produce the quotient. */
- /* Try a quotient insn, but not a library call. */
- quotient = sign_expand_binop (compute_mode, udiv_optab, sdiv_optab,
- op0, op1, rem_flag ? NULL_RTX : target,
- unsignedp, OPTAB_WIDEN);
+ /* Produce the quotient. Try a quotient insn, but not a library call.
+ If we have a divmod in this mode, use it in preference to widening
+ the div (for this test we assume it will not fail). Note that optab2
+ is set to the one of the two optabs that the call below will use. */
+ quotient
+ = sign_expand_binop (compute_mode, udiv_optab, sdiv_optab,
+ op0, op1, rem_flag ? NULL_RTX : target,
+ unsignedp,
+ ((optab2->handlers[(int) compute_mode].insn_code
+ != CODE_FOR_nothing)
+ ? OPTAB_DIRECT : OPTAB_WIDEN));
+
if (quotient == 0)
{
/* No luck there. Try a quotient-and-remainder insn,