* gcc.target/i386/pr70021.c: Add -mtune=skylake.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / mmx-8.c
blobc90083babb57ce448df220896667c600be5951c6
1 /* PR middle-end/37809 */
3 /* { dg-do run } */
4 /* { dg-options "-O2 -mmmx" } */
6 #include <mmintrin.h>
8 #include "mmx-check.h"
10 // Various tests of cases where it is incorrect to optimise vectors as if they
11 // were integers of the same width.
13 extern void abort (void);
15 void __attribute__ ((noinline))
16 Sshift()
18 volatile __m64 y = (__m64) 0xffffffffll;
19 __m64 x = y & (__m64) 0xffffffffll;
20 x = _m_psradi (x, 1);
21 x &= (__m64) 0x80000000ll;
22 if (0 == (long long) x)
23 abort();
26 #define SHIFTU(F,B,S,T) \
27 void F() \
28 { \
29 volatile __m64 y = (__m64) 0ll; \
30 __m64 x = y | (__m64) (1llu << B); \
31 if (S > 0) \
32 x = _m_pslldi (x, S); \
33 else \
34 x = _m_psrldi (x, -S); \
35 if (T > 0) \
36 x = _m_pslldi (x, T); \
37 else \
38 x = _m_psrldi (x, -T); \
39 x &= (__m64) (1llu << (B + S + T)); \
40 if ((long long) x) \
41 abort(); \
44 SHIFTU (shiftU1, 31, 1, -1)
45 SHIFTU (shiftU2, 32, -1, 1)
46 SHIFTU (shiftU3, 31, 1, 0)
47 SHIFTU (shiftU4, 32, -1, 0)
49 void __attribute__ ((noinline))
50 add_1()
52 volatile long long ONE = 1;
53 long long one = ONE;
55 __m64 a = (__m64) one;
56 __m64 b = (__m64) -one;
57 __m64 c = a + b;
58 if (0 == (long long) c)
59 abort();
62 void __attribute__ ((noinline))
63 add_2()
65 volatile long long ONE = 1;
66 long long one = ONE;
68 __m64 a = (__m64) one;
69 __m64 b = (__m64) -one;
70 __m64 c = _m_paddd (a, b);
71 if (0 == (long long) c)
72 abort();
75 void __attribute__ ((noinline))
76 mult_1()
78 volatile __m64 y = (__m64) 0ll;
79 __m64 x = y | (__m64) (1ll << 32);
80 x = x * (__m64) 1ll;
81 x &= (__m64) (1ll << 32);
82 if (0 != (long long) x)
83 abort();
86 void __attribute__ ((noinline))
87 mult_2()
89 volatile int foo = 1;
90 unsigned long long one = foo & 1;
92 __m64 x = (__m64) (one << 16);
93 x *= x;
94 x &= (__m64) (1ll << 32);
95 if (0 != (long long) x)
96 abort();
99 void __attribute__ ((noinline))
100 mult_3()
102 volatile __m64 y = (__m64) (1ll << 32);
103 __m64 a = y;
104 __m64 b = y * (__m64) 1ll;
105 if (((long long) a) == (long long) b)
106 abort();
109 void __attribute__ ((noinline))
110 div_1()
112 volatile __m64 y = (__m64) 0ll;
113 __m64 x = y | (__m64) (1ull << 32);
114 x |= (__m64) 1ull;
115 x = x / x;
116 if (1ll == (long long) x)
117 abort();
121 void mmx_test (void)
123 Sshift();
124 shiftU1();
125 shiftU2();
126 shiftU3();
127 shiftU4();
129 add_1();
130 add_2();
132 mult_1();
133 mult_2();
134 mult_3();
136 div_1();