On Wednesday 02 July 2003 02:36, Andrew Morton wrote:
> > sorry for coming up with this patch in a short time frame, but
> > it needs to be applied in order to fix real do_div() brokenness
> > on many architectures.
> I included this in 2.5.73-mm2. It will percolate through after I've
> eyeballed it more thoroughly and run it past the arch maintainers.
Thank you very much Andrew! I was already thinking of contacting either
you or davem to pick that one up from me.
By the way, what do you think about getting rid of the do_div() macro
altogether? I've noticed that gcc 3.3 is quite capable of guessing the
optimal instruction pattern to use even for the generic do_div()
written in C:
rem = (unsigned long)div % (unsigned)base;
div = (unsigned long)div / (unsigned)base;
This code makes gcc select the "udivmodsi4" pattern on the m68k
backend, which computes both the quotient and remainder with a
single instruction on some architectures. The compiler is even
smart enough to optimize the case where the remainder isn't used:
if (find_reg_note (insn, REG_UNUSED, operands))
return \"divu%.l %2,%0\";
return \"divul%.l %2,%3:%0\";
So I don't see a performance issue here. There are even places
in the kernel where do_div() is used even when the remainder
isn't used, so it's a potential performance hit (but GCC is
again smart enough to detect that dead code and discards it ;-).
If there are architectures where gcc doesn't implement divisions
correctly, this issue should be solved in gcc, not by adding a
silly macro to the kernel.
-- // Bernardo Innocenti - Develer S.r.l., R&D dept. \X/ http://www.develer.com/
Please don't send Word attachments - http://www.gnu.org/philosophy/no-word-attachments.html
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to email@example.com More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Mon Jul 07 2003 - 22:00:14 EST