https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117601
Bug ID: 117601 Summary: Another missing optimization after rewrite of SCCP for overflow Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: missed-optimization, TREE Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- >From looking at PR 117572, after a quick hack to match to do simple reassociation with respect to pointer addition/minus, there is still some stuff to optimize: ``` _386 = (sizetype) &o; _390 = _386 + 2; h_391 = (char *) _390; h_392 = h_391 + 1; _394 = h_392 - &o; _395 = (int) _394; ``` Seems like h_391 could be optimized to just: `&o p+ 2 ` . Which means _395 is just 3. That is this: ``` typedef __SIZE_TYPE__ size_t; extern char o[3]; int f(void) { size_t t = (size_t)&o[0]; t += 2; char *t1 = (char*)t; t1 += 1; return t1 - &o[0]; } ``` Which does get optimized to 3 at the RTL level