diff options
author | Richard Biener <rguenther@suse.de> | 2017-09-20 11:08:35 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-09-20 11:08:35 +0000 |
commit | 2a9000795c721f5d4117dfb0832f272769d9b2a6 (patch) | |
tree | 1f4ea118b3a2c957c8a13e23975c5adbde54f8b5 | |
parent | 88272c019414e6558db9c6c72053415fa88e0b5e (diff) | |
download | gcc-2a9000795c721f5d4117dfb0832f272769d9b2a6.zip gcc-2a9000795c721f5d4117dfb0832f272769d9b2a6.tar.gz gcc-2a9000795c721f5d4117dfb0832f272769d9b2a6.tar.bz2 |
re PR tree-optimization/82264 (ICE in vn_phi_lookup at gcc/tree-ssa-sccvn.c:3125)
2017-09-20 Richard Biener <rguenther@suse.de>
PR tree-optimization/82264
* tree-ssa-sccvn.c (vn_phi_eq): Use safe_dyn_cast to check
for GIMPLE_CONDs.
(vn_phi_lookup): Likewise.
(vn_phi_insert): Likewise.
* gcc.dg/torture/pr82264.c: New testcase.
From-SVN: r253005
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr82264.c | 21 | ||||
-rw-r--r-- | gcc/tree-ssa-sccvn.c | 17 |
4 files changed, 41 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b82df9f..15b1095 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-09-20 Richard Biener <rguenther@suse.de> + + PR tree-optimization/82264 + * tree-ssa-sccvn.c (vn_phi_eq): Use safe_dyn_cast to check + for GIMPLE_CONDs. + (vn_phi_lookup): Likewise. + (vn_phi_insert): Likewise. + 2017-09-20 Jakub Jelinek <jakub@redhat.com> * dwarf2out.c (tree_add_const_value_attribute): For INTEGER_CST diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0247ada..da107c3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-09-20 Richard Biener <rguenther@suse.de> + + PR tree-optimization/82264 + * gcc.dg/torture/pr82264.c: New testcase. + 2017-09-20 Jakub Jelinek <jakub@redhat.com> * g++.dg/debug/dwarf2/template-params-13.C: New test. diff --git a/gcc/testsuite/gcc.dg/torture/pr82264.c b/gcc/testsuite/gcc.dg/torture/pr82264.c new file mode 100644 index 0000000..2bc0367 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr82264.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +char a; +int c; +unsigned b (); +unsigned +setjmp () +{ +} +static void +d () +{ + if (b ()) + c = 3; +} +void +e () +{ + d (); + a && ({ setjmp (); }); +} diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 0b0c510..ca78e2d 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -3028,16 +3028,13 @@ vn_phi_eq (const_vn_phi_t const vp1, const_vn_phi_t const vp2) return false; /* Verify the controlling stmt is the same. */ - gimple *last1 = last_stmt (idom1); - gimple *last2 = last_stmt (idom2); - if (gimple_code (last1) != GIMPLE_COND - || gimple_code (last2) != GIMPLE_COND) + gcond *last1 = safe_dyn_cast <gcond *> (last_stmt (idom1)); + gcond *last2 = safe_dyn_cast <gcond *> (last_stmt (idom2)); + if (! last1 || ! last2) return false; bool inverted_p; - if (! cond_stmts_equal_p (as_a <gcond *> (last1), - vp1->cclhs, vp1->ccrhs, - as_a <gcond *> (last2), - vp2->cclhs, vp2->ccrhs, + if (! cond_stmts_equal_p (last1, vp1->cclhs, vp1->ccrhs, + last2, vp2->cclhs, vp2->ccrhs, &inverted_p)) return false; @@ -3122,7 +3119,7 @@ vn_phi_lookup (gimple *phi) vp1.ccrhs = NULL_TREE; basic_block idom1 = get_immediate_dominator (CDI_DOMINATORS, vp1.block); if (EDGE_COUNT (idom1->succs) == 2) - if (gcond *last1 = dyn_cast <gcond *> (last_stmt (idom1))) + if (gcond *last1 = safe_dyn_cast <gcond *> (last_stmt (idom1))) { vp1.cclhs = vn_valueize (gimple_cond_lhs (last1)); vp1.ccrhs = vn_valueize (gimple_cond_rhs (last1)); @@ -3168,7 +3165,7 @@ vn_phi_insert (gimple *phi, tree result) vp1->ccrhs = NULL_TREE; basic_block idom1 = get_immediate_dominator (CDI_DOMINATORS, vp1->block); if (EDGE_COUNT (idom1->succs) == 2) - if (gcond *last1 = dyn_cast <gcond *> (last_stmt (idom1))) + if (gcond *last1 = safe_dyn_cast <gcond *> (last_stmt (idom1))) { vp1->cclhs = vn_valueize (gimple_cond_lhs (last1)); vp1->ccrhs = vn_valueize (gimple_cond_rhs (last1)); |