This testcase: double t (double a, double b) { return fmod (a, b); }
generates wrong code when compiled with -O2 -funroll-all-loops (-ffast-math -fomit-frame-pointer is used here only for clarity): : fldl 4(%esp) fldl 12(%esp) fxch %st(1) .L2: fprem fnstsw %ax sahf jnp .L22 fprem fnstsw %ax sahf jnp .L22 fprem jnp .L22 fprem .p2align 4,,2 jnp .L22 fprem .p2align 4,,5 jnp .L22 fprem .p2align 4,,5 jnp .L22 fprem .p2align 4,,5 jnp .L22 fprem .p2align 4,,5 jp .L2 .p2align 4,,7 .L22: fstp %st(1) .p2align 4,,5 ret Please note that from second iteration,fnstsw %ax and sahf are not present anymore in the instruction stream. The problem starts in .159r.postreload RTL dump, where missing instructions just vanish without NOTE_INSN_DELETED trace from RTL insn stream, although they are still present in 158r.greg dump. -- Summary: Problem with -funroll-all-loops Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ubizjak at gmail dot com GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31101