• Nicolas Pitre's avatar
    [ARM PATCH] 1678/1: correct and better do_div() implementation for ARM · 3eb64c82
    Nicolas Pitre authored
    Patch from Nicolas Pitre
    
    Here's a rewrite of the ARM do_div() implementation.  It is much
    faster and smarter than the current code, and it also takes
    advantage of ARMv5+ instructions when target processor allows it.
    
    The current code also deserves to be killed ASAP since it overflows
    and fails to compute correct values in many cases.  For example:
    
    	u64 n = 2200000001;
    	u32 x = 2200000000;
    	u32 r = do_div(n, x);
    
    This currently returns n = 41 and r = 46829569 which is obviously bad.
    
    Another failing example is n=15000000000000000000 and x=3000000000.
    3eb64c82
div64.S 3.75 KB