From 3c031cbe7c4b1896dd262a373131fc9a7cb58981 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 3 Mar 2015 13:09:13 +0100 Subject: [PATCH] re PR ipa/65282 (wrong code at -Os and above on x86_64-linux-gnu) Fix PR ipa/65282. * gcc.dg/ipa/PR65282.c: New test. PR ipa/65282 * ipa-icf.c (sem_variable::equals): Fix wrong condition. From-SVN: r221146 --- gcc/ChangeLog | 5 +++++ gcc/ipa-icf.c | 2 +- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/ipa/PR65282.c | 20 ++++++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/ipa/PR65282.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cb42917f610..f2fd1ff6ffb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-03-03 Martin Liska + + PR ipa/65282 + * ipa-icf.c (sem_variable::equals): Fix wrong condition. + 2015-03-23 Jeff Law PR tree-optimization/65241 diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index 48326185d96..a47ca29aeea 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -1638,7 +1638,7 @@ sem_variable::equals (tree t1, tree t2) tree y1 = TREE_OPERAND (t1, 1); tree y2 = TREE_OPERAND (t2, 1); - if (!sem_variable::equals (x1, x2) && sem_variable::equals (y1, y2)) + if (!sem_variable::equals (x1, x2) || !sem_variable::equals (y1, y2)) return false; if (!sem_variable::equals (array_ref_low_bound (t1), array_ref_low_bound (t2))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 824d2561fea..11ffd258d61 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-03-03 Martin Liska + + * gcc.dg/ipa/PR65282.c: New test. + 2015-03-13 Jeff Law PR tree-optimization/65241 diff --git a/gcc/testsuite/gcc.dg/ipa/PR65282.c b/gcc/testsuite/gcc.dg/ipa/PR65282.c new file mode 100644 index 00000000000..58e1c55237b --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/PR65282.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -fdump-ipa-icf" } */ + +int a[2]; +static int *b = &a[0], *c = &a[1]; + +int +main () +{ + *c = 1; + *b = 0; + + if (a[1] != 1) + __builtin_abort (); + + return 0; +} + +/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */ +/* { dg-final { cleanup-ipa-dump "icf" } } */ -- 2.30.2