https://gcc.gnu.org/g:35a293a6454ac0cd88735036f536d8f4ec65951a
commit r15-785-g35a293a6454ac0cd88735036f536d8f4ec65951a Author: Aldy Hernandez <al...@redhat.com> Date: Wed May 22 22:32:57 2024 +0200 [prange] Use type agnostic range in phiopt [PR115191] Fix a use of int_range_max in phiopt that should be a type agnostic range, because it could be either a pointer or an int. PR tree-optimization/115191 gcc/ChangeLog: * tree-ssa-phiopt.cc (value_replacement): Use Value_Range instead of int_range_max. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr115191.c: New test. Diff: --- gcc/testsuite/gcc.dg/tree-ssa/pr115191.c | 10 ++++++++++ gcc/tree-ssa-phiopt.cc | 5 ++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr115191.c b/gcc/testsuite/gcc.dg/tree-ssa/pr115191.c new file mode 100644 index 00000000000..43f780aa3b8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr115191.c @@ -0,0 +1,10 @@ +// { dg-do compile } +// { dg-options "-O1 -w" } + +typedef void *SCM; +void set_socket_io_ports(); +void STk_socket_accept(SCM line_buffered) { + if (!line_buffered) + line_buffered = (SCM)3; + set_socket_io_ports(line_buffered != 1); +} diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 918cf50b589..65f63eb0652 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -1326,12 +1326,11 @@ value_replacement (basic_block cond_bb, basic_block middle_bb, { /* After the optimization PHI result can have value which it couldn't have previously. */ - int_range_max r; + Value_Range r (TREE_TYPE (phires)); if (get_global_range_query ()->range_of_expr (r, phires, phi)) { - wide_int warg = wi::to_wide (carg); - int_range<2> tmp (TREE_TYPE (carg), warg, warg); + Value_Range tmp (carg, carg); r.union_ (tmp); reset_flow_sensitive_info (phires); set_range_info (phires, r);