https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113487
Bug ID: 113487 Summary: Missed optimization:simplify demanded bits on multi-use instructions like select Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: xxs_chy at outlook dot com Target Milestone: --- Godbolt example: https://godbolt.org/z/EfKrTbK77 Based on common demanded bits from s&8 and s&16, ``` void src(bool c, unsigned a, unsigned b) { unsigned s = c ? a & 24 : b & 25; use(s & 8); use(s & 16); } ``` can be folded to: ``` void tgt(bool c, unsigned a, unsigned b) { unsigned s = c ? a : b ; use(s & 8); use(s & 16); } ``` Both LLVM and GCC missed this optimization opportunity.