[ARM] Reapply: Use __rt_div functions for divrem on Windows
authorMartin Storsjo <martin@martin.st>
Fri, 7 Oct 2016 13:28:53 +0000 (13:28 +0000)
committerMartin Storsjo <martin@martin.st>
Fri, 7 Oct 2016 13:28:53 +0000 (13:28 +0000)
commit04864f45b2f24e1268640cbde9203a7f769b6a79
tree5eb71c7f126d00c6b7fbad7e5e43032ea4767437
parent12d6baf5e40ac16d70bd588d0b62ad53b945fe7e
[ARM] Reapply: Use __rt_div functions for divrem on Windows

Reapplying r283383 after revert in r283442. The additional fix
is a getting rid of a stray space in a function name, in the
refactoring part of the commit.

This avoids falling back to calling out to the GCC rem functions
(__moddi3, __umoddi3) when targeting Windows.

The __rt_div functions have flipped the two arguments compared
to the __aeabi_divmod functions. To match MSVC, we emit a
check for division by zero before actually calling the library
function (even if the library function itself also might do
the same check).

Not all calls to __rt_div functions for division are currently
merged with calls to the same function with the same parameters
for the remainder. This is more wasteful than a div + mls as before,
but avoids calls to __moddi3.

Differential Revision: https://reviews.llvm.org/D25332

llvm-svn: 283550
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/test/CodeGen/ARM/Windows/dbzchk.ll
llvm/test/CodeGen/ARM/divmod-eabi.ll