https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93006
Bug ID: 93006 Summary: Better code with a-- == 0 rather than --a == -1 Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- unsigned int a; unsigned foo (unsigned b, unsigned c) { return b + c + (--a == -1); } unsigned bar (unsigned b, unsigned c) { return b + c + (a-- == 0); } unsigned baz (unsigned b, unsigned c) { return b + c + (--a != -1); } unsigned qux (unsigned b, unsigned c) { return b + c + (a-- != 0); } where foo is equivalent to bar and baz to qux generates better code (just 6 instructions) in bar/qux and 9 in foo/baz on x86_64-linux.