https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114853
Bug ID: 114853 Summary: Inefficient code with a bunch of bitwise checks Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gh228df at gmail dot com Target Milestone: --- Here is a compiler explorer link https://godbolt.org/z/WccxhnTfK, the first function is 'inefficient' while the second function does the same while having 1/2 assembly lines of the first function and will probably run faster in some cases. The problem is that the compiler doesnt generate negated constant once in the start but rather keeps generating it over and over again before every check which is very inefficient