From: Richard Biener Date: Tue, 19 Feb 2013 12:10:48 +0000 (+0000) Subject: re PR tree-optimization/56384 (ICE in fold_binary_loc, at fold-const.c:10422) X-Git-Tag: upstream/12.2.0~71190 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=24d630163b15482845ffef8c733653281008016f;p=platform%2Fupstream%2Fgcc.git re PR tree-optimization/56384 (ICE in fold_binary_loc, at fold-const.c:10422) 2013-02-19 Richard Biener 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b4036f2..7a1657c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2013-02-19 Richard Biener + + 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 PR tree-optimization/56350 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 94a237b..68ea2bd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-02-19 Richard Biener + + PR tree-optimization/56384 + * gcc.dg/torture/pr56384.c: New testcase. + 2013-02-19 Jakub Jelinek PR tree-optimization/56350 diff --git a/gcc/testsuite/gcc.dg/torture/pr56384.c b/gcc/testsuite/gcc.dg/torture/pr56384.c new file mode 100644 index 0000000..ef3cf05 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr56384.c @@ -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; +} diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 81a07ae..202980c 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -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; diff --git a/gcc/tree-ssa-sccvn.h b/gcc/tree-ssa-sccvn.h index ea9020d..072f7dd 100644 --- a/gcc/tree-ssa-sccvn.h +++ b/gcc/tree-ssa-sccvn.h @@ -67,6 +67,7 @@ typedef struct vn_phi_s hashval_t hashcode; vec 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