Changes from v3: 1. Modify BEXTC to compare in the original type of the operand instead of the extended type of the copied object.
Due to omission of BITINT_EXTEND during expand, which forces an actual extension from the operand to a wider type, we can no longer rely on the value of the operand converted to the wider type as a reference result of a properly extended object. So, we convert the copied object down to the original precision to force such a extension before limb-wise comparison. 2. Adjust large/huge _BitInt lowering to match the expand behavior for small/middle _BitInts, so that BEXTC works for both cases. This is also one of the possible optimizations based on the "info.extended" ABI assumption. 3. In bitint lowering, ensure a zero-extension after widening cast from a signed _BitInt to an unsigned _BitInt type with a partial limb. 4. Other fixes from Jakub's review on v3. This series has been bootstrapped and tested on x86_64-linux-gnu, and tested on loongarch64-linux-gnu (right now bootstrap on LoongArch do not pass due to some strict checks failing in final.cc). Yang Yujie (9): bitint: Allow mode promotion of _BitInt types expand: Reduce unneeded _BitInt extensions bitint: Allow unused bits when testing extended _BitInt ABIs bitint: Avoid extending ABI-extended large/huge _BitInts on load bitint: Zero-extend the result of a signed->unsigned widening cast bitint: Make sure BEXTC checks extension when optimized bitint: Do not optimize away conversion to _BitInt before a VCE LoongArch: Prioritize target-specific makefile fragments LoongArch: Add support for _BitInt [PR117599] gcc/config/loongarch/loongarch.cc | 35 +++++++- gcc/config/loongarch/loongarch.h | 4 +- gcc/explow.cc | 24 ++++++ gcc/expr.cc | 12 +++ gcc/expr.h | 4 + gcc/function.cc | 4 + gcc/gimple-lower-bitint.cc | 35 ++++++-- gcc/match.pd | 19 ++++- gcc/testsuite/gcc.dg/bitintext.h | 26 +++++- gcc/testsuite/gcc.dg/torture/bitint-84.c | 19 +++++ .../gcc.target/loongarch/bitint-alignments.c | 58 +++++++++++++ .../gcc.target/loongarch/bitint-args.c | 81 +++++++++++++++++++ .../gcc.target/loongarch/bitint-sizes.c | 60 ++++++++++++++ libgcc/config.host | 31 +++---- libgcc/config/loongarch/libgcc-loongarch.ver | 28 +++++++ libgcc/config/loongarch/t-loongarch | 2 + libgcc/config/loongarch/t-softfp-tf | 1 + 17 files changed, 407 insertions(+), 36 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/bitint-84.c create mode 100644 gcc/testsuite/gcc.target/loongarch/bitint-alignments.c create mode 100644 gcc/testsuite/gcc.target/loongarch/bitint-args.c create mode 100644 gcc/testsuite/gcc.target/loongarch/bitint-sizes.c create mode 100644 libgcc/config/loongarch/libgcc-loongarch.ver -- 2.46.0