Hi.

operand_equal_p can properly handle situation where we have a CONSTRUCTOR
where indices are NULL:

              if (!operand_equal_p (c0->value, c1->value, flags)
                  /* In GIMPLE the indexes can be either NULL or matching i.
                     Double check this so we won't get false
                     positives for GENERIC.  */
                  || (c0->index
                      && (TREE_CODE (c0->index) != INTEGER_CST 
                          || compare_tree_int (c0->index, i)))
                  || (c1->index
                      && (TREE_CODE (c1->index) != INTEGER_CST 
                          || compare_tree_int (c1->index, i))))
                return false;

but the corresponding hash function always hashes field (which
can be NULL_TREE or equal to ctor index).

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

2019-10-31  Martin Liska  <mli...@suse.cz>

        PR ipa/92304
        * fold-const.c (operand_compare::hash_operand): Fix field
        hashing of CONSTRUCTOR.
---
 gcc/fold-const.c | 3 +++
 1 file changed, 3 insertions(+)


diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index fce503692fd..1e25859a707 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -3659,6 +3659,9 @@ operand_compare::hash_operand (const_tree t, inchash::hash &hstate,
 	flags &= ~OEP_ADDRESS_OF;
 	FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t), idx, field, value)
 	  {
+	    /* In GIMPLE the indexes can be either NULL or matching i.  */
+	    if (field == NULL_TREE)
+	      field = bitsize_int (idx);
 	    hash_operand (field, hstate, flags);
 	    hash_operand (value, hstate, flags);
 	  }

Reply via email to