Re: [PATCH 2/2] IPA ICF: make algorithm stable to survive -fcompare-debug

2017-01-18 Thread Martin Liška
On 01/18/2017 01:35 AM, Dominik Vogt wrote:
> On Tue, Jan 10, 2017 at 03:40:00PM +0100, Martin Liška wrote:
>> On 01/10/2017 02:56 PM, Richard Biener wrote:
>>> On Mon, Jan 9, 2017 at 4:05 PM, Martin Liška  wrote:
 Second part of the patch does sorting of final congruence classes, it's 
 groups
 and items included in the groups according DECL_UID.

 Both patches can bootstrap together on ppc64le-redhat-linux and survive 
 regression tests.

 Ready to be installed?
>>>
>>> Minor nit:
>>>
>>> +  auto_vec  classes;
>>> +  for (hash_table::iterator it = m_classes.begin ();
>>> +   it != m_classes.end (); ++it)
>>> +classes.safe_push (*it);
>>>
>>> use quick_push and reserve_exact m_classes.elements () elements for
>>> the classes vector before.
>>
>> Thanks for hint.
>>
>>>
>>> +
>>> +  classes.qsort (sort_congruence_class_groups_by_decl_uid);
>>>
>>> Ok with that change.
>>
>> Installed as r244273.
> 
> This patch has somehow broken the error line information in some
> s390x test case:
> 
> .../build/gcc/xgcc -B.../gcc/ 
> .../gcc/testsuite/gcc.target/s390/target-attribute/tattr-2.c -O3 -march=zEC12 
> -mno-htm -S -m64 -o tattr-2.s
> 
> ...
> .../gcc/testsuite/gcc.target/s390/target-attribute/tattr-2.c:
> In function ‘a0’:
> 
> .../gcc/testsuite/gcc.target/s390/target-attribute/tattr-2.c:23:3:
> 
> error: Builtin ‘__builtin_tend’ is not supported without -mhtm
> (default with -march=zEC12 and higher).

Hello.

As I've been reading when the warning is emitted (rtl expansion), I guess a 
pair of function was merged
by IPA ICF and thus the location points to a different function.

I can't reproduce the test-case due to missing __HTM__. Can you please provide 
pre-processed source file?

Thanks,
Martin

> 
> But function a0 is actually in lines 37 to 43.  It looks like the
> message has used the same line number as the previous message.
> 
> Ciao
> 
> Dominik ^_^  ^_^
> 



Re: [PATCH 2/2] IPA ICF: make algorithm stable to survive -fcompare-debug

2017-01-17 Thread Dominik Vogt
On Tue, Jan 10, 2017 at 03:40:00PM +0100, Martin Liška wrote:
> On 01/10/2017 02:56 PM, Richard Biener wrote:
> >On Mon, Jan 9, 2017 at 4:05 PM, Martin Liška  wrote:
> >>Second part of the patch does sorting of final congruence classes, it's 
> >>groups
> >>and items included in the groups according DECL_UID.
> >>
> >>Both patches can bootstrap together on ppc64le-redhat-linux and survive 
> >>regression tests.
> >>
> >>Ready to be installed?
> >
> >Minor nit:
> >
> >+  auto_vec  classes;
> >+  for (hash_table::iterator it = m_classes.begin ();
> >+   it != m_classes.end (); ++it)
> >+classes.safe_push (*it);
> >
> >use quick_push and reserve_exact m_classes.elements () elements for
> >the classes vector before.
> 
> Thanks for hint.
> 
> >
> >+
> >+  classes.qsort (sort_congruence_class_groups_by_decl_uid);
> >
> >Ok with that change.
> 
> Installed as r244273.

This patch has somehow broken the error line information in some
s390x test case:

.../build/gcc/xgcc -B.../gcc/ 
.../gcc/testsuite/gcc.target/s390/target-attribute/tattr-2.c -O3 -march=zEC12 
-mno-htm -S -m64 -o tattr-2.s

...
.../gcc/testsuite/gcc.target/s390/target-attribute/tattr-2.c:
In function ‘a0’:

.../gcc/testsuite/gcc.target/s390/target-attribute/tattr-2.c:23:3:

error: Builtin ‘__builtin_tend’ is not supported without -mhtm
(default with -march=zEC12 and higher).

But function a0 is actually in lines 37 to 43.  It looks like the
message has used the same line number as the previous message.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany



Re: [PATCH 2/2] IPA ICF: make algorithm stable to survive -fcompare-debug

2017-01-11 Thread Jakub Jelinek
On Wed, Jan 11, 2017 at 11:48:03AM +0100, Martin Liška wrote:
> gcc/testsuite/ChangeLog:
> 
> 2017-01-11  Martin Liska  
> 
>   * gcc.dg/tree-ssa/flatten-3.c: Add -fno-ipa-icf to dg-options.
> ---
>  gcc/testsuite/gcc.dg/tree-ssa/flatten-3.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/flatten-3.c 
> b/gcc/testsuite/gcc.dg/tree-ssa/flatten-3.c
> index a1edb910e9d..153165c72e3 100644
> --- a/gcc/testsuite/gcc.dg/tree-ssa/flatten-3.c
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/flatten-3.c
> @@ -1,5 +1,5 @@
>  /* { dg-do compile } */
> -/* { dg-options -O2 } */
> +/* { dg-options -O2 -fno-ipa-icf } */
>  
>  extern void do_something_usefull();
>  /* Check that we finish compiling even if instructed to

The test still fails, now with:
ERROR: gcc.dg/tree-ssa/flatten-3.c: syntax error in target selector 
"-fno-ipa-icf" for " dg-options 2 -O2 -fno-ipa-icf "

Fixed thusly, committed as obvious:

2017-01-11  Jakub Jelinek  

* gcc.dg/tree-ssa/flatten-3.c: Add quotation marks around dg-options
argument.

--- gcc/testsuite/gcc.dg/tree-ssa/flatten-3.c   (revision 244331)
+++ gcc/testsuite/gcc.dg/tree-ssa/flatten-3.c   (working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options -O2 -fno-ipa-icf } */
+/* { dg-options "-O2 -fno-ipa-icf" } */
 
 extern void do_something_usefull();
 /* Check that we finish compiling even if instructed to


Jakub


Re: [PATCH 2/2] IPA ICF: make algorithm stable to survive -fcompare-debug

2017-01-11 Thread Richard Biener
On Wed, Jan 11, 2017 at 11:48 AM, Martin Liška  wrote:
> On 01/11/2017 11:28 AM, Jakub Jelinek wrote:
>> On Wed, Jan 11, 2017 at 11:21:08AM +0100, Christophe Lyon wrote:
>>> Since then, I've noticed that
>>>   gcc.dg/tree-ssa/flatten-3.c scan-assembler cycle[123][: \t\n]
>>> now fails on aarch64 and arm targets.
>>
>> It fails on x86_64-linux and i686-linux too.
>>
>>   Jakub
>>
>
> Ok, problem is that we used to merge:
>
> Semantic equality hit:doubleindirect1->subcycle1
> Semantic equality hit:doubleindirect1->doublesubcycle1
> Semantic equality hit:subcycle->doublesubcycle
>
> and after my patch it changed to:
>
> Semantic equality hit:doublesubcycle->subcycle
> Semantic equality hit:doublesubcycle1->subcycle1
> Semantic equality hit:doublesubcycle1->doubleindirect1
>
> As output is grepped for a cycle[123], so of them would be merged.
> Thus, adding -fno-ipa-icf would be the right fix.
>
> Ready to be installed?

Ok.

Richard.

> Thanks,
> Martin


Re: [PATCH 2/2] IPA ICF: make algorithm stable to survive -fcompare-debug

2017-01-11 Thread Martin Liška
On 01/11/2017 11:28 AM, Jakub Jelinek wrote:
> On Wed, Jan 11, 2017 at 11:21:08AM +0100, Christophe Lyon wrote:
>> Since then, I've noticed that
>>   gcc.dg/tree-ssa/flatten-3.c scan-assembler cycle[123][: \t\n]
>> now fails on aarch64 and arm targets.
> 
> It fails on x86_64-linux and i686-linux too.
> 
>   Jakub
> 

Ok, problem is that we used to merge:

Semantic equality hit:doubleindirect1->subcycle1
Semantic equality hit:doubleindirect1->doublesubcycle1
Semantic equality hit:subcycle->doublesubcycle

and after my patch it changed to:

Semantic equality hit:doublesubcycle->subcycle
Semantic equality hit:doublesubcycle1->subcycle1
Semantic equality hit:doublesubcycle1->doubleindirect1

As output is grepped for a cycle[123], so of them would be merged.
Thus, adding -fno-ipa-icf would be the right fix.

Ready to be installed?
Thanks,
Martin
>From 2facdc8b5730568ead389e7d4af8a4f6b04e9cbc Mon Sep 17 00:00:00 2001
From: marxin 
Date: Wed, 11 Jan 2017 11:46:14 +0100
Subject: [PATCH] Fix flatten-3.c test-case.

gcc/testsuite/ChangeLog:

2017-01-11  Martin Liska  

	* gcc.dg/tree-ssa/flatten-3.c: Add -fno-ipa-icf to dg-options.
---
 gcc/testsuite/gcc.dg/tree-ssa/flatten-3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/flatten-3.c b/gcc/testsuite/gcc.dg/tree-ssa/flatten-3.c
index a1edb910e9d..153165c72e3 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/flatten-3.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/flatten-3.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options -O2 } */
+/* { dg-options -O2 -fno-ipa-icf } */
 
 extern void do_something_usefull();
 /* Check that we finish compiling even if instructed to
-- 
2.11.0



Re: [PATCH 2/2] IPA ICF: make algorithm stable to survive -fcompare-debug

2017-01-11 Thread Martin Liška
On 01/11/2017 11:28 AM, Jakub Jelinek wrote:
> On Wed, Jan 11, 2017 at 11:21:08AM +0100, Christophe Lyon wrote:
>> Since then, I've noticed that
>>   gcc.dg/tree-ssa/flatten-3.c scan-assembler cycle[123][: \t\n]
>> now fails on aarch64 and arm targets.
> 
> It fails on x86_64-linux and i686-linux too.
> 
>   Jakub
> 

Sorry for the breakage, I'm going to fix that.

Martin


Re: [PATCH 2/2] IPA ICF: make algorithm stable to survive -fcompare-debug

2017-01-11 Thread Jakub Jelinek
On Wed, Jan 11, 2017 at 11:21:08AM +0100, Christophe Lyon wrote:
> Since then, I've noticed that
>   gcc.dg/tree-ssa/flatten-3.c scan-assembler cycle[123][: \t\n]
> now fails on aarch64 and arm targets.

It fails on x86_64-linux and i686-linux too.

Jakub


Re: [PATCH 2/2] IPA ICF: make algorithm stable to survive -fcompare-debug

2017-01-11 Thread Christophe Lyon
Hi Martin,

On 10 January 2017 at 15:40, Martin Liška  wrote:
> On 01/10/2017 02:56 PM, Richard Biener wrote:
>>
>> On Mon, Jan 9, 2017 at 4:05 PM, Martin Liška  wrote:
>>>
>>> Second part of the patch does sorting of final congruence classes, it's
>>> groups
>>> and items included in the groups according DECL_UID.
>>>
>>> Both patches can bootstrap together on ppc64le-redhat-linux and survive
>>> regression tests.
>>>
>>> Ready to be installed?
>>
>>
>> Minor nit:
>>
>> +  auto_vec  classes;
>> +  for (hash_table::iterator it = m_classes.begin
>> ();
>> +   it != m_classes.end (); ++it)
>> +classes.safe_push (*it);
>>
>> use quick_push and reserve_exact m_classes.elements () elements for
>> the classes vector before.
>
>
> Thanks for hint.
>
>>
>> +
>> +  classes.qsort (sort_congruence_class_groups_by_decl_uid);
>>
>> Ok with that change.
>
>
> Installed as r244273.
>
Since then, I've noticed that
  gcc.dg/tree-ssa/flatten-3.c scan-assembler cycle[123][: \t\n]
now fails on aarch64 and arm targets.

Christophe



> Martin
>
>>
>> Richard.
>>
>>
>>> Martin
>
>


Re: [PATCH 2/2] IPA ICF: make algorithm stable to survive -fcompare-debug

2017-01-10 Thread Martin Liška

On 01/10/2017 02:56 PM, Richard Biener wrote:

On Mon, Jan 9, 2017 at 4:05 PM, Martin Liška  wrote:

Second part of the patch does sorting of final congruence classes, it's groups
and items included in the groups according DECL_UID.

Both patches can bootstrap together on ppc64le-redhat-linux and survive 
regression tests.

Ready to be installed?


Minor nit:

+  auto_vec  classes;
+  for (hash_table::iterator it = m_classes.begin ();
+   it != m_classes.end (); ++it)
+classes.safe_push (*it);

use quick_push and reserve_exact m_classes.elements () elements for
the classes vector before.


Thanks for hint.



+
+  classes.qsort (sort_congruence_class_groups_by_decl_uid);

Ok with that change.


Installed as r244273.

Martin



Richard.



Martin




Re: [PATCH 2/2] IPA ICF: make algorithm stable to survive -fcompare-debug

2017-01-10 Thread Richard Biener
On Mon, Jan 9, 2017 at 4:05 PM, Martin Liška  wrote:
> Second part of the patch does sorting of final congruence classes, it's groups
> and items included in the groups according DECL_UID.
>
> Both patches can bootstrap together on ppc64le-redhat-linux and survive 
> regression tests.
>
> Ready to be installed?

Minor nit:

+  auto_vec  classes;
+  for (hash_table::iterator it = m_classes.begin ();
+   it != m_classes.end (); ++it)
+classes.safe_push (*it);

use quick_push and reserve_exact m_classes.elements () elements for
the classes vector before.

+
+  classes.qsort (sort_congruence_class_groups_by_decl_uid);

Ok with that change.

Richard.


> Martin


[PATCH 2/2] IPA ICF: make algorithm stable to survive -fcompare-debug

2017-01-09 Thread Martin Liška
Second part of the patch does sorting of final congruence classes, it's groups
and items included in the groups according DECL_UID.

Both patches can bootstrap together on ppc64le-redhat-linux and survive 
regression tests.

Ready to be installed?
Martin
>From c3baaad9da1fdaa95ff5b8a69fc7925ede13d8c9 Mon Sep 17 00:00:00 2001
From: marxin <mli...@suse.cz>
Date: Fri, 6 Jan 2017 13:30:08 +0100
Subject: [PATCH 2/2] IPA ICF: make algorithm stable to survive -fcompare-debug

gcc/testsuite/ChangeLog:

2017-01-06  Martin Liska  <mli...@suse.cz>

	* gcc.dg/ipa/ipa-icf-1.c: Change scanned pattern.
	* gcc.dg/ipa/ipa-icf-10.c: Likewise.
	* gcc.dg/ipa/ipa-icf-11.c: Likewise.
	* gcc.dg/ipa/ipa-icf-12.c: Likewise.
	* gcc.dg/ipa/ipa-icf-13.c: Likewise.
	* gcc.dg/ipa/ipa-icf-16.c: Likewise.
	* gcc.dg/ipa/ipa-icf-18.c: Likewise.
	* gcc.dg/ipa/ipa-icf-2.c: Likewise.
	* gcc.dg/ipa/ipa-icf-20.c: Likewise.
	* gcc.dg/ipa/ipa-icf-21.c: Likewise.
	* gcc.dg/ipa/ipa-icf-23.c: Likewise.
	* gcc.dg/ipa/ipa-icf-25.c: Likewise.
	* gcc.dg/ipa/ipa-icf-26.c: Likewise.
	* gcc.dg/ipa/ipa-icf-27.c: Likewise.
	* gcc.dg/ipa/ipa-icf-3.c: Likewise.
	* gcc.dg/ipa/ipa-icf-35.c: Likewise.
	* gcc.dg/ipa/ipa-icf-36.c: Likewise.
	* gcc.dg/ipa/ipa-icf-37.c: Likewise.
	* gcc.dg/ipa/ipa-icf-5.c: Likewise.
	* gcc.dg/ipa/ipa-icf-7.c: Likewise.
	* gcc.dg/ipa/ipa-icf-8.c: Likewise.
	* gcc.dg/ipa/pr64307.c: Likewise.
	* gcc.dg/ipa/pr77653.c: Likewise.

gcc/ChangeLog:

2017-01-06  Martin Liska  <mli...@suse.cz>

	* ipa-icf.c (sort_sem_items_by_decl_uid): New function.
	(sort_congruence_classes_by_decl_uid): Likewise.
	(sort_congruence_class_groups_by_decl_uid): Likewise.
	(sem_item_optimizer::merge_classes): Sort class, groups in these
	classes and members in the groups by DECL_UID of declarations.
	This would make merge operations stable.
---
 gcc/ipa-icf.c | 92 +--
 gcc/testsuite/gcc.dg/ipa/ipa-icf-1.c  |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-10.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-11.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-12.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-13.c |  6 +--
 gcc/testsuite/gcc.dg/ipa/ipa-icf-16.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-18.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-2.c  |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-20.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-21.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-23.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-25.c |  4 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-26.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-27.c |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-3.c  |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-35.c |  6 +--
 gcc/testsuite/gcc.dg/ipa/ipa-icf-36.c | 10 ++--
 gcc/testsuite/gcc.dg/ipa/ipa-icf-37.c | 10 ++--
 gcc/testsuite/gcc.dg/ipa/ipa-icf-5.c  |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-7.c  |  2 +-
 gcc/testsuite/gcc.dg/ipa/ipa-icf-8.c  |  2 +-
 gcc/testsuite/gcc.dg/ipa/pr64307.c|  2 +-
 gcc/testsuite/gcc.dg/ipa/pr77653.c|  2 +-
 24 files changed, 124 insertions(+), 40 deletions(-)

diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 28de251c421..4c835c39e3d 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -3380,6 +3380,66 @@ sem_item_optimizer::dump_cong_classes (void)
   free (histogram);
 }
 
+/* Sort pair of sem_items A and B by DECL_UID.  */
+
+static int
+sort_sem_items_by_decl_uid (const void *a, const void *b)
+{
+  const sem_item *i1 = *(const sem_item * const *)a;
+  const sem_item *i2 = *(const sem_item * const *)b;
+
+  int uid1 = DECL_UID (i1->decl);
+  int uid2 = DECL_UID (i2->decl);
+
+  if (uid1 < uid2)
+return -1;
+  else if (uid1 > uid2)
+return 1;
+  else
+return 0;
+}
+
+/* Sort pair of congruence_classes A and B by DECL_UID of the first member.  */
+
+static int
+sort_congruence_classes_by_decl_uid (const void *a, const void *b)
+{
+  const congruence_class *c1 = *(const congruence_class * const *)a;
+  const congruence_class *c2 = *(const congruence_class * const *)b;
+
+  int uid1 = DECL_UID (c1->members[0]->decl);
+  int uid2 = DECL_UID (c2->members[0]->decl);
+
+  if (uid1 < uid2)
+return -1;
+  else if (uid1 > uid2)
+return 1;
+  else
+return 0;
+}
+
+/* Sort pair of congruence_class_groups A and B by
+   DECL_UID of the first member of a first group.  */
+
+static int
+sort_congruence_class_groups_by_decl_uid (const void *a, const void *b)
+{
+  const congruence_class_group *g1
+= *(const congruence_class_group * const *)a;
+  const congruence_class_group *g2
+= *(const congruence_class_group * const *)b;
+
+  int uid1 = DECL_UID (g1->classes[0]->members[0]->decl);
+  int uid2 = DECL_UID (g2->classes[0]->members[0]->decl);
+
+  if (uid1 < uid2)
+return -1;
+  else if (uid1 > uid2)
+return 1;
+  else
+return 0;
+}
+
 /* After reduction is done, we can declare all items in a group
to be equal. PREV_CLASS_COUNT is start number of classes
before r