Re: [PATCH 9/9] Remove alias set comparison.

2019-08-08 Thread Martin Sebor

On 8/8/19 2:14 AM, Martin Liška wrote:

On 8/7/19 5:20 PM, Martin Sebor wrote:

On 6/11/19 1:36 AM, Martin Liska wrote:


gcc/ChangeLog:

2019-07-24  Martin Liska  

 * ipa-icf-gimple.c (func_checker::compatible_types_p):
 Do not compare alias sets.  It's handled by operand_equal_p.

gcc/testsuite/ChangeLog:

2019-07-24  Martin Liska  

 * c-c++-common/Wstringop-truncation-4.c: Disable IPA ICF.


What fails without the change?


ICF will newly merge these functions:


I see.  I suppose the other alternatives are to either add
attribute noipa to the functions or make unique the string
each function copies so they can't be merged.

I have a mild preference for the last alternative but it's
your call.  If you decide to keep the option can you please
add a brief comment explaining why it's needed?

Thanks
Martin



grep hit: Wstringop-truncation-4.c.070i.icf
Semantic equality hit:void test_arrays(Arrays*, const char*)->void 
test_const_arrays(ConstArrays*, const char*)
Semantic equality hit:void test_arrays(Arrays*, const char*)->void 
test_volatile_arrays(VolatileArrays*, const char*)
Semantic equality hit:void test_arrays(Arrays*, const char*)->void 
test_const_volatile_arrays(ConstVolatileArrays*, const char*)

So we'll get less warnings than expected.

Martin



Thanks
Martin


 * gcc.dg/tree-ssa/pr64910-2.c: Likewise.
 * gcc.dg/tree-ssa/pr79352.c: Likewise.
 * gcc.dg/ipa/ipa-icf-40.c: New test.
---
   gcc/ipa-icf-gimple.c  | 12 ---
   .../c-c++-common/Wstringop-truncation-4.c |  2 +-
   gcc/testsuite/gcc.dg/ipa/ipa-icf-40.c | 32 +++
   gcc/testsuite/gcc.dg/tree-ssa/pr64910-2.c |  2 +-
   gcc/testsuite/gcc.dg/tree-ssa/pr79352.c   |  2 +-
   5 files changed, 35 insertions(+), 15 deletions(-)
   create mode 100644 gcc/testsuite/gcc.dg/ipa/ipa-icf-40.c









Re: [PATCH 9/9] Remove alias set comparison.

2019-08-08 Thread Jeff Law
On 6/11/19 1:36 AM, Martin Liska wrote:
> 
> gcc/ChangeLog:
> 
> 2019-07-24  Martin Liska  
> 
>   * ipa-icf-gimple.c (func_checker::compatible_types_p):
>   Do not compare alias sets.  It's handled by operand_equal_p.
> 
> gcc/testsuite/ChangeLog:
> 
> 2019-07-24  Martin Liska  
> 
>   * c-c++-common/Wstringop-truncation-4.c: Disable IPA ICF.
>   * gcc.dg/tree-ssa/pr64910-2.c: Likewise.
>   * gcc.dg/tree-ssa/pr79352.c: Likewise.
>   * gcc.dg/ipa/ipa-icf-40.c: New test.
OK for the trunk once any prereqs are approved.

jeff


Re: [PATCH 9/9] Remove alias set comparison.

2019-08-08 Thread Martin Liška
On 8/7/19 5:20 PM, Martin Sebor wrote:
> On 6/11/19 1:36 AM, Martin Liska wrote:
>>
>> gcc/ChangeLog:
>>
>> 2019-07-24  Martin Liska  
>>
>> * ipa-icf-gimple.c (func_checker::compatible_types_p):
>> Do not compare alias sets.  It's handled by operand_equal_p.
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2019-07-24  Martin Liska  
>>
>> * c-c++-common/Wstringop-truncation-4.c: Disable IPA ICF.
> 
> What fails without the change?

ICF will newly merge these functions:

grep hit: Wstringop-truncation-4.c.070i.icf 
Semantic equality hit:void test_arrays(Arrays*, const char*)->void 
test_const_arrays(ConstArrays*, const char*)
Semantic equality hit:void test_arrays(Arrays*, const char*)->void 
test_volatile_arrays(VolatileArrays*, const char*)
Semantic equality hit:void test_arrays(Arrays*, const char*)->void 
test_const_volatile_arrays(ConstVolatileArrays*, const char*)

So we'll get less warnings than expected.

Martin

> 
> Thanks
> Martin
> 
>> * gcc.dg/tree-ssa/pr64910-2.c: Likewise.
>> * gcc.dg/tree-ssa/pr79352.c: Likewise.
>> * gcc.dg/ipa/ipa-icf-40.c: New test.
>> ---
>>   gcc/ipa-icf-gimple.c  | 12 ---
>>   .../c-c++-common/Wstringop-truncation-4.c |  2 +-
>>   gcc/testsuite/gcc.dg/ipa/ipa-icf-40.c | 32 +++
>>   gcc/testsuite/gcc.dg/tree-ssa/pr64910-2.c |  2 +-
>>   gcc/testsuite/gcc.dg/tree-ssa/pr79352.c   |  2 +-
>>   5 files changed, 35 insertions(+), 15 deletions(-)
>>   create mode 100644 gcc/testsuite/gcc.dg/ipa/ipa-icf-40.c
>>
> 



Re: [PATCH 9/9] Remove alias set comparison.

2019-08-07 Thread Martin Sebor

On 6/11/19 1:36 AM, Martin Liska wrote:


gcc/ChangeLog:

2019-07-24  Martin Liska  

* ipa-icf-gimple.c (func_checker::compatible_types_p):
Do not compare alias sets.  It's handled by operand_equal_p.

gcc/testsuite/ChangeLog:

2019-07-24  Martin Liska  

* c-c++-common/Wstringop-truncation-4.c: Disable IPA ICF.


What fails without the change?

Thanks
Martin


* gcc.dg/tree-ssa/pr64910-2.c: Likewise.
* gcc.dg/tree-ssa/pr79352.c: Likewise.
* gcc.dg/ipa/ipa-icf-40.c: New test.
---
  gcc/ipa-icf-gimple.c  | 12 ---
  .../c-c++-common/Wstringop-truncation-4.c |  2 +-
  gcc/testsuite/gcc.dg/ipa/ipa-icf-40.c | 32 +++
  gcc/testsuite/gcc.dg/tree-ssa/pr64910-2.c |  2 +-
  gcc/testsuite/gcc.dg/tree-ssa/pr79352.c   |  2 +-
  5 files changed, 35 insertions(+), 15 deletions(-)
  create mode 100644 gcc/testsuite/gcc.dg/ipa/ipa-icf-40.c





[PATCH 9/9] Remove alias set comparison.

2019-08-06 Thread Martin Liska

gcc/ChangeLog:

2019-07-24  Martin Liska  

* ipa-icf-gimple.c (func_checker::compatible_types_p):
Do not compare alias sets.  It's handled by operand_equal_p.

gcc/testsuite/ChangeLog:

2019-07-24  Martin Liska  

* c-c++-common/Wstringop-truncation-4.c: Disable IPA ICF.
* gcc.dg/tree-ssa/pr64910-2.c: Likewise.
* gcc.dg/tree-ssa/pr79352.c: Likewise.
* gcc.dg/ipa/ipa-icf-40.c: New test.
---
 gcc/ipa-icf-gimple.c  | 12 ---
 .../c-c++-common/Wstringop-truncation-4.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-40.c | 32 +++
 gcc/testsuite/gcc.dg/tree-ssa/pr64910-2.c |  2 +-
 gcc/testsuite/gcc.dg/tree-ssa/pr79352.c   |  2 +-
 5 files changed, 35 insertions(+), 15 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/ipa/ipa-icf-40.c

diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
index 375aadad412..751d5859706 100644
--- a/gcc/ipa-icf-gimple.c
+++ b/gcc/ipa-icf-gimple.c
@@ -31,7 +31,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "cgraph.h"
 #include "data-streamer.h"
 #include "gimple-pretty-print.h"
-#include "alias.h"
 #include "fold-const.h"
 #include "gimple-iterator.h"
 #include "ipa-utils.h"
@@ -209,17 +208,6 @@ func_checker::compatible_types_p (tree t1, tree t2)
   if (!types_compatible_p (t1, t2))
 return return_false_with_msg ("types are not compatible");
 
-  /* We do a lot of unnecesary matching of types that are not being
- accessed and thus do not need to be compatible.  In longer term we should
- remove these checks on all types which are not accessed as memory
- locations.
-
- For time being just avoid calling get_alias_set on types that are not
- having alias sets defined at all.  */
-  if (type_with_alias_set_p (t1) && type_with_alias_set_p (t2)
-  && get_alias_set (t1) != get_alias_set (t2))
-return return_false_with_msg ("alias sets are different");
-
   return true;
 }
 
diff --git a/gcc/testsuite/c-c++-common/Wstringop-truncation-4.c b/gcc/testsuite/c-c++-common/Wstringop-truncation-4.c
index c76f2823daf..15209536add 100644
--- a/gcc/testsuite/c-c++-common/Wstringop-truncation-4.c
+++ b/gcc/testsuite/c-c++-common/Wstringop-truncation-4.c
@@ -3,7 +3,7 @@
Verify that -Wstringop-truncation is issued for uses of arrays and
pointers to qualified forms of characters of all three types.
{ dg-do compile }
-   { dg-options "-O2 -Wall -Wstringop-truncation" } */
+   { dg-options "-O2 -Wall -Wstringop-truncation -fno-ipa-icf" } */
 
 #if __cplusplus
 extern "C"
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-40.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-40.c
new file mode 100644
index 000..8d512cbc7d3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-40.c
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf"  } */
+
+struct A { int i; char a1[10]; };
+struct B { int i; char a3[30]; };
+struct C { int i; char ax[]; };
+
+static int
+__attribute__((noinline))
+test_array_1 (int i, struct A *a)
+{
+  return __builtin_printf ("%-s\n", a->a1);
+}
+
+static int
+__attribute__((noinline))
+test_array_3 (int i, struct B *b)
+{
+  return __builtin_printf ("%-s\n", b->a3);
+}
+
+struct A a = { 0, "foo" };
+struct B b = { 0, "bar" };
+
+int main()
+{
+  test_array_1 (0, );
+  test_array_3 (0, );
+  return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr64910-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr64910-2.c
index 2e3d6790776..812bfa48825 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr64910-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr64910-2.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-reassoc1" } */
+/* { dg-options "-O2 -fdump-tree-reassoc1 -fno-ipa-icf" } */
 
 /* We want to make sure that we reassociate in a way that has the
constant last.  With the constant last, it's more likely to result
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr79352.c b/gcc/testsuite/gcc.dg/tree-ssa/pr79352.c
index 485e2d64cb3..36e195c3a06 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr79352.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr79352.c
@@ -1,7 +1,7 @@
 /* PR tree-optimization/79352 - -fprintf-return-value doesn't handle
flexible-like array members properly
{ dg-do compile }
-   { dg-options "-O2 -fdump-tree-optimized" } */
+   { dg-options "-O2 -fdump-tree-optimized -fno-ipa-icf" } */
 
 struct A { int i; char a1[1]; };
 struct B { int i; char a3[3]; };