https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94234
Bug ID: 94234 Summary: missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1)) Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: fxue at os dot amperecomputing.com Target Milestone: --- CCP could not fold the following expression to a constant "8": size_t foo (char *a, size_t n) { char *b1 = a + 8 * n; char *b2 = a + 8 * (n - 1); return b1 - b2; } But if we change b1 and b2 to integer type, folding happens. size_t foo (char *a, size_t n) { size_t b1 = (size_t)(a + 8 * n); size_t b2 = (size_t)(a + 8 * (n - 1)); return b1 - b2; }