I've encountered a rather nasty bug in the Microblaze gcc compiler. This happens with both 2017.4 and 2018.3. I have attached a reduced source code and the command line. The problem is in this snippet:
int bottom = float1 - 3 * float2; int top = float1 + 3 * float2;
if( bottom < 0 ) bottom = 0;
If you check the assembly listing, you'll see at line 109 that it computes "top" into r6, then just before it uses that value, it tries to compare r22 to 0, thinking that it's "bottom", but it never put anything into r22. It forgot to compute "bottom". Indeed, it moved the "fcmp" instruction way up front, before it started these lines.
It's a delicate bug. If I remove the final printf, it no longer occurs. If I cast the floats to (int), it no longer occurs, and that's the workaround I chose (that is, int bottom = (int)float1 - 3 * (int)float2;)