https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111718
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Keywords| |missed-optimization Last reconfirmed| |2023-10-08 --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #3) > For comment #2 from EVRP: > Folding statement: _3 = _2 / a_5(D); > Applying pattern match.pd:934, gimple-match-4.cc:2021 > gimple_simplified to _3 = 2; > > Which corresponds to the match pattern: > /* Simplify (t * 2) / 2) -> t. */ > (for div (trunc_div ceil_div floor_div round_div exact_div) > (simplify > (div (mult:c @0 @1) @1) > (if (ANY_INTEGRAL_TYPE_P (type)) > (if (TYPE_OVERFLOW_UNDEFINED (type)) > @0 > #if GIMPLE > (with {value_range vr0, vr1;} > (if (INTEGRAL_TYPE_P (type) > && get_range_query (cfun)->range_of_expr (vr0, @0) > && get_range_query (cfun)->range_of_expr (vr1, @1) > && range_op_handler (MULT_EXPR).overflow_free_p (vr0, vr1)) > @0)) > #endif > )))) Which was improved on the trunk by r14-4082-g55b22a6f630e (and then by r14-4191-gd946fc1c71bd). I don't know why the original testcase is not causing the above pattern to match though, maybe because a*2 is used twice ...