https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88784
Bug ID: 88784 Summary: Middle end is missing some optimizations about unsigned Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: helijia at gcc dot gnu.org Target Milestone: --- For both operands are unsigned, the following optimizations are valid, and missing: 1. X > Y && X != 0 --> X > Y 2. X > Y || X != 0 --> X != 0 3. X <= Y || X != 0 --> true 4. X <= Y || X == 0 --> X <= Y 5. X > Y && X == 0 --> false unsigned foo(unsigned x, unsigned y) { return x > y && x != 0; } should fold to x > y, but I found we haven't done it right now. I compile the code with the following command. g++ unsigned.cpp -Ofast -c -S -o unsigned.s -fdump-tree-all