[Bug tree-optimization/110204] [14 Regression] Suspicous warning when compiling ranges-v3 using GCC trunk (iteration 9223372036854775807 invokes undefined behavior)
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jul 17 09:55:53 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110204
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Yeah, the issue is that PRE figures out a new value here but we've already done
value-numbering so we can't alter the "old" solution here. So what we do
is add a '0' with value '_42' (instead of value '0'). This "second order"
value numbering leaves more opportunities on the plate. It was IMHO
cleaner to insert a
pretmp_163 = 0;
than substituting '0' everywhere but then leaving around the third order
optimizations in case we had _42 + 1 that would then simplify to sth = 1 ...
Previously we'd have inserted a degenerate PHI, now we get these kind of
copies. "Now" is for a long time so this isn't new for PRE at least.
We could "hack" this by doing
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index 11061a374a2..effb4f4de73 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -6615,6 +6615,13 @@ eliminate_dom_walker::eliminate_push_avail (basic_block,
tree op)
if (avail[SSA_NAME_VERSION (valnum)])
pushop = avail[SSA_NAME_VERSION (valnum)];
avail_stack.safe_push (pushop);
+ if (gassign *ass = dyn_cast <gassign *> (SSA_NAME_DEF_STMT (op)))
+ if (gimple_assign_rhs_class (ass) == GIMPLE_SINGLE_RHS)
+ {
+ tree rhs1 = gimple_assign_rhs1 (ass);
+ if (CONSTANT_CLASS_P (rhs1) || TREE_CODE (rhs1) == SSA_NAME)
+ op = rhs1;
+ }
avail[SSA_NAME_VERSION (valnum)] = op;
}
}
More information about the Gcc-bugs
mailing list