On Sat, Aug 21, 2021 at 09:40:16PM +0200, Stefan Kanthak wrote: > > I believe your example doesn't take into account that the values can be NaN > > which compares false in all situations. > > That's a misbelief! > Please notice the first if-clause, which rules out NaNs for both arguments. > Also notice that GCC did NOT generate JP after the 4 COMISD instructions > in question, i.e. it knew that NaNs had been ruled out.
GCC doesn't do value range propagation of floating point values, not even the special ones like NaNs, infinities, +/- zeros etc., and without that the earlier ifs aren't taken into account for the earlier code. Also, as you have been told already, sending these mails to gcc mailing list is a very bad idea, unless somebody jumps on it immediately and implements it, they will be effectively forgotten. You should file missed optimizations into gcc bugzilla where they can be seen any time. Jakub