https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118994
Bug ID: 118994 Summary: GCC fails to optimize (a >> 1) + (b >> 1) + ((a | b) & 1) to PAVGB/PAVGW (or equivalent instruction) Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: john_platts at hotmail dot com Target Milestone: --- SSE2 PAVGB/PAVGW, NEON/SVE2 SRHADD/URHADD, AltiVec vavgsb/vavgsh/vavgsw/vavgub/vavguh/vavguw, and LSX/LASX vavgr is equivalent to the following expression for each lane of an integer vector: (a >> 1) + (b >> 1) + ((a | b) & 1) A snippet that shows that GCC fails to optimize the above expression down to PAVGB/PAVGW (or an equivalent instruction) where supported on the target can be found at https://godbolt.org/z/4o6c5e1hj.