1 // SPDX-License-Identifier: GPL-2.0
11 #include <sys/types.h>
12 #include <sys/select.h>
17 long double __attribute__((noinline)) insn(long flags) \
25 " " #insn " %%st(1), %%st" "\n" \
26 " ffree %%st(1)" "\n" \
48 void sighandler(int sig
)
50 printf("[FAIL]\tGot signal %d, exiting\n", sig
);
54 int main(int argc
, char **argv
, char **envp
)
58 /* SIGILL triggers on 32-bit kernels w/o fcomi emulation
59 * when run with "no387 nofxsr". Other signals are caught
62 signal(SIGILL
, sighandler
);
63 signal(SIGFPE
, sighandler
);
64 signal(SIGSEGV
, sighandler
);
66 printf("[RUN]\tTesting fcmovCC instructions\n");
67 /* If fcmovCC() returns 1.0, the move wasn't done */
68 err
|= !(fcmovb(0) == 1.0); err
|= !(fcmovnb(0) != 1.0);
69 err
|= !(fcmove(0) == 1.0); err
|= !(fcmovne(0) != 1.0);
70 err
|= !(fcmovbe(0) == 1.0); err
|= !(fcmovnbe(0) != 1.0);
71 err
|= !(fcmovu(0) == 1.0); err
|= !(fcmovnu(0) != 1.0);
73 err
|= !(fcmovb(CF
) != 1.0); err
|= !(fcmovnb(CF
) == 1.0);
74 err
|= !(fcmove(CF
) == 1.0); err
|= !(fcmovne(CF
) != 1.0);
75 err
|= !(fcmovbe(CF
) != 1.0); err
|= !(fcmovnbe(CF
) == 1.0);
76 err
|= !(fcmovu(CF
) == 1.0); err
|= !(fcmovnu(CF
) != 1.0);
78 err
|= !(fcmovb(ZF
) == 1.0); err
|= !(fcmovnb(ZF
) != 1.0);
79 err
|= !(fcmove(ZF
) != 1.0); err
|= !(fcmovne(ZF
) == 1.0);
80 err
|= !(fcmovbe(ZF
) != 1.0); err
|= !(fcmovnbe(ZF
) == 1.0);
81 err
|= !(fcmovu(ZF
) == 1.0); err
|= !(fcmovnu(ZF
) != 1.0);
83 err
|= !(fcmovb(PF
) == 1.0); err
|= !(fcmovnb(PF
) != 1.0);
84 err
|= !(fcmove(PF
) == 1.0); err
|= !(fcmovne(PF
) != 1.0);
85 err
|= !(fcmovbe(PF
) == 1.0); err
|= !(fcmovnbe(PF
) != 1.0);
86 err
|= !(fcmovu(PF
) != 1.0); err
|= !(fcmovnu(PF
) == 1.0);
89 printf("[OK]\tfcmovCC\n");
91 printf("[FAIL]\tfcmovCC errors: %d\n", err
);