]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/tree-ssa/builtin-snprintf-3.c
Fix profile update in tree_transform_and_unroll_loop
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / builtin-snprintf-3.c
1 /* Verify the lower and upper bounds of floating directives with
2 precision whose range crosses zero.
3 { do-do compile }
4 { dg-options "-O2 -Wall -fdump-tree-optimized" } */
5
6 static const double x = 1.23456789;
7
8 /* All calls to failure_range must be eliminated. */
9 extern void failure_range (int, int, int);
10
11 /* All calls to verify_{lo,hi}_bound must be retained. */
12 extern void verify_lo_bound (int, int);
13 extern void verify_hi_bound (int, int);
14
15 int test_a (int p)
16 {
17 if (p < -1 || 3 < p)
18 p = -1;
19
20 int n = __builtin_snprintf (0, 0, "%.*A", p, x);
21 if (n < 6 || 25 < n)
22 failure_range ('A', 6, 25);
23
24 if (n == 6) verify_lo_bound ('A', 6);
25 if (n == 25) verify_hi_bound ('A', 25);
26
27 return n;
28 }
29
30 int test_e (int p)
31 {
32 if (p < -1 || 3 < p)
33 p = -1;
34
35 int n = __builtin_snprintf (0, 0, "%.*E", p, x);
36 if (n < 5 || 17 < n)
37 failure_range ('E', 5, 17);
38
39 if (n == 5) verify_lo_bound ('E', 5);
40 if (n == 17) verify_hi_bound ('E', 17);
41
42 return n;
43 }
44
45 int test_f (int p)
46 {
47 if (p < -1 || 3 < p)
48 p = -1;
49
50 int n = __builtin_snprintf (0, 0, "%.*F", p, x);
51 if (n < 1 || 13 < n)
52 failure_range ('F', 1, 13);
53
54 if (n == 1) verify_lo_bound ('F', 1);
55 if (n == 13) verify_hi_bound ('F', 13);
56
57 return n;
58 }
59
60 int test_g (int p)
61 {
62 if (p < -1 || 3 < p)
63 p = -1;
64
65 int n = __builtin_snprintf (0, 0, "%.*G", p, x);
66 if (n < 1 || 12 < n)
67 failure_range ('G', 1, 12);
68
69 if (n == 1) verify_lo_bound ('G', 1);
70 if (n == 12) verify_hi_bound ('G', 12);
71
72 return n;
73 }
74
75 /* { dg-final { scan-tree-dump-times "snprintf" 4 "optimized"} }
76 { dg-final { scan-tree-dump-not "failure_range" "optimized"} }
77 { dg-final { scan-tree-dump-times "verify_" 8 "optimized"} } */