Debian Codegraph @

gcc/testsuite/gcc.target/i386/avx-pr99563.c

raw
1 /* PR target/99563 */
2 /* { dg-do run { target avx } } */
3 /* { dg-options "-O2 -mavx -mno-vzeroupper" } */
4
5 #include "avx-check.h"
6 #include <immintrin.h>
7
8
9 __attribute__((noipa)) float
10 compute_generic (void)
11 {
12 return 0.0f;
13 }
14
15 static inline __attribute__((always_inline))
16 float compute_avx (unsigned long block_count)
17 {
18 __m128d mm_res = _mm_set1_pd (256.0);
19 float res = (float) (_mm_cvtsd_f64 (mm_res) / (double) block_count);
20 _mm256_zeroupper ();
21 return res;
22 }
23
24 __attribute__((noipa)) float
25 compute (unsigned long block_count)
26 {
27 if (block_count >= 64)
28 return compute_avx (block_count);
29 else
30 return compute_generic ();
31 }
32
33 static void
34 avx_test (void)
35 {
36 if (compute (128) != 2.0f || compute (32) != 0.0f)
37 abort ();
38 }