https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120331
Bug ID: 120331 Summary: useless NON_LVALUE not fully elided by genmatch generated code Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: internal-improvement, missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` void g(); void f(int maxlen) { maxlen = maxlen > 264 ? 264 : maxlen; if (maxlen > 16) g(); } ``` We end up with: ``` Matching expression match.pd:197, gimple-match-6.cc:22 Matching expression match.pd:181, gimple-match-7.cc:45 Matching expression match.pd:181, gimple-match-7.cc:45 Matching expression match.pd:199, gimple-match-6.cc:54 Applying pattern match.pd:1690, gimple-match-3.cc:18989 Applying pattern match.pd:4777, gimple-match-6.cc:5116 gimple_simplified to _6 = maxlen_2(D) > 16; _1 = _6; ``` This comes from: ``` /* x & ~0 -> x */ (simplify (bit_and @0 integer_all_onesp) (non_lvalue @0)) ``` pattern. The non_lvalue here is useless for gimple. I noticed this while working on PR 120206 .