Fix missed constant folding of _BitInt return values.
GCC can now constant fold functions returning _BitInt types by checking the return type instead of the mode.
This commit resolves an issue where GCC failed to constant fold functions returning _BitInt types. The problem stemmed from a check that incorrectly used SCALAR_INT_MODE_P on BLKmode, which does not apply to _BitInt. The fix replaces this mode check with a direct check of the return type, enabling constant folding for these types and a new test case verifies the correction.
In Details
The fold_const_call_1 function in fold-const-call.cc previously used SCALAR_INT_MODE_P to determine if a function call's return value could be constant folded. This check fails for _BitInt types, which are represented in BLKmode. This commit modifies the function to directly check the return type of the call, ensuring that _BitInt return values are correctly handled for constant folding, aligning with the intended behavior of scalar integral types.
- _BitInt
- A non-standard integer type in GCC that allows specifying an exact bit width for an integer, e.g., _BitInt(7).
- constant folding
- An optimization technique where the compiler evaluates constant expressions at compile time rather than runtime.
- BLKmode
- A GCC internal machine mode representing a block of memory, often used for types that do not map directly to standard scalar integer or floating-point types, such as aggregate types or bit-fields.
- SSA
- Static Single Assignment form, an intermediate representation where each variable is assigned a value exactly once.