match.pd: Replace incorrect simplifications into copysign [PR90248]
[gcc.git] / gcc / testsuite / gcc.dg / pr90248.c
1 /* PR tree-optimization/90248 */
2 /* { dg-do run } */
3 /* { dg-options "-Ofast" } */
4
5 volatile float b1 = -1.f;
6 volatile float b2 = 0.f;
7
8 __attribute__((noipa)) float
9 f1 (float x)
10 {
11 return x > 0 ? 1.f : -1.f;
12 }
13
14 __attribute__((noipa)) float
15 f2 (float x)
16 {
17 return x >= 0 ? 1.f : -1.f;
18 }
19
20 __attribute__((noipa)) float
21 f3 (float x)
22 {
23 return x < 0 ? 1.f : -1.f;
24 }
25
26 __attribute__((noipa)) float
27 f4 (float x)
28 {
29 return x <= 0 ? 1.f : -1.f;
30 }
31
32 __attribute__((noipa)) float
33 f5 (float x)
34 {
35 return x > 0 ? -1.f : 1.f;
36 }
37
38 __attribute__((noipa)) float
39 f6 (float x)
40 {
41 return x >= 0 ? -1.f : 1.f;
42 }
43
44 __attribute__((noipa)) float
45 f7 (float x)
46 {
47 return x < 0 ? -1.f : 1.f;
48 }
49
50 __attribute__((noipa)) float
51 f8 (float x)
52 {
53 return x <= 0 ? -1.f : 1.f;
54 }
55
56 int
57 main ()
58 {
59 float a = 0.f;
60 float b = b1 * b2;
61 float c = 2.f;
62 float d = -2.f;
63 if (f1 (a) != -1.f || f1 (b) != -1.f || f1 (c) != 1.f || f1 (d) != -1.f
64 || f2 (a) != 1.f || f2 (b) != 1.f || f2 (c) != 1.f || f2 (d) != -1.f
65 || f3 (a) != -1.f || f3 (b) != -1.f || f3 (c) != -1.f || f3 (d) != 1.f
66 || f4 (a) != 1.f || f4 (b) != 1.f || f4 (c) != -1.f || f4 (d) != 1.f
67 || f5 (a) != 1.f || f5 (b) != 1.f || f5 (c) != -1.f || f5 (d) != 1.f
68 || f6 (a) != -1.f || f6 (b) != -1.f || f6 (c) != -1.f || f6 (d) != 1.f
69 || f7 (a) != 1.f || f7 (b) != 1.f || f7 (c) != 1.f || f7 (d) != -1.f
70 || f8 (a) != -1.f || f8 (b) != -1.f || f8 (c) != 1.f || f8 (d) != -1.f)
71 __builtin_abort ();
72 return 0;
73 }