re PR tree-optimization/23603 (VRP does not say range for a in a = b == c; is [0,1])
2007-01-08 Richard Guenther <rguenther@suse.de> PR tree-optimization/23603 * tree-vrp.c (set_value_range_to_truthvalue): New function. (extract_range_from_binary): Fall back to truthvalue instead of varying for TRUTH_*_EXPR. (extract_range_from_comparison): Fall back to truthvalue instead of varying. (vrp_visit_phi_node): Don't adjust new range bounds to +INF/-INF if all visited PHI values were constant. * gcc.dg/tree-ssa/vrp31.c: New testcase. * gcc.dg/tree-ssa/vrp32.c: Likewise. From-SVN: r120578
This commit is contained in:
parent
151e6f2437
commit
31ab1cc9db
@ -1,3 +1,14 @@
|
|||||||
|
2007-01-08 Richard Guenther <rguenther@suse.de>
|
||||||
|
|
||||||
|
PR tree-optimization/23603
|
||||||
|
* tree-vrp.c (set_value_range_to_truthvalue): New function.
|
||||||
|
(extract_range_from_binary): Fall back to truthvalue instead of
|
||||||
|
varying for TRUTH_*_EXPR.
|
||||||
|
(extract_range_from_comparison): Fall back to truthvalue instead of
|
||||||
|
varying.
|
||||||
|
(vrp_visit_phi_node): Don't adjust new range bounds to +INF/-INF
|
||||||
|
if all visited PHI values were constant.
|
||||||
|
|
||||||
2007-01-08 Jan Hubicka <jh@suse.cz>
|
2007-01-08 Jan Hubicka <jh@suse.cz>
|
||||||
|
|
||||||
* cgraphunit.c (cgraph_process_new_functions): Reset reachable flag.
|
* cgraphunit.c (cgraph_process_new_functions): Reset reachable flag.
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
2007-01-08 Richard Guenther <rguenther@suse.de>
|
||||||
|
|
||||||
|
PR tree-optimization/23603
|
||||||
|
* gcc.dg/tree-ssa/vrp31.c: New testcase.
|
||||||
|
* gcc.dg/tree-ssa/vrp32.c: Likewise.
|
||||||
|
|
||||||
2007-01-08 Mark Shinwell <shinwell@codesourcery.com>
|
2007-01-08 Mark Shinwell <shinwell@codesourcery.com>
|
||||||
|
|
||||||
* gcc.target/i386/20020531-1.c: Use "char" not "unsigned char"
|
* gcc.target/i386/20020531-1.c: Use "char" not "unsigned char"
|
||||||
|
14
gcc/testsuite/gcc.dg/tree-ssa/vrp31.c
Normal file
14
gcc/testsuite/gcc.dg/tree-ssa/vrp31.c
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-options "-O2 -fdump-tree-vrp1" } */
|
||||||
|
|
||||||
|
int f(int i)
|
||||||
|
{
|
||||||
|
int t = i == 1;
|
||||||
|
int g = t == 2;
|
||||||
|
int h = g == 3;
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* { dg-final { scan-tree-dump "return 0;" "vrp1" } } */
|
||||||
|
/* { dg-final { cleanup-tree-dump "vrp1" } } */
|
||||||
|
|
14
gcc/testsuite/gcc.dg/tree-ssa/vrp32.c
Normal file
14
gcc/testsuite/gcc.dg/tree-ssa/vrp32.c
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-options "-O2 -fdump-tree-vrp1" } */
|
||||||
|
|
||||||
|
int f(int i)
|
||||||
|
{
|
||||||
|
_Bool t = !i;
|
||||||
|
int g = !t && i;
|
||||||
|
int h = g == 3;
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* { dg-final { scan-tree-dump "return 0;" "vrp1" } } */
|
||||||
|
/* { dg-final { cleanup-tree-dump "vrp1" } } */
|
||||||
|
|
@ -236,6 +236,20 @@ set_value_range_to_varying (value_range_t *vr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Set value range VR to a range of a truthvalue of type TYPE. */
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
set_value_range_to_truthvalue (value_range_t *vr, tree type)
|
||||||
|
{
|
||||||
|
if (TYPE_PRECISION (type) == 1)
|
||||||
|
set_value_range_to_varying (vr);
|
||||||
|
else
|
||||||
|
set_value_range (vr, VR_RANGE,
|
||||||
|
build_int_cst (type, 0), build_int_cst (type, 1),
|
||||||
|
vr->equiv);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Set value range VR to VR_UNDEFINED. */
|
/* Set value range VR to VR_UNDEFINED. */
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
@ -1439,7 +1453,8 @@ extract_range_from_binary_expr (value_range_t *vr, tree expr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
set_value_range_to_varying (vr);
|
/* The result of a TRUTH_*_EXPR is always true or false. */
|
||||||
|
set_value_range_to_truthvalue (vr, TREE_TYPE (expr));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1920,7 +1935,8 @@ extract_range_from_comparison (value_range_t *vr, tree expr)
|
|||||||
set_value_range (vr, VR_RANGE, val, val, vr->equiv);
|
set_value_range (vr, VR_RANGE, val, val, vr->equiv);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
set_value_range_to_varying (vr);
|
/* The result of a comparison is always true or false. */
|
||||||
|
set_value_range_to_truthvalue (vr, TREE_TYPE (expr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4182,6 +4198,7 @@ vrp_visit_phi_node (tree phi)
|
|||||||
tree lhs = PHI_RESULT (phi);
|
tree lhs = PHI_RESULT (phi);
|
||||||
value_range_t *lhs_vr = get_value_range (lhs);
|
value_range_t *lhs_vr = get_value_range (lhs);
|
||||||
value_range_t vr_result = { VR_UNDEFINED, NULL_TREE, NULL_TREE, NULL };
|
value_range_t vr_result = { VR_UNDEFINED, NULL_TREE, NULL_TREE, NULL };
|
||||||
|
bool all_const = true;
|
||||||
|
|
||||||
copy_value_range (&vr_result, lhs_vr);
|
copy_value_range (&vr_result, lhs_vr);
|
||||||
|
|
||||||
@ -4209,7 +4226,10 @@ vrp_visit_phi_node (tree phi)
|
|||||||
value_range_t vr_arg;
|
value_range_t vr_arg;
|
||||||
|
|
||||||
if (TREE_CODE (arg) == SSA_NAME)
|
if (TREE_CODE (arg) == SSA_NAME)
|
||||||
|
{
|
||||||
vr_arg = *(get_value_range (arg));
|
vr_arg = *(get_value_range (arg));
|
||||||
|
all_const = false;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vr_arg.type = VR_RANGE;
|
vr_arg.type = VR_RANGE;
|
||||||
@ -4240,7 +4260,8 @@ vrp_visit_phi_node (tree phi)
|
|||||||
/* To prevent infinite iterations in the algorithm, derive ranges
|
/* To prevent infinite iterations in the algorithm, derive ranges
|
||||||
when the new value is slightly bigger or smaller than the
|
when the new value is slightly bigger or smaller than the
|
||||||
previous one. */
|
previous one. */
|
||||||
if (lhs_vr->type == VR_RANGE && vr_result.type == VR_RANGE)
|
if (lhs_vr->type == VR_RANGE && vr_result.type == VR_RANGE
|
||||||
|
&& !all_const)
|
||||||
{
|
{
|
||||||
if (!POINTER_TYPE_P (TREE_TYPE (lhs)))
|
if (!POINTER_TYPE_P (TREE_TYPE (lhs)))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user