tree-optimization/125553 - ICE with VN trick
Checks
Commit Message
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.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
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.
---
gcc/testsuite/gcc.dg/torture/pr125553.c | 22 ++++++++++++++++++++++
gcc/tree-ssa-sccvn.cc | 7 ++++---
2 files changed, 26 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr125553.c
new file mode 100644
@@ -0,0 +1,22 @@
+/* { 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];
+}
@@ -5778,9 +5778,10 @@ visit_nary_op (tree lhs, gassign *stmt)
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)
{