Debian Codegraph @

gcc/testsuite/gcc.dg/pr81192.c

raw
1 /* { dg-options "-Os -fgimple -fdump-tree-pre-details -fdisable-tree-evrp -fno-tree-dse" } */
2
3 #if __SIZEOF_INT__ == 2
4 #define unsigned __UINT32_TYPE__
5 #define int __INT32_TYPE__
6 #endif
7
8 unsigned a;
9 int b, c;
10
11 void __GIMPLE(ssa, startwith("pre")) fn2 ()
12 {
13 int b_lsm6;
14 int j;
15 int c0_1;
16 int iftmp2_8;
17
18 __BB(2):
19 a = _Literal (unsigned)30;
20 c0_1 = c;
21 b_lsm6_9 = b;
22 goto __BB7;
23
24 __BB(3):
25 if (j_6(D) != _Literal (int)2147483647)
26 goto __BB4;
27 else
28 goto __BB9;
29
30 __BB(4):
31 iftmp2_8 = j_6(D) + _Literal (int)1;
32 goto __BB5;
33
34 __BB(9):
35 iftmp2_8 = j_6(D) + _Literal (int)1;
36 goto __BB5;
37
38 __BB(5):
39 b_lsm6_10 = _Literal (int)2147483647;
40 goto __BB6;
41
42 __BB(6):
43 if (c0_1 != _Literal (int) 0)
44 goto __BB3;
45 else
46 goto __BB8;
47
48 __BB(8):
49 goto __BB7;
50
51 __BB(7):
52 goto __BB6;
53
54 }
55
56 #if 0
57 /* This used to be a C based testcase but ccp3 would now would remove
58 the setting of iftmp2_8 (in the above gimple) which would cause PRE
59 not to test what PRE was doing incorrectly. The original code is below. */
60 /* Disable tree-evrp because the new version of evrp sees
61 <bb 3> :
62 if (j_8(D) != 2147483647)
63 goto <bb 4>; [50.00%]
64 else
65 goto <bb 5>; [50.00%]
66 <bb 4> :
67 iftmp.2_11 = j_8(D) + 1;
68 <bb 5> :
69 # iftmp.2_12 = PHI <j_8(D)(3), iftmp.2_11(4)>
70
71 EVRP now recognizes a constant can be propagated into the 3->5 edge and
72 produces
73 # iftmp.2_12 = PHI <2147483647(3), iftmp.2_11(4)>
74 which causes the situation being tested to dissapear before we get to PRE. */
75
76 /* Likewise disable DSE which also elides the tail merging "opportunity". */
77
78 static int
79 fn1 (int p1, int p2)
80 {
81 return p1 > 2147483647 - p2 ? p1 : p1 + p2;
82 }
83
84 void
85 fn2 (void)
86 {
87 int j;
88 a = 30;
89 for (; a;)
90 for (; c; b = fn1 (j, 1))
91 ;
92 }
93 #endif
94
95 /* { dg-final { scan-tree-dump-times "(?n)find_duplicates: <bb .*> duplicate of <bb .*>" 1 "pre" } } */