Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
40 user(s) are online (33 user(s) are browsing Forums)

Members: 0
Guests: 40

more...

Support us!

Headlines

 
  Register To Post  

GCC disabling the instructions reordering ?
Not too shy to talk
Not too shy to talk


See User information
I am using an old GCC with optimisation option O2 and I made this code for the Vampire 68080
it have been designed with the pipeline in mind so the two fdiv are computed way before their result is used so fpu "have the time" to make the computation
But gcc reorder it badly so the move using the result is just following the div in the generated ASM

Is there a way to disable the reordering in this specific C function ?

In the code all variables are registers so C and generated ASM should looks like identical

while(dy)
{
fuv=fu;
fuv=fuv/fw; // div here

E->L.x=x;
x= x + dx;
E->L.z=z;
z= z + dz;
E->L.l=l;
l= l + dl;

E->L.fu=fuv; // result used here

fuv=fv;
fuv=fuv/fw; // other div here

fw= fw + fdw;
E->L.fw=fw;
fu= fu + fdu;
fv= fv + fdv;

E->L.fv=fuv; // result used here
E++;
dy--;
}

Go to top
Re: GCC disabling the instructions reordering ?
Just can't stay away
Just can't stay away


See User information
@thellier
Did you try all of the usual options for disabling it, -fno-toplevel-reorder, -fno-reorder-blocks, -fno-reorder-blocks-and-partition and -fno-reorder-functions, already?

If you don't want to disable it globally, or for a complete source file, or even a just a single function using something like
volatile fuv=fu;
volatile fuv=fuv/fw// div here
...
volatile E->L.fu=fuv// result used here

fuv=fv;
volatile fuv=fuv/fw// other div here
...
volatile E->L.fv=fuv// result used here
may help.


Edited by joerg on 2024/12/22 17:14:30
Edited by joerg on 2024/12/22 17:15:50
Go to top
Re: GCC disabling the instructions reordering ?
Not too shy to talk
Not too shy to talk


See User information
Thanks for all that infos

volatile didnt worked as it stored the var in the stack so using the result too early

other options didnt seems to exists in my old gcc for 68k

but I just right here successfully compile it ok by specifying the registers for each variable and using separate registers for fu2 fv2

The result is here 100% perfect:
(I am very pleased when my C is exactly like ASM )

// register struct point3D *P1 __asm("a1");
LBB125:
// register struct point3D *P2 __asm("a2");
// register union FixPoint3D *E __asm("a3");
//
// register LONG x;
// register LONG l;
// register LONG z;
// register LONG dx;
// register LONG dl;
// register LONG dz;
// register LONG dy;
//
// register float fu __asm("fp0");
// register float fv __asm("fp1");
// register float fw __asm("fp2");
// register float fdu __asm("fp3");
// register float fdv __asm("fp4");
// register float fdw __asm("fp5");
// register float fu2 ;
// register float fv2;

[...]
L566:
// while(dy)
// {

// fu2=fu;
// fu2=fu2/fw;
fsmovex fp0,fp7
fsdivx fp2,fp7
// fv2=fv;
// fv2=fv2/fw;
fsmovex fp1,fp6
fsdivx fp2,fp6
//
// E->L.x=x;
movel d2,a3@
// x= x + dx;
addl a5@(-16),d2
// E->L.z=z;
movel d4,a3@(8)
// z= z + dz;
addl a4,d4
// E->L.l=l;
movel a5@(-12),a3@(40)
// l= l + dl;
movel a0,d5
addl d5,a5@(-12)
// E->L.fw=fw;
fmoves fp2,a3@(60)
// fw= fw + fdw;
fsaddx fp5,fp2
// E++;
addw #128,a3
//
// fu= fu + fdu;
fsaddx fp3,fp0
// E[-1].L.fu=fu2;
fmoves fp7,a3@(-76)
// fv= fv + fdv;
fsaddx fp4,fp1
// E[-1].L.fv=fv2;
fmoves fp6,a3@(-72)
//
// dy--;
subql #1,d3
// }
jne L566

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project