> gcc/ChangeLog: > > 2025-02-24 Martin Jambor <mjam...@suse.cz> > > PR ipa/118785 > > * ipa-cp.cc (ipa_vr_intersect_with_arith_jfunc): Handle non-conversion > unary operations separately before doing any conversions. Check > expr_type_first_operand_type_p for non-unary operations too. Fix type > of op_res. > > gcc/testsuite/ChangeLog: > > 2025-02-24 Martin Jambor <mjam...@suse.cz> > > PR ipa/118785 > * g++.dg/lto/pr118785_0.C: New test. > --- > gcc/ipa-cp.cc | 34 ++++++++++++++++++++++++--- > gcc/testsuite/g++.dg/lto/pr118785_0.C | 14 +++++++++++ > 2 files changed, 45 insertions(+), 3 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/lto/pr118785_0.C > > diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc > index 68959f2677b..0dd65a707b6 100644 > --- a/gcc/ipa-cp.cc > +++ b/gcc/ipa-cp.cc > @@ -1720,8 +1720,34 @@ ipa_vr_intersect_with_arith_jfunc (vrange &vr, > enum tree_code operation = ipa_get_jf_pass_through_operation (jfunc); > if (TREE_CODE_CLASS (operation) == tcc_unary) > { > + value_range op_res; > + const value_range *inter_vr; > + if (operation != NOP_EXPR) > + { > + tree operation_type; > + if (expr_type_first_operand_type_p (operation)) > + operation_type = src_type; > + else if (operation == ABSU_EXPR) > + operation_type = unsigned_type_for (src_type); > + else > + return;
I would say this is fine for stage4, but I think we should add comment explaining why this somewhat ugly logic is here and how to fix it later. Patch is OK with this change. Thanks, Honza