re PR tree-optimization/56384 (ICE in fold_binary_loc, at fold-const.c:10422)

2013-02-19  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/56384
	* tree-ssa-sccvn.h (struct vn_phi_s): Add type member.
	(vn_hash_type): Split out from ...
	(vn_hash_constant_with_type): ... here.
	* tree-ssa-sccvn.c (vn_phi_compute_hash): Use vn_hash_type.
	(vn_phi_eq): Compare types from vn_phi_s structure.
	(vn_phi_lookup): Populate vn_phi_s type.
	(vn_phi_insert): Likewise.

	* gcc.dg/torture/pr56384.c: New testcase.

From-SVN: r196136
This commit is contained in:
Richard Biener 2013-02-19 12:10:48 +00:00 committed by Richard Biener
parent 47cc28f568
commit 24d630163b
5 changed files with 58 additions and 10 deletions

View File

@ -1,3 +1,14 @@
2013-02-19 Richard Biener <rguenther@suse.de>
PR tree-optimization/56384
* tree-ssa-sccvn.h (struct vn_phi_s): Add type member.
(vn_hash_type): Split out from ...
(vn_hash_constant_with_type): ... here.
* tree-ssa-sccvn.c (vn_phi_compute_hash): Use vn_hash_type.
(vn_phi_eq): Compare types from vn_phi_s structure.
(vn_phi_lookup): Populate vn_phi_s type.
(vn_phi_insert): Likewise.
2013-02-19 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/56350

View File

@ -1,3 +1,8 @@
2013-02-19 Richard Biener <rguenther@suse.de>
PR tree-optimization/56384
* gcc.dg/torture/pr56384.c: New testcase.
2013-02-19 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/56350

View File

@ -0,0 +1,24 @@
/* { dg-do compile } */
int a, c;
void f(void)
{
unsigned char b;
if(a)
{
for(; b < 1; b++);
lbl1:
c = (b |= 0) ^ (b || a);
}
if((a = b))
{
b = c;
goto lbl1;
}
b = 5;
goto lbl1;
}

View File

@ -2401,10 +2401,8 @@ vn_phi_compute_hash (vn_phi_t vp1)
/* If all PHI arguments are constants we need to distinguish
the PHI node via its type. */
type = TREE_TYPE (vp1->phiargs[0]);
result += (INTEGRAL_TYPE_P (type)
+ (INTEGRAL_TYPE_P (type)
? TYPE_PRECISION (type) + TYPE_UNSIGNED (type) : 0));
type = vp1->type;
result += vn_hash_type (type);
FOR_EACH_VEC_ELT (vp1->phiargs, i, phi1op)
{
@ -2443,8 +2441,7 @@ vn_phi_eq (const void *p1, const void *p2)
/* If the PHI nodes do not have compatible types
they are not the same. */
if (!types_compatible_p (TREE_TYPE (vp1->phiargs[0]),
TREE_TYPE (vp2->phiargs[0])))
if (!types_compatible_p (vp1->type, vp2->type))
return false;
/* Any phi in the same block will have it's arguments in the
@ -2484,6 +2481,7 @@ vn_phi_lookup (gimple phi)
def = TREE_CODE (def) == SSA_NAME ? SSA_VAL (def) : def;
shared_lookup_phiargs.safe_push (def);
}
vp1.type = TREE_TYPE (gimple_phi_result (phi));
vp1.phiargs = shared_lookup_phiargs;
vp1.block = gimple_bb (phi);
vp1.hashcode = vn_phi_compute_hash (&vp1);
@ -2516,6 +2514,7 @@ vn_phi_insert (gimple phi, tree result)
args.safe_push (def);
}
vp1->value_id = VN_INFO (result)->value_id;
vp1->type = TREE_TYPE (gimple_phi_result (phi));
vp1->phiargs = args;
vp1->block = gimple_bb (phi);
vp1->result = result;

View File

@ -67,6 +67,7 @@ typedef struct vn_phi_s
hashval_t hashcode;
vec<tree> phiargs;
basic_block block;
tree type;
tree result;
} *vn_phi_t;
typedef const struct vn_phi_s *const_vn_phi_t;
@ -122,17 +123,25 @@ typedef struct vn_constant_s
enum vn_kind { VN_NONE, VN_CONSTANT, VN_NARY, VN_REFERENCE, VN_PHI };
enum vn_kind vn_get_stmt_kind (gimple);
/* Hash the type TYPE using bits that distinguishes it in the
types_compatible_p sense. */
static inline hashval_t
vn_hash_type (tree type)
{
return (INTEGRAL_TYPE_P (type)
+ (INTEGRAL_TYPE_P (type)
? TYPE_PRECISION (type) + TYPE_UNSIGNED (type) : 0));
}
/* Hash the constant CONSTANT with distinguishing type incompatible
constants in the types_compatible_p sense. */
static inline hashval_t
vn_hash_constant_with_type (tree constant)
{
tree type = TREE_TYPE (constant);
return (iterative_hash_expr (constant, 0)
+ INTEGRAL_TYPE_P (type)
+ (INTEGRAL_TYPE_P (type)
? TYPE_PRECISION (type) + TYPE_UNSIGNED (type) : 0));
+ vn_hash_type (TREE_TYPE (constant)));
}
/* Compare the constants C1 and C2 with distinguishing type incompatible