diff options
author | Richard Biener <rguenther@suse.de> | 2025-08-12 09:00:48 +0200 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2025-08-12 10:19:46 +0200 |
commit | a440b382e43203857de9195eb526c4a16f21ceb1 (patch) | |
tree | 3777397e20e27509a8e713787968e1cade9a852e | |
parent | 2fe432175ef135037dea210002881a093f328779 (diff) | |
download | gcc-a440b382e43203857de9195eb526c4a16f21ceb1.zip gcc-a440b382e43203857de9195eb526c4a16f21ceb1.tar.gz gcc-a440b382e43203857de9195eb526c4a16f21ceb1.tar.bz2 |
tree-optimization/121514 - ICE with recent VN improvement
When inserting a compensation stmt during VN we are making sure to
register the result for the original stmt into the hashtable so
VN iteration has the chance to converge and we avoid inserting
another copy each time. But the implementation doesn't work for
non-SSA name values, and is also not necessary for constants since
we did not insert anything for them. The following appropriately
guards the calls to vn_nary_op_insert_stmt as was already done
in one place.
PR tree-optimization/121514
* tree-ssa-sccvn.cc (visit_nary_op): Only call
vn_nary_op_insert_stmt for SSA name result.
* gcc.dg/torture/pr121514.c: New testcase.
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr121514.c | 20 | ||||
-rw-r--r-- | gcc/tree-ssa-sccvn.cc | 12 |
2 files changed, 28 insertions, 4 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/pr121514.c b/gcc/testsuite/gcc.dg/torture/pr121514.c new file mode 100644 index 0000000..95b7a0b --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr121514.c @@ -0,0 +1,20 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-additional-options "-Wno-psabi" } */ + +typedef unsigned U __attribute__((__vector_size__(64))); +typedef char V __attribute__((vector_size(64))); +typedef __int128 W __attribute__((vector_size(64))); +char c; +int i; +U u; +V v; +W w; + +W +foo() +{ + u = 0 <= u; + __builtin_mul_overflow(i, c, &u[7]); + v ^= (V)u; + return (W)u + w; +} diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 0f6760d..3884f0f 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -5593,7 +5593,8 @@ visit_nary_op (tree lhs, gassign *stmt) if (result) { bool changed = set_ssa_val_to (lhs, result); - vn_nary_op_insert_stmt (stmt, result); + if (TREE_CODE (result) == SSA_NAME) + vn_nary_op_insert_stmt (stmt, result); return changed; } } @@ -5609,7 +5610,8 @@ visit_nary_op (tree lhs, gassign *stmt) if (result) { bool changed = set_ssa_val_to (lhs, result); - vn_nary_op_insert_stmt (stmt, result); + if (TREE_CODE (result) == SSA_NAME) + vn_nary_op_insert_stmt (stmt, result); return changed; } } @@ -5689,7 +5691,8 @@ visit_nary_op (tree lhs, gassign *stmt) if (result) { bool changed = set_ssa_val_to (lhs, result); - vn_nary_op_insert_stmt (stmt, result); + if (TREE_CODE (result) == SSA_NAME) + vn_nary_op_insert_stmt (stmt, result); return changed; } } @@ -5727,7 +5730,8 @@ visit_nary_op (tree lhs, gassign *stmt) if (result) { bool changed = set_ssa_val_to (lhs, result); - vn_nary_op_insert_stmt (stmt, result); + if (TREE_CODE (result) == SSA_NAME) + vn_nary_op_insert_stmt (stmt, result); return changed; } } |