https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120209
--- Comment #2 from Paul Cercueil <paul at crapouillou dot net> --- > The test case is somewhat bogus. Changing the "-1.0f" to "1.0f" will > generate the "fldi1" instruction for the comparison as well. Yes, I got confused while writing the bug report. The problem is loading the -1.0f constant. > Based on our previous discussion, I guess you'd expect this case to generate > the sequence "fldi1; fneg" to load the constant -1.0, which would be better > in this case. > > > > The compiler also does not seem to understand that fr1 contains -1.0f which > > it can add to fr0 directly, and instead it will load 1.0f with fldi1 this > > time and substract it to fr0. > > That's because there are two constants in your case "-1" and "1". > > If the test case is changed to > > if (x < -2.0f) > x2 *= -2.0f; > > ... then we will see that constants are shared in registers. Well, but I'm doing if (x < -1.0f) x2 += -1.0f; So that's only one constant, -1.0.