https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94715
Wilco <wilco at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2020-04-23 Ever confirmed|0 |1 Status|RESOLVED |REOPENED Resolution|INVALID |--- --- Comment #2 from Wilco <wilco at gcc dot gnu.org> --- (In reply to Richard Biener from comment #1) > I think GCC is correct in assuming that x * x is positive since overflow > with signed arithmetic is undefined. Thus on GIMPLE we elide > > _1 = x_2(D) * x_2(D); > t_3 = (unsigned int) _1; > _4 = (long long unsigned int) t_3; > > to > > _1 = x_2(D) * x_2(D); > _4 = (long long unsigned int) _1; If we assume x * x is always positive, using unsigned extension would make more sense. It still adds an unnecessary extra instruction on most targets which cannot be removed in RTL.