Fix ARM32 JIT errors with native int-div#128970
Conversation
Fix errors when USE_HELPERS_FOR_INT_DIV is disabled to use native ARM division instructions, and add the missing GT_UDIV case.
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
@dhartglassMSFT, PTAL. |
It's enabled with hardcoded value: runtime/src/coreclr/jit/targetarm.h Line 14 in 503cdd1 Do we need to add a runtime detection? // in src/native/minipal/cpufeatures.h
#if defined(HOST_ARM)
#define ArmIntrinsicConstants_IDIV (1 << 0)
#endif
// in src/native/minipal/cpufeatures.c
#elif defined(HOST_ARM)
#if defined(HOST_UNIX)
unsigned long hwcaps = getauxval(AT_HWCAP);
if (hwcaps & HWCAP_IDIV)
{
// Our baseline support is ARMv7 with SDIV/UDIV
result |= ArmIntrinsicConstants_IDIV;
}and wire it like Zbs was done in 65e9497. |
|
@am11 Thanks for the suggestion! Regarding |
|
Our bar for linux arm32 is to keep it functional. We are not spending any cycles to make it better. I do not think we are interested in investing into new arm32-specific optimizations. |
|
@jkotas Thank you for your comment. I think PR like error fix can still be reviewed and merged if there is no problem. Could you review this PR? |
|
@dhartglassMSFT is going to review this PR |
|
@dhartglassMSFT Could you please review this PR when you get a chance? |
|
|
||
| #if defined(USE_HELPERS_FOR_INT_DIV) | ||
| #if USE_HELPERS_FOR_INT_DIV | ||
| if (!varTypeIsIntegral(divMod->TypeGet())) |
There was a problem hiding this comment.
Should the if be checking the inverse? This seems like a typo and we want if(varTypeIsIntegral... without the !
or get rid of the if, and add the assert message to the TypeIsFloating assert, seems like we don't need both of these
|
I think the following code in gentree.cpp must also be updated - as-is something strange could happen if we try to generate a MOD/UMOD helper call when "USE_HELPERS_FOR_INT_DIV == 0" in the GT_MOD/GT_UMOD cases should be under the ARM32 target ifdef |
BTW, that hwcap suggestion is about changing buildtime check to runtime check with a single |
- genCodeForDivMod now throws DivideByZeroException (x / 0) and ArithmeticException (MinInt / -1), gated on OperExceptions. - Address review comments
Fix errors when USE_HELPERS_FOR_INT_DIV is disabled to use native ARM division instructions, and add the missing GT_UDIV case.