Commit d2391983 by Alexander Monakov Committed by Alexander Monakov

tree-loop-distribution: convert to gcc_stablesort

	* tree-loop-distribution.c (offset_cmp): Convert to C-qsort-style
	tri-state comparator.
	(fuse_memset_builtins): Change std::stable_sort to gcc_stablesort.

From-SVN: r264067
parent a6405b11
2018-09-03 Alexander Monakov <amonakov@ispras.ru> 2018-09-03 Alexander Monakov <amonakov@ispras.ru>
* tree-loop-distribution.c (offset_cmp): Convert to C-qsort-style
tri-state comparator.
(fuse_memset_builtins): Change std::stable_sort to gcc_stablesort.
2018-09-03 Alexander Monakov <amonakov@ispras.ru>
* sort.cc (struct sort_ctx): New field 'nlim'. Use it... * sort.cc (struct sort_ctx): New field 'nlim'. Use it...
(mergesort): ... here as maximum count for using netsort. (mergesort): ... here as maximum count for using netsort.
(gcc_qsort): Set nlim to 3 if stable sort is requested. (gcc_qsort): Set nlim to 3 if stable sort is requested.
......
...@@ -90,7 +90,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -90,7 +90,6 @@ along with GCC; see the file COPYING3. If not see
data reuse. */ data reuse. */
#include "config.h" #include "config.h"
#define INCLUDE_ALGORITHM /* stable_sort */
#include "system.h" #include "system.h"
#include "coretypes.h" #include "coretypes.h"
#include "backend.h" #include "backend.h"
...@@ -2561,12 +2560,14 @@ version_for_distribution_p (vec<struct partition *> *partitions, ...@@ -2561,12 +2560,14 @@ version_for_distribution_p (vec<struct partition *> *partitions,
/* Compare base offset of builtin mem* partitions P1 and P2. */ /* Compare base offset of builtin mem* partitions P1 and P2. */
static bool static int
offset_cmp (struct partition *p1, struct partition *p2) offset_cmp (const void *vp1, const void *vp2)
{ {
gcc_assert (p1 != NULL && p1->builtin != NULL); struct partition *p1 = *(struct partition *const *) vp1;
gcc_assert (p2 != NULL && p2->builtin != NULL); struct partition *p2 = *(struct partition *const *) vp2;
return p1->builtin->dst_base_offset < p2->builtin->dst_base_offset; unsigned HOST_WIDE_INT o1 = p1->builtin->dst_base_offset;
unsigned HOST_WIDE_INT o2 = p2->builtin->dst_base_offset;
return (o2 < o1) - (o1 < o2);
} }
/* Fuse adjacent memset builtin PARTITIONS if possible. This is a special /* Fuse adjacent memset builtin PARTITIONS if possible. This is a special
...@@ -2618,8 +2619,8 @@ fuse_memset_builtins (vec<struct partition *> *partitions) ...@@ -2618,8 +2619,8 @@ fuse_memset_builtins (vec<struct partition *> *partitions)
} }
/* Stable sort is required in order to avoid breaking dependence. */ /* Stable sort is required in order to avoid breaking dependence. */
std::stable_sort (&(*partitions)[i], gcc_stablesort (&(*partitions)[i], j - i, sizeof (*partitions)[i],
&(*partitions)[i] + j - i, offset_cmp); offset_cmp);
/* Continue with next partition. */ /* Continue with next partition. */
i = j; i = j;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment