Handle constant CONSTRUCTORs in operand_compare
commit0f02e744ca1ea3256f912dbeb965ead3b5c9f66f
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 10 Nov 2023 17:59:31 +0000 (10 18:59 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Fri, 10 Nov 2023 18:01:45 +0000 (10 19:01 +0100)
tree9f335a55fb91dc8ca5fe890840a3a554883746db
parentdf66fa08578a28b3acc8bdb6257b68c245a6a0fa
Handle constant CONSTRUCTORs in operand_compare

This teaches operand_compare to compare constant CONSTRUCTORs, which is
quite helpful for so-called fat pointers in Ada, i.e. objects that are
semantically pointers but are represented by structures made up of two
pointers.  This is modeled on the implementation present in the ICF pass.

gcc/
* fold-const.cc (operand_compare::operand_equal_p) <CONSTRUCTOR>:
Deal with nonempty constant CONSTRUCTORs.
(operand_compare::hash_operand) <CONSTRUCTOR>: Hash DECL_FIELD_OFFSET
and DECL_FIELD_BIT_OFFSET for FIELD_DECLs.

gcc/testsuite/
* gnat.dg/opt103.ads, gnat.dg/opt103.adb: New test.
gcc/fold-const.cc
gcc/testsuite/gnat.dg/opt103.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/opt103.ads [new file with mode: 0644]