aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2014-11-07 13:35:43 +0100
committerMartin Liska <marxin@gcc.gnu.org>2014-11-07 12:35:43 +0000
commitfdaaeea1b61b60c0b76a657d7557a34c3e7b5186 (patch)
tree44271cd0fb5a71b824811bdca1bbf30dff0728b8 /gcc
parent8c14c817f30b966f509636b96d4e5586261a258b (diff)
downloadgcc-fdaaeea1b61b60c0b76a657d7557a34c3e7b5186.zip
gcc-fdaaeea1b61b60c0b76a657d7557a34c3e7b5186.tar.gz
gcc-fdaaeea1b61b60c0b76a657d7557a34c3e7b5186.tar.bz2
re PR tree-optimization/63747 (icf mis-compares switch gimple)
PR ipa/63747 * gcc.dg/ipa/pr63747.c: New test. * ipa-icf-gimple.c (func_checker::compare_gimple_switch): Missing checking for CASE_LOW and CASE_HIGH added. From-SVN: r217219
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/ipa-icf-gimple.c13
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/ipa/pr63747.c40
4 files changed, 64 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6fc91b5..6e721a6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2014-11-07 Martin Liska <mliska@suse.cz>
+ PR ipa/63747
+ * ipa-icf-gimple.c (func_checker::compare_gimple_switch):
+ Missing checking for CASE_LOW and CASE_HIGH added.
+
+2014-11-07 Martin Liska <mliska@suse.cz>
+
PR ipa/63595
* cgraphunit.c (cgraph_node::expand_thunk): DECL_BY_REFERENCE
is correctly handled for thunks created by IPA ICF.
diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
index ecb9667..75b5cfb 100644
--- a/gcc/ipa-icf-gimple.c
+++ b/gcc/ipa-icf-gimple.c
@@ -798,6 +798,19 @@ func_checker::compare_gimple_switch (gimple g1, gimple g2)
tree label1 = gimple_switch_label (g1, i);
tree label2 = gimple_switch_label (g2, i);
+ /* Label LOW and HIGH comparison. */
+ tree low1 = CASE_LOW (label1);
+ tree low2 = CASE_LOW (label2);
+
+ if (!tree_int_cst_equal (low1, low2))
+ return return_false_with_msg ("case low values are different");
+
+ tree high1 = CASE_HIGH (label1);
+ tree high2 = CASE_HIGH (label2);
+
+ if (!tree_int_cst_equal (high1, high2))
+ return return_false_with_msg ("case high values are different");
+
if (TREE_CODE (label1) == CASE_LABEL_EXPR
&& TREE_CODE (label2) == CASE_LABEL_EXPR)
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8575ba3..036d59d3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2014-11-07 Martin Liska <mliska@suse.cz>
+ PR ipa/63747
+ * gcc.dg/ipa/pr63747.c: New test.
+
+2014-11-07 Martin Liska <mliska@suse.cz>
+
PR ipa/63595
* g++.dg/ipa/pr63595.C: New test.
diff --git a/gcc/testsuite/gcc.dg/ipa/pr63747.c b/gcc/testsuite/gcc.dg/ipa/pr63747.c
new file mode 100644
index 0000000..7b5df4b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr63747.c
@@ -0,0 +1,40 @@
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+/* { dg-do run } */
+
+static int __attribute__((noinline))
+foo(int i)
+{
+ switch (i)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ return 0;
+ default:
+ return 1;
+ }
+}
+
+static int __attribute__((noinline))
+bar(int i)
+{
+ switch (i)
+ {
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ return 0;
+ default:
+ return 1;
+ }
+}
+
+int main()
+{
+ return foo(0) + bar(4);
+}
+
+/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */