summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-09-24 14:14:18 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-09-24 14:14:18 +0000
commita03a52b437d9e1b2d311f26aedd60465d025e1d6 (patch)
treec20a1313111ed5f986d8e19344092dc061ea09d4 /gcc
parent58bf5219edd00f3fa401e2fe8a8048820a7ac96a (diff)
downloadgcc-a03a52b437d9e1b2d311f26aedd60465d025e1d6.tar.gz
2012-09-24 Richard Guenther <rguenther@suse.de>
PR tree-optimization/54684 * tree-ssa-ccp.c (optimize_unreachable): Properly update stmts. * g++.dg/torture/pr54684.C: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191667 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/torture/pr54684.C62
-rw-r--r--gcc/tree-ssa-ccp.c1
4 files changed, 73 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index efa46766b4d..484df3673ad 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2012-09-24 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/54684
+ * tree-ssa-ccp.c (optimize_unreachable): Properly update stmts.
+
2012-09-24 Marc Glisse <marc.glisse@inria.fr>
* tree-ssa-forwprop.c: Include tree-ssa-propagate.h.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6d610e56909..a0b2bdf0ef6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-09-24 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/54684
+ * g++.dg/torture/pr54684.C: New testcase.
+
2012-09-24 Marc Glisse <marc.glisse@inria.fr>
* gcc.dg/tree-ssa/forwprop-23.c: New testcase.
diff --git a/gcc/testsuite/g++.dg/torture/pr54684.C b/gcc/testsuite/g++.dg/torture/pr54684.C
new file mode 100644
index 00000000000..40c47f3fa29
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr54684.C
@@ -0,0 +1,62 @@
+// { dg-do compile }
+
+typedef union tree_node *tree;
+typedef union gimple_statement_d *gimple;
+struct vec_prefix { unsigned num_; };
+template<typename T> struct vec_t {
+ unsigned length (void) const;
+ T &operator[] (unsigned);
+ vec_prefix prefix_;
+ T vec_[1];
+};
+template<typename T> inline unsigned vec_t<T>::length (void) const {
+ return prefix_.num_;
+}
+template<typename T> T & vec_t<T>::operator[] (unsigned ix) {
+ ((void)(__builtin_expect(!(ix < prefix_.num_), 0) ? __builtin_unreachable(), 0 : 0));
+ return vec_[ix];
+}
+enum tree_code { PARM_DECL };
+struct tree_base {
+ enum tree_code code : 16;
+ unsigned default_def_flag : 1;
+};
+union tree_node {
+ struct tree_base base;
+};
+struct ipa_param_descriptor {
+ tree decl;
+ unsigned used : 1;
+};
+typedef struct ipa_param_descriptor ipa_param_descriptor_t;
+struct ipa_node_params {
+ vec_t<ipa_param_descriptor_t> *descriptors;
+};
+static inline int ipa_get_param_count (struct ipa_node_params *info) {
+ return ((info->descriptors) ? (info->descriptors)->length () : 0);
+}
+static inline tree ipa_get_param (struct ipa_node_params *info, int i) {
+ return ((*(info->descriptors))[i]).decl;
+}
+static inline void ipa_set_param_used (struct ipa_node_params *info, int i, bool val) {
+ ((*(info->descriptors))[i]).used = val;
+}
+int ipa_get_param_decl_index (struct ipa_node_params *info, tree ptree)
+{
+ int i, count;
+ count = ipa_get_param_count (info);
+ for (i = 0; i < count; i++)
+ if (ipa_get_param (info, i) == ptree) return i;
+ return -1;
+}
+bool visit_ref_for_mod_analysis (gimple stmt __attribute__ ((__unused__)),
+ tree op, void *data)
+{
+ struct ipa_node_params *info = (struct ipa_node_params *) data;
+ if (op && ((enum tree_code) (op)->base.code) == PARM_DECL)
+ {
+ int index = ipa_get_param_decl_index (info, op);
+ ((void)(__builtin_expect(!(index >= 0), 0) ? __builtin_unreachable(), 0 : 0));
+ ipa_set_param_used (info, index, true);
+ }
+}
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index bf684749926..49a4c6fbe28 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -2355,6 +2355,7 @@ optimize_unreachable (gimple_stmt_iterator i)
gimple_cond_make_true (stmt);
else
gcc_unreachable ();
+ update_stmt (stmt);
}
else
{