The following avoids re-doing an earlier CSE when trying to handle
a BIT_FIELD_REF as memory reference by combining it with a
defining load. This might (as in this case) result in double-insertion
to the VN hashtables which rightfully ICEs.
PR tree-optimization/125553
* tree-ssa-sccvn.cc (visit_nary_op): Valueize the BIT_FIELD_REF
operand before looking at its definition.
* gcc.dg/torture/pr125553.c: New testcase.
--- /dev/null
+/* { dg-do compile } */
+
+#include <stdint.h>
+
+typedef int64_t v8i64 __attribute__((vector_size(64)));
+int64_t g2, g17;
+void *g24;
+static v8i64 g25;
+
+void hash()
+{
+ v8i64 vec6;
+lbl_b3:
+ *(v8i64 *)g24 = g25;
+ uint64_t __ov_tmp_g17 = __builtin_sub_overflow(g2, g2, &__ov_tmp_g17);
+ g17 = __ov_tmp_g17;
+ g25 = vec6;
+ vec6 = *(v8i64 *)g24;
+ g2 = vec6[0];
+ goto lbl_b3;
+ g25[7];
+}
case BIT_FIELD_REF:
if (TREE_CODE (TREE_OPERAND (rhs1, 0)) == SSA_NAME)
{
- tree op0 = TREE_OPERAND (rhs1, 0);
- gassign *ass = dyn_cast <gassign *> (SSA_NAME_DEF_STMT (op0));
- if (ass
+ tree op0 = vn_valueize (TREE_OPERAND (rhs1, 0));
+ gassign *ass;
+ if (TREE_CODE (op0) == SSA_NAME
+ && (ass = dyn_cast <gassign *> (SSA_NAME_DEF_STMT (op0)))
&& !gimple_has_volatile_ops (ass)
&& vn_get_stmt_kind (ass) == VN_REFERENCE)
{