[PATCH] proposed fix for PR40987 if-conversion bug on HWI32 hosts

Mikael Pettersson mikpe@it.uu.se
Sat Sep 26 11:16:00 GMT 2009


Eric Botcazou writes:
 > > I do suspect that some optimizations can be salvaged. To do
 > > that someone has to go through every single computation, test,
 > > and code-generation sequence (and there are quite a few) and
 > > review them for the "sizeof(dst) > sizeof(hwi)" case, and
 > > either keep them as-is if they're safe, or disable them with
 > > additional checks if they're unsafe.
 > 
 > Note that there is already such a test in the code:
 > 
 >       /* Make sure we can represent the difference between the two values.  */
 >       if ((itrue - ifalse > 0)
 > 	  != ((ifalse < 0) != (itrue < 0) ? ifalse < 0 : ifalse < itrue))
 > 	return FALSE;
 > 
 > Is it tight enough in this case?

It's not tight enough, otherwise it would have prevented the bug
in the PR because this test dominates the actual transformation
parts of this function.

(And there is no validation of itrue/ifalse before this test,
so that subtraction can get a signed overflow.)



More information about the Gcc-patches mailing list