https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109119
Bug ID: 109119 Summary: missing loading fre with branch comparing two pointers Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` void fun (unsigned *x, unsigned *b) { asm volatile(""::"r"(*x)); unsigned *a = b;//malloc (*x); if (a == 0) return; if (a != x) // (A) *a = *x; *x = *a; } ``` GCC currently produces: <bb 2> [local count: 1073741824]: _1 = *x_6(D); __asm__ __volatile__("" : : "r" _1); if (b_7(D) == 0B) goto <bb 7>; [18.09%] else goto <bb 3>; [81.91%] <bb 3> [local count: 879501929]: if (x_6(D) != b_7(D)) goto <bb 5>; [70.00%] else goto <bb 4>; [30.00%] <bb 4> [local count: 263850576]: pretmp_10 = *b_7(D); goto <bb 6>; [100.00%] <bb 5> [local count: 615651353]: *b_7(D) = _1; <bb 6> [local count: 879501929]: # prephitmp_11 = PHI <pretmp_10(4), _1(5)> *x_6(D) = prephitmp_11; But pretmp_10 should be the same as _1 as at that point b_7 == x_6. Note I noticed this while looking into PR 96564.