File tree Expand file tree Collapse file tree 3 files changed +90
-0
lines changed
gcc/testsuite/gcc.dg/tree-ssa Expand file tree Collapse file tree 3 files changed +90
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* { dg-do compile } */
2
+ /* { dg-options "-O2 -fdump-tree-evrp" } */
3
+
4
+ void call (void );
5
+
6
+ void foo (int base )
7
+ {
8
+ unsigned i ;
9
+
10
+ // Ranger should be able to remove the (i > 123) comparison.
11
+ for (i = base ; i < 10 ; i ++ )
12
+ if (i > 123 )
13
+ {
14
+ call ();
15
+ return ;
16
+ }
17
+ }
18
+
19
+ /* { dg-final { scan-tree-dump-not "call" "evrp"} } */
Original file line number Diff line number Diff line change
1
+ /* { dg-do compile } */
2
+ /* { dg-options "-O2 -fdump-tree-evrp" } */
3
+
4
+ extern void vrp_keep (void );
5
+ extern void vrp_kill (void );
6
+
7
+ void
8
+ f2 (int s , int b )
9
+ {
10
+ if (s > 4 )
11
+ s = 4 ;
12
+ if (s < -16 )
13
+ s = -16 ;
14
+ /* s in [-16, 4]. */
15
+ b = (b & 1 ) + 1 ;
16
+ /* b in range [1, 2]. */
17
+ b = s << b ;
18
+ /* b in range [-64, 16]. */
19
+ if (b == -2 )
20
+ vrp_keep ();
21
+ if (b <= -65 )
22
+ vrp_kill ();
23
+ if (b >= 17 )
24
+ vrp_kill ();
25
+ }
26
+
27
+ /* { dg-final { scan-tree-dump-times "vrp_keep \\(" 1 "evrp"} } */
28
+ /* { dg-final { scan-tree-dump-times "vrp_kill \\(" 0 "evrp"} } */
Original file line number Diff line number Diff line change
1
+ /* See backwards thru casts if the range fits the LHS type. */
2
+ /* { dg-do compile } */
3
+ /* { dg-options "-O2 -fdump-tree-evrp" } */
4
+
5
+ extern void kill (int i );
6
+ extern void keep (int i );
7
+
8
+ void
9
+ foo (int i )
10
+ {
11
+ if (i >= 10 )
12
+ {
13
+ if (i <= 100 )
14
+ {
15
+ /* i has a range of [10, 100] */
16
+ char c = (char ) i ;
17
+ if (c < 30 )
18
+ {
19
+ /* If we wind back thru the cast with the range of c being [10,29]
20
+ * from the branch, and recognize that the range of i fits within
21
+ * a cast to c, then there is no missing information in a cast
22
+ * back to int. We can use the range calculated for 'c' with 'i'
23
+ * as well and Ranger should be able to kill the call. */
24
+ if (i > 29 )
25
+ kill (i );
26
+ }
27
+ }
28
+ /* i has a range of [10, MAX] */
29
+ char d = (char ) i ;
30
+ if (d < 30 )
31
+ {
32
+ /* Here, a cast to a char and back is NOT equivalent, so we cannot use
33
+ * the value of d to remove the call. */
34
+ if (i > 29 )
35
+ keep (i );
36
+ }
37
+
38
+ }
39
+ }
40
+
41
+ /* { dg-final { scan-tree-dump-times "kill \\(" 0 "evrp"} } */
42
+ /* { dg-final { scan-tree-dump-times "keep \\(" 1 "evrp"} } */
43
+
You can’t perform that action at this time.
0 commit comments