]>
Commit | Line | Data |
---|---|---|
692b5caf PS |
1 | 2005-07-30 James A. Morrison <phython@gcc.gnu.org> |
2 | ||
3 | PR tree-optimization/23128 | |
4 | PR tree-optimization/23129 | |
5 | * tree-vrp.c (vrp_int_const_binop): Treat unsigned types like | |
6 | flag_wrapv. | |
7 | (extract_range_from_binary_expr): Set value range to varying for | |
8 | divisions with anti-ranges. Set value range to varying for unsigned | |
9 | addition and subtraction if it could wrap. | |
10 | (compare_ranges): Return false for EQ_EXPR if VR0 is less than VR1 or | |
11 | vice-versa. | |
12 | ||
13 | --- gcc/gcc/tree-vrp.c 29 Jul 2005 15:21:54 -0000 2.47 | |
14 | +++ gcc/gcc/tree-vrp.c 30 Jul 2005 18:10:26 -0000 | |
15 | @@ -908,7 +908,7 @@ vrp_int_const_binop (enum tree_code code | |
16 | { | |
17 | tree res; | |
18 | ||
19 | - if (flag_wrapv) | |
20 | + if (flag_wrapv || TYPE_UNSIGNED (TREE_TYPE (val1))) | |
21 | return int_const_binop (code, val1, val2, 0); | |
22 | ||
23 | /* If we are not using wrapping arithmetic, operate symbolically | |
24 | @@ -1095,6 +1095,22 @@ extract_range_from_binary_expr (value_ra | |
25 | the same end of each range. */ | |
26 | min = vrp_int_const_binop (code, vr0.min, vr1.min); | |
27 | max = vrp_int_const_binop (code, vr0.max, vr1.max); | |
28 | + | |
29 | + /* Check for possible unsigned wrapping. */ | |
30 | + if (code == PLUS_EXPR && TYPE_UNSIGNED (TREE_TYPE (expr))) | |
31 | + { | |
32 | + tree res0 = fold_binary_to_constant (GT_EXPR, TREE_TYPE (expr), | |
33 | + vr0.max, max); | |
34 | + tree res1 = fold_binary_to_constant (GT_EXPR, TREE_TYPE (expr), | |
35 | + vr1.max, max); | |
36 | + | |
37 | + if ((res0 && integer_onep (res0)) | |
38 | + || (res1 && integer_onep (res1))) | |
39 | + { | |
40 | + set_value_range_to_varying (vr); | |
41 | + return; | |
42 | + } | |
43 | + } | |
44 | } | |
45 | else if (code == MULT_EXPR | |
46 | || code == TRUNC_DIV_EXPR | |
47 | @@ -1136,7 +1152,8 @@ extract_range_from_binary_expr (value_ra | |
48 | the new range. */ | |
49 | ||
50 | /* Divisions by zero result in a VARYING value. */ | |
51 | - if (code != MULT_EXPR && range_includes_zero_p (&vr1)) | |
52 | + if (code != MULT_EXPR | |
53 | + && (vr0.type == VR_ANTI_RANGE || range_includes_zero_p (&vr1))) | |
54 | { | |
55 | set_value_range_to_varying (vr); | |
56 | return; | |
57 | @@ -1204,6 +1221,22 @@ extract_range_from_binary_expr (value_ra | |
58 | each range. */ | |
59 | min = vrp_int_const_binop (code, vr0.min, vr1.max); | |
60 | max = vrp_int_const_binop (code, vr0.max, vr1.min); | |
61 | + | |
62 | + /* Check for possible unsigned wrapping. */ | |
63 | + if (TYPE_UNSIGNED (TREE_TYPE (expr))) | |
64 | + { | |
65 | + tree res0 = fold_binary_to_constant (LT_EXPR, TREE_TYPE (expr), | |
66 | + vr0.min, min); | |
67 | + tree res1 = fold_binary_to_constant (GT_EXPR, TREE_TYPE (expr), | |
68 | + vr1.max, max); | |
69 | + | |
70 | + if ((res0 && integer_onep (res0)) | |
71 | + || (res1 && integer_onep (res1))) | |
72 | + { | |
73 | + set_value_range_to_varying (vr); | |
74 | + return; | |
75 | + } | |
76 | + } | |
77 | } | |
78 | else | |
79 | gcc_unreachable (); | |
80 | @@ -1677,6 +1710,10 @@ compare_ranges (enum tree_code comp, val | |
81 | else if (cmp_min != -2 && cmp_max != -2) | |
82 | return boolean_false_node; | |
83 | } | |
84 | + /* If [V0_MIN, V1_MAX] < [V1_MIN, V1_MAX] then V0 != V1. */ | |
85 | + else if (compare_values (vr0->min, vr1->max) == 1 | |
86 | + || compare_values (vr1->min, vr0->max) == 1) | |
87 | + return boolean_false_node; | |
88 | ||
89 | return NULL_TREE; | |
90 | } |