https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121710
Bug ID: 121710 Summary: `a - b == nonzero` implies that `a != b` Product: gcc Version: 16.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Blocks: 85316, 116651 Target Milestone: --- Extracted from PR 116651. ``` void link_error(); void f(int a, int b, int *c) { int t = b - a; if (t == 16) { if (b == a) { link_error(); } } } void f2(int a, int b, int *c) { int t = b - a; if (b == a) { if (t == 16) { link_error(); } } } void f3(int a, int b, int *c) { if (b == a) { int t = b - a; if (t == 16) { link_error(); } } } void fp(int *a, int *b, int *c) { auto t = b - a; if (t == 1) { if (b == a) { link_error(); } } } void fp1(int *a, int *b, int *c) { if (b == a) { auto t = b - a; if (t == 1) { link_error(); } } } ``` These all should simplify down to just a return. Currently only fp1 and f3 do. LLVM does not handle fp1 nor fp. fp shows up in PR 116651. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316 [Bug 85316] [meta-bug] VRP range propagation missed cases https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116651 [Bug 116651] vector::operator== on a newly created single element vector is not that good