bitintlower: Padding bit fixes, part 6 [PR123635]
This commit fixes an issue in bitintlower on big-endian architectures related to padding bits and overflow handling in multiplication.
This commit addresses a failure in the bitintlower pass on big-endian architectures, specifically s390x-linux. The issue occurred during the handling of __builtin_mul_overflow for bitint types, where the code incorrectly extended the most significant limb due to an incorrect offset calculation. The fix involves recomputing obj_nelts before extending the bitint and adjusting the arguments passed to limb_access for big-endian systems, resolving the incorrect memory access and assertion failures.
In Details
This patch fixes PR123635 in gimple-lower-bitint.cc, specifically within bitint_large_huge::finish_arith_overflow. The bug involved incorrect handling of padding bits when lowering __builtin_mul_overflow for bitint types on big-endian architectures. The code extends the partial most significant limb before memmoving, leading to incorrect offset calculations. The fix adjusts the offset calculation and uses NULL_TREE for limb_access calls on big-endian systems.
For Context
The bitintlower pass in GCC lowers operations on arbitrarily large integer types (bitints) to primitive operations. This commit fixes an issue in the handling of multiplication overflow checking for these types, specifically on big-endian architectures like s390x. The fix ensures that padding bits are handled correctly when performing multiplication, preventing incorrect results or crashes. This improves the reliability of code that utilizes bitint types for arbitrary precision arithmetic.