fold-const: Ignore padding bits in native_interpret_expr REAL_CST reverse verificatio...
authorJakub Jelinek <jakub@redhat.com>
Thu, 2 Mar 2023 08:27:40 +0000 (09:27 +0100)
committerJakub Jelinek <jakub@redhat.com>
Thu, 2 Mar 2023 08:27:40 +0000 (09:27 +0100)
commitcc88366a80e35b3e53141f49d3071010ff3c2ef8
tree6bddb8b53d18f50e77dd6b050dfe0a2d0dcf1204
parentf0ef740d54f47ff614eb02e13e8f4cb11dfbb140
fold-const: Ignore padding bits in native_interpret_expr REAL_CST reverse verification [PR108934]

In the following testcase we try to std::bit_cast a (pair of) integral
value(s) which has some non-zero bits in the place of x86 long double
(for 64-bit 16 byte type with 10 bytes actually loaded/stored by hw,
for 32-bit 12 byte) and starting with my PR104522 change we reject that
as native_interpret_expr fails on it.  The PR104522 change extends what
has been done before for MODE_COMPOSITE_P (but those don't have any padding
bits) to all floating point types, because e.g. the exact x86 long double
has various bit combinations we don't support, like
pseudo-(denormals,infinities,NaNs) or unnormals.  The HW handles some of
those as exceptional cases and others similarly to the non-pseudo ones.
But for the padding bits it actually doesn't load/store those bits at all,
it loads/stores 10 bytes.  So, I think we should exempt the padding bits
from the reverse comparison (the native_encode_expr bits for the padding
will be all zeros), which the following patch does.  For bit_cast it is
similar to e.g. ignoring padding bits if the destination is a structure
which has padding bits in there.

The change changed auto-init-4.c to how it has been behaving before the
PR105259 change, where some more VCEs can be now done.

2023-03-02  Jakub Jelinek  <jakub@redhat.com>

PR c++/108934
* fold-const.cc (native_interpret_expr) <case REAL_CST>: Before memcmp
comparison copy the bytes from ptr to a temporary buffer and clearing
padding bits in there.

* gcc.target/i386/auto-init-4.c: Revert PR105259 change.
* g++.target/i386/pr108934.C: New test.
gcc/fold-const.cc
gcc/testsuite/g++.target/i386/pr108934.C [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/auto-init-4.c