Debian Codegraph @

gcc/testsuite/gnat.dg/hardcfr.adb

raw
1 -- { dg-do run }
2 -- { dg-options "-fharden-control-flow-redundancy -fno-hardcfr-check-exceptions -fdump-tree-hardcfr --param=hardcfr-max-blocks=22 --param=hardcfr-max-inline-blocks=12 -O0" }
3
4 procedure HardCFR is
5 function F (I, J : Integer) return Integer is
6 begin
7 if (I < J) then
8 return 2 * I;
9 else
10 return 3 * J;
11 end if;
12 end F;
13
14 function G (I : Natural; J : Integer) return Integer is
15 begin
16 case I is
17 when 0 =>
18 return J * 2;
19
20 when 1 =>
21 return J * 3;
22
23 when 2 =>
24 return J * 5;
25
26 when others =>
27 return J * 7;
28 end case;
29 end G;
30
31 function H (I : Natural; -- { dg-warning "has more than 22 blocks, the requested maximum" }
32 J : Integer)
33 return Integer is
34 begin
35 case I is
36 when 0 =>
37 return J * 2;
38
39 when 1 =>
40 return J * 3;
41
42 when 2 =>
43 return J * 5;
44
45 when 3 =>
46 return J * 7;
47
48 when 4 =>
49 return J * 11;
50
51 when 5 =>
52 return J * 13;
53
54 when 6 =>
55 return J * 17;
56
57 when 7 =>
58 return J * 19;
59
60 when others =>
61 return J * 23;
62 end case;
63 end H;
64 begin
65 if (F (1, 2) /= 2 or else F (3, 2) /= 6
66 or else G (2, 5) /= 25 or else H (4, 3) /= 33)
67 then
68 raise Program_Error;
69 end if;
70 end HardCFR;
71
72 -- HardCFR and HardCFR.F:
73 -- { dg-final { scan-tree-dump-times ".builtin_trap" 2 "hardcfr" } }
74
75 -- This is __builtin___hardcfr_check in HardCFR.G:
76 -- { dg-final { scan-tree-dump-times ".builtin " 1 "hardcfr" } }