Debian Codegraph @

gcc/testsuite/g++.target/i386/pr103973-9.C

raw
1 // PR target/103973
2 // { dg-do run }
3 // { dg-options "-O2 -std=c++20 -save-temps" }
4 // { dg-final { scan-assembler-not "'\t\[v\]?ucomisd" { target { ! ia32 } } } }
5 // { dg-final { scan-assembler-times "\t\[v\]?comisd" 2 { target { ! ia32 } } } }
6
7 #include <compare>
8
9 #ifndef double_type
10 #define double_type double
11 #endif
12
13 __attribute__((noipa)) auto
14 foo (double_type a, double_type b)
15 {
16 return a <=> b;
17 }
18
19 __attribute__((noipa)) int
20 bar (double_type a, double_type b)
21 {
22 auto c = foo (a, b);
23 if (c == std::partial_ordering::less)
24 return -1;
25 if (c == std::partial_ordering::equivalent)
26 return 0;
27 return 1;
28 }
29
30 __attribute__((noipa)) auto
31 baz (double_type a)
32 {
33 return a <=> 0.0f;
34 }
35
36 __attribute__((noipa)) int
37 qux (double_type a)
38 {
39 auto c = baz (a);
40 if (c == std::partial_ordering::less)
41 return -1;
42 if (c == std::partial_ordering::equivalent)
43 return 0;
44 return 1;
45 }
46
47 int
48 main ()
49 {
50 double_type m5 = -5.0;
51 double_type p5 = 5.0;
52 volatile double_type p0 = 0.0;
53 double_type nan = p0 / p0;
54 if (bar (p5, p5) != 0 || bar (m5, m5) != 0)
55 __builtin_abort ();
56 if (bar (m5, p5) != -1 || bar (p5, m5) != 1)
57 __builtin_abort ();
58 if (bar (m5, nan) != 1 || bar (nan, p5) != 1)
59 __builtin_abort ();
60 if (bar (nan, nan) != 1)
61 __builtin_abort ();
62 if (qux (p0) != 0 || qux (nan) != 1)
63 __builtin_abort ();
64 if (qux (m5) != -1 || qux (p5) != 1)
65 __builtin_abort ();
66 return 0;
67 }