https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37242
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org --- Comment #25 from Richard Biener <rguenth at gcc dot gnu.org> --- I think parts of this was fixed with the fix for PR45397 (r245752). I can't really figure if the issue in the benchmark is fixed though. I still see in PRE <bb 3> [local count: 1014686024]: # top_52 = PHI <top_36(D)(2), maxIdx_31(6)> # maxIdx_54 = PHI <maxIdx_47(2), maxIdx_40(6)> _4 = (long unsigned int) maxIdx_54; _5 = _4 * 4; _6 = numbers_37(D) + _5; _7 = *_6; _8 = _4 + 1; _9 = _8 * 4; _10 = numbers_37(D) + _9; _11 = *_10; if (_7 < _11) goto <bb 4>; [50.00%] else goto <bb 5>; [50.00%] <bb 4> [local count: 507343012]: maxIdx_42 = maxIdx_54 + 1; _68 = (long unsigned int) maxIdx_42; _70 = _68 * 4; _72 = numbers_37(D) + _70; pretmp_74 = *_72; suggesting it is not fixed in GCC 8 at least. Same with GCC 9 and trunk. Testcase: unsigned long a, b; void foo (int m, int f) { unsigned long tem = (unsigned long)m; a = tem + 1; if (f) { int tem2 = m + 1; b = (unsigned long)tem2; } } note to value-number the expressions the same you need to apply knowledge that in if (f), m + 1 cannot overflow.