]> git.ipfire.org Git - thirdparty/gcc.git/commit
bitint: Handle BIT_FIELD_REF lowering [PR114157]
authorJakub Jelinek <jakub@redhat.com>
Tue, 5 Mar 2024 09:27:14 +0000 (10:27 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 5 Mar 2024 09:27:14 +0000 (10:27 +0100)
commit9d2bc5def30830e685ae2e3c2f4d07b967e2be63
tree7f083086b754067ead1218d254683fb1df7c725c
parent8ee6d13e32279faf9ef4fd8eabfba0adfca0dfb9
bitint: Handle BIT_FIELD_REF lowering [PR114157]

The following patch adds support for BIT_FIELD_REF lowering with
large/huge _BitInt lhs.  BIT_FIELD_REF requires mode argument first
operand, so the operand shouldn't be any huge _BitInt.
If we only access limbs from inside of BIT_FIELD_REF using constant
indexes, we can just create a new BIT_FIELD_REF to extract the limb,
but if we need to use variable index in a loop, I'm afraid we need
to spill it into memory, which is what the following patch does.
If there is some bitwise type for the extraction, it extracts just
what we need and not more than that, otherwise it spills the whole
first argument of BIT_FIELD_REF and uses MEM_REF with an offset
with VIEW_CONVERT_EXPR around it.

2024-03-05  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/114157
* gimple-lower-bitint.cc: Include stor-layout.h.
(mergeable_op): Return true for BIT_FIELD_REF.
(struct bitint_large_huge): Declare handle_bit_field_ref method.
(bitint_large_huge::handle_bit_field_ref): New method.
(bitint_large_huge::handle_stmt): Use it for BIT_FIELD_REF.

* gcc.dg/bitint-98.c: New test.
* gcc.target/i386/avx2-pr114157.c: New test.
* gcc.target/i386/avx512f-pr114157.c: New test.
gcc/gimple-lower-bitint.cc
gcc/testsuite/gcc.dg/bitint-98.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx2-pr114157.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-pr114157.c [new file with mode: 0644]