Debian Codegraph @

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

raw
1 // PR target/103973
2 // { dg-do run }
3 // { dg-options "-O2 -ffast-math -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 if (c == std::partial_ordering::greater)
28 return 1;
29 return 2;
30 }
31
32 __attribute__((noipa)) auto
33 baz (double_type a)
34 {
35 return a <=> 0.0f;
36 }
37
38 __attribute__((noipa)) int
39 qux (double_type a)
40 {
41 auto c = baz (a);
42 if (c == std::partial_ordering::less)
43 return -1;
44 if (c == std::partial_ordering::equivalent)
45 return 0;
46 if (c == std::partial_ordering::greater)
47 return 1;
48 return 2;
49 }
50
51 int
52 main ()
53 {
54 double_type m5 = -5.0;
55 double_type p5 = 5.0;
56 double_type p0 = 0.0;
57 if (bar (p5, p5) != 0 || bar (m5, m5) != 0)
58 __builtin_abort ();
59 if (bar (m5, p5) != -1 || bar (p5, m5) != 1)
60 __builtin_abort ();
61 if (qux (p0) != 0)
62 __builtin_abort ();
63 if (qux (m5) != -1 || qux (p5) != 1)
64 __builtin_abort ();
65 return 0;
66 }