Merge tag 'qemu-macppc-20230206' of https://github.com/mcayland/qemu into staging
[qemu.git] / tests / tcg / i386 / test-i386-fisttp.c
blob16af59a7749f6dfa3f149b73b390dc4a39351a0b
1 /* Test fisttpl and fisttpll instructions. */
3 #include <stdint.h>
4 #include <stdio.h>
5 #include <string.h>
7 union u {
8 struct { uint64_t sig; uint16_t sign_exp; } s;
9 long double ld;
12 volatile union u ld_invalid_1 = { .s = { 1, 1234 } };
14 int main(void)
16 int ret = 0;
17 int32_t res_32;
18 int64_t res_64;
19 __asm__ volatile ("fisttpl %0" : "=m" (res_32) : "t" (0x1p100L) : "st");
20 if (res_32 != INT32_MIN) {
21 printf("FAIL: fisttpl 0x1p100\n");
22 ret = 1;
24 __asm__ volatile ("fisttpl %0" : "=m" (res_32) : "t" (-0x1p100L) : "st");
25 if (res_32 != INT32_MIN) {
26 printf("FAIL: fisttpl -0x1p100\n");
27 ret = 1;
29 __asm__ volatile ("fisttpl %0" : "=m" (res_32) : "t" (__builtin_infl()) :
30 "st");
31 if (res_32 != INT32_MIN) {
32 printf("FAIL: fisttpl inf\n");
33 ret = 1;
35 __asm__ volatile ("fisttpl %0" : "=m" (res_32) : "t" (-__builtin_infl()) :
36 "st");
37 if (res_32 != INT32_MIN) {
38 printf("FAIL: fisttpl -inf\n");
39 ret = 1;
41 __asm__ volatile ("fisttpl %0" : "=m" (res_32) : "t" (__builtin_nanl("")) :
42 "st");
43 if (res_32 != INT32_MIN) {
44 printf("FAIL: fisttpl nan\n");
45 ret = 1;
47 __asm__ volatile ("fisttpl %0" : "=m" (res_32) :
48 "t" (-__builtin_nanl("")) : "st");
49 if (res_32 != INT32_MIN) {
50 printf("FAIL: fisttpl -nan\n");
51 ret = 1;
53 __asm__ volatile ("fisttpl %0" : "=m" (res_32) : "t" (ld_invalid_1.ld) :
54 "st");
55 if (res_32 != INT32_MIN) {
56 printf("FAIL: fisttpl invalid\n");
57 ret = 1;
59 __asm__ volatile ("fisttpll %0" : "=m" (res_64) : "t" (0x1p100L) : "st");
60 if (res_64 != INT64_MIN) {
61 printf("FAIL: fisttpll 0x1p100\n");
62 ret = 1;
64 __asm__ volatile ("fisttpll %0" : "=m" (res_64) : "t" (-0x1p100L) : "st");
65 if (res_64 != INT64_MIN) {
66 printf("FAIL: fisttpll -0x1p100\n");
67 ret = 1;
69 __asm__ volatile ("fisttpll %0" : "=m" (res_64) : "t" (__builtin_infl()) :
70 "st");
71 if (res_64 != INT64_MIN) {
72 printf("FAIL: fisttpll inf\n");
73 ret = 1;
75 __asm__ volatile ("fisttpll %0" : "=m" (res_64) : "t" (-__builtin_infl()) :
76 "st");
77 if (res_64 != INT64_MIN) {
78 printf("FAIL: fisttpll -inf\n");
79 ret = 1;
81 __asm__ volatile ("fisttpll %0" : "=m" (res_64) :
82 "t" (__builtin_nanl("")) : "st");
83 if (res_64 != INT64_MIN) {
84 printf("FAIL: fisttpll nan\n");
85 ret = 1;
87 __asm__ volatile ("fisttpll %0" : "=m" (res_64) :
88 "t" (-__builtin_nanl("")) : "st");
89 if (res_64 != INT64_MIN) {
90 printf("FAIL: fisttpll -nan\n");
91 ret = 1;
93 __asm__ volatile ("fisttpll %0" : "=m" (res_64) : "t" (ld_invalid_1.ld) :
94 "st");
95 if (res_64 != INT64_MIN) {
96 printf("FAIL: fisttpll invalid\n");
97 ret = 1;
99 return ret;