@@ -2012,28 +2012,14 @@ default_max_noce_ifcvt_seq_cost (edge e)
DImode __udivmoddi4 (DImode op0, DImode op1, DImode *rem). */
void
-default_expand_divmod_libfunc (bool unsignedp, machine_mode mode,
- rtx op0, rtx op1,
- rtx *quot_p, rtx *rem_p)
+default_expand_divmod_libfunc (bool unsignedp ATTRIBUTE_UNUSED,
+ machine_mode mode ATTRIBUTE_UNUSED,
+ rtx op0 ATTRIBUTE_UNUSED,
+ rtx op1 ATTRIBUTE_UNUSED,
+ rtx *quot_p ATTRIBUTE_UNUSED,
+ rtx *rem_p ATTRIBUTE_UNUSED)
{
- gcc_assert (mode == DImode);
- gcc_assert (unsignedp);
-
- rtx libfunc = optab_libfunc (udivmod_optab, DImode);
- gcc_assert (libfunc);
- gcc_assert (!strcmp (XSTR (libfunc, 0), "__udivmoddi4"));
-
- rtx remainder = assign_stack_temp (DImode, GET_MODE_SIZE (DImode));
- rtx address = XEXP (remainder, 0);
-
- rtx quotient = emit_library_call_value (libfunc, NULL_RTX, LCT_CONST,
- DImode, 3,
- op0, GET_MODE (op0),
- op1, GET_MODE (op1),
- address, GET_MODE (address));
-
- *quot_p = quotient;
- *rem_p = remainder;
+ gcc_unreachable ();
}
@@ -3808,9 +3808,13 @@ target_supports_divmod_p (optab divmod_optab, optab div_optab, machine_mode mode
if (optab_handler (divmod_optab, mode) != CODE_FOR_nothing)
return true;
- /* Check if libfunc for divmod is available. */
- rtx libfunc = optab_libfunc (divmod_optab, mode);
- if (libfunc != NULL_RTX)
+ /* Check if target-specific divmod libfunc is available.
+ If target overrides expand_divmod_libfunc, then it *has to*
+ set_optab_libfunc (divmod_optab, mode) to target-specific divmod
+ libfunc or NULL for unsupported modes. */
+
+ if (targetm.expand_divmod_libfunc != default_expand_divmod_libfunc
+ && optab_libfunc (divmod_optab, mode))
{
/* If optab_handler exists for div_optab, perhaps in a wider mode,
we don't want to use the libfunc even if it exists for given mode. */
@@ -3820,12 +3824,7 @@ target_supports_divmod_p (optab divmod_optab, optab div_optab, machine_mode mode
if (optab_handler (div_optab, div_mode) != CODE_FOR_nothing)
return false;
- /* FIXME: This is a hack to workaround an issue with optab_libfunc().
- optab_libfunc (sdivmod_optab, DImode) returns libfunc "__divmoddi4",
- although __divmoddi4() does not exist in libgcc. For now, enable the
- transform only if libfunc is guaranteed to be __udivmoddi4. */
- return (targetm.expand_divmod_libfunc != default_expand_divmod_libfunc
- || !strcmp (XSTR (libfunc, 0), "__udivmoddi4"));
+ return true;
}
return false;