Debian Codegraph @

gcc/testsuite/g++.target/i386/pr103973-13.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 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::greater)
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 double_type p0 = 0.0;
53 if (bar (p5, p5) != 0 || bar (m5, m5) != 0)
54 __builtin_abort ();
55 if (bar (m5, p5) != -1 || bar (p5, m5) != 1)
56 __builtin_abort ();
57 if (qux (p0) != 0)
58 __builtin_abort ();
59 if (qux (m5) != -1 || qux (p5) != 1)
60 __builtin_abort ();
61 return 0;
62 }