https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120209
Bug ID: 120209 Summary: [SH] Float constant 1.0 is loaded from constant pool Product: gcc Version: 15.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: paul at crapouillou dot net Target Milestone: --- With the following code compiled at -Os: float sh4_floorf(float x) { float x2 = (float)(int)x; if (x < -1.0f) x2 += -1.0f; return x2; } GCC generates: _sh4_floorf: mova .L6,r0 fmov.s @r0+,fr1 ftrc fr5,fpul fcmp/gt fr5,fr1 bf/s .L5 float fpul,fr0 fldi1 fr1 fsub fr1,fr0 .L5: rts nop .L6: .long -1082130432 Notice how the 1.0f constant is loaded from .L6 using mova + fmov.s, while it could be loaded using fldi1 directly. 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.