https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80399
Bug ID: 80399 Summary: Premature optimization with unsigned Product: gcc Version: 7.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take the following two functions: unsigned f(unsigned t) { t = (t - 1)*16; t = t/16; return t; } unsigned g(unsigned t) { t = t - 1; t = t*16; t = t/16; return t; } They should produce the same code but they don't. On aarch64 for an example we produce: f: mov w1, 268435455 add w0, w0, w1 and w0, w0, w1 ret .... g: sub w0, w0, #1 and w0, w0, 268435455 ret g is better than f here since we have only one dependent instruction instead of 2.