diff options
| author | Jeff Epler <jepler@gmail.com> | 2025-07-23 16:14:22 -0500 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-10-01 09:23:05 +1000 |
| commit | a80913292153a14424b29bdb9ca8847e8d35cf73 (patch) | |
| tree | 9d073ab5c9c1773d30daa89d3062c3ee1bbed380 /tests/micropython/const_math.py.exp | |
| parent | 3dd8073c290c077f17ffdee17a019763ad82604d (diff) | |
py: Add MICROPY_USE_GCC_MUL_OVERFLOW_INTRINSIC.
Most MCUs apart from Cortex-M0 with Thumb 1 have an instruction
for computing the "high part" of a multiplication (e.g., the upper
32 bits of a 32x32 multiply).
When they do, gcc uses this to implement a small and fast
overflow check using the __builtin_mul_overflow intrinsic, which
is preferable to the guard division method previously used in smallint.c.
However, in contrast to the previous mp_small_int_mul_overflow
routine, which checks that the result fits not only within mp_int_t
but is SMALL_INT_FITS(), __builtin_mul_overflow only checks for
overflow of the C type. As a result, a slight change in the code
flow is needed for MP_BINARY_OP_MULTIPLY.
Other sites using mp_small_int_mul_overflow already had the
result value flow through to a SMALL_INT_FITS check so they didn't
need any additional changes.
Do similarly for the _ll and _ull multiply overflows checks.
Signed-off-by: Jeff Epler <jepler@gmail.com>
Diffstat (limited to 'tests/micropython/const_math.py.exp')
0 files changed, 0 insertions, 0 deletions
