Patchwork Steam out non-explicit -fno-tree-loop-distribute-patterns for LTO options

login
register
mail settings
Submitter Kito Cheng
Date Aug. 27, 2014, 2:42 p.m.
Message ID <CA+yXCZAKvQYY4us+RawpSxmfZ4LFdRSw_qiJDgmOJxAdVLAPQA@mail.gmail.com>
Download mbox | patch
Permalink /patch/383468/
State New
Headers show

Comments

Kito Cheng - Aug. 27, 2014, 2:42 p.m.
Hi all:

This patch basically is extension for r210100[1], stream out
non-explicit -fno-tree-loop-distribute-patterns since compile with
`-flto -O3 -fno-builtin` still may gen builtin function call during
LTO phase.

LTO bootstrapped and tested on x86_64-unknown-linux-gnu.

2014-09-27  Kito Cheng  <kito@0xlab.org>

    * lto-opts.c (lto_write_options): Output non-explicit
    -fno-tree-loop-distribute-patterns.
    * lto-wrapper.c (merge_and_complain): Merge
    -fno-tree-loop-distribute-patterns conservatively.
    (run_gcc): Pass through -fno-tree-loop-distribute-patterns.


[1] https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=210100
Richard Guenther - Aug. 28, 2014, 8:45 a.m.
On Wed, Aug 27, 2014 at 4:42 PM, Kito Cheng <kito.cheng@gmail.com> wrote:
> Hi all:
>
> This patch basically is extension for r210100[1], stream out
> non-explicit -fno-tree-loop-distribute-patterns since compile with
> `-flto -O3 -fno-builtin` still may gen builtin function call during
> LTO phase.
>
> LTO bootstrapped and tested on x86_64-unknown-linux-gnu.

Hmm, but that will for two units, one compiled with -O2 and one
compiled with -O3, produce -O3 -fno-tree-loop-distribute-patterns.
The previous patch restricted this to -ffreestanding / -fno-builtin.

I think it makes more sense to preserve -fno-builtin, that is,
add 'LTO' to the list of FEs supporting 'fbuiltin' (the non-joined version)
and stream '-fno-builtin' if set, doing similar option post-processing
in the LTO frontend as I added to the C family frontends.

Richard.

> 2014-09-27  Kito Cheng  <kito@0xlab.org>
>
>     * lto-opts.c (lto_write_options): Output non-explicit
>     -fno-tree-loop-distribute-patterns.
>     * lto-wrapper.c (merge_and_complain): Merge
>     -fno-tree-loop-distribute-patterns conservatively.
>     (run_gcc): Pass through -fno-tree-loop-distribute-patterns.
>
>
> [1] https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=210100
Kito Cheng - Aug. 28, 2014, 9:06 a.m.
Hi Richard:

I think preserve -fno-builtin is better than
-fno-tree-loop-distribute-patterns too,

However if we preserve -fno-builtin, the coming problem is should we
preserve all -fbuiltin-* and do the check logic[1] in common code in
gcc?

btw, in our internal gcc 4.9.x tree is move -fno-builtin to common
group (CL_COMMON) (preserve in lto since it's in CL_COMMON)  and check
it in tree-loop-distribution.c for temporary workaround .

[1] gcc/c-family/c-common.c:disable_builtin_function

On Thu, Aug 28, 2014 at 4:45 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Wed, Aug 27, 2014 at 4:42 PM, Kito Cheng <kito.cheng@gmail.com> wrote:
>> Hi all:
>>
>> This patch basically is extension for r210100[1], stream out
>> non-explicit -fno-tree-loop-distribute-patterns since compile with
>> `-flto -O3 -fno-builtin` still may gen builtin function call during
>> LTO phase.
>>
>> LTO bootstrapped and tested on x86_64-unknown-linux-gnu.
>
> Hmm, but that will for two units, one compiled with -O2 and one
> compiled with -O3, produce -O3 -fno-tree-loop-distribute-patterns.
> The previous patch restricted this to -ffreestanding / -fno-builtin.
>
> I think it makes more sense to preserve -fno-builtin, that is,
> add 'LTO' to the list of FEs supporting 'fbuiltin' (the non-joined version)
> and stream '-fno-builtin' if set, doing similar option post-processing
> in the LTO frontend as I added to the C family frontends.
>
> Richard.
>
>> 2014-09-27  Kito Cheng  <kito@0xlab.org>
>>
>>     * lto-opts.c (lto_write_options): Output non-explicit
>>     -fno-tree-loop-distribute-patterns.
>>     * lto-wrapper.c (merge_and_complain): Merge
>>     -fno-tree-loop-distribute-patterns conservatively.
>>     (run_gcc): Pass through -fno-tree-loop-distribute-patterns.
>>
>>
>> [1] https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=210100
Richard Guenther - Aug. 28, 2014, 9:29 a.m.
On Thu, 28 Aug 2014, Kito Cheng wrote:

> Hi Richard:
> 
> I think preserve -fno-builtin is better than
> -fno-tree-loop-distribute-patterns too,
> 
> However if we preserve -fno-builtin, the coming problem is should we
> preserve all -fbuiltin-* and do the check logic[1] in common code in
> gcc?

No, just -fno-builtin.
 
> btw, in our internal gcc 4.9.x tree is move -fno-builtin to common
> group (CL_COMMON) (preserve in lto since it's in CL_COMMON)  and check
> it in tree-loop-distribution.c for temporary workaround .
> 
> [1] gcc/c-family/c-common.c:disable_builtin_function
> 
> On Thu, Aug 28, 2014 at 4:45 PM, Richard Biener
> <richard.guenther@gmail.com> wrote:
> > On Wed, Aug 27, 2014 at 4:42 PM, Kito Cheng <kito.cheng@gmail.com> wrote:
> >> Hi all:
> >>
> >> This patch basically is extension for r210100[1], stream out
> >> non-explicit -fno-tree-loop-distribute-patterns since compile with
> >> `-flto -O3 -fno-builtin` still may gen builtin function call during
> >> LTO phase.
> >>
> >> LTO bootstrapped and tested on x86_64-unknown-linux-gnu.
> >
> > Hmm, but that will for two units, one compiled with -O2 and one
> > compiled with -O3, produce -O3 -fno-tree-loop-distribute-patterns.
> > The previous patch restricted this to -ffreestanding / -fno-builtin.
> >
> > I think it makes more sense to preserve -fno-builtin, that is,
> > add 'LTO' to the list of FEs supporting 'fbuiltin' (the non-joined version)
> > and stream '-fno-builtin' if set, doing similar option post-processing
> > in the LTO frontend as I added to the C family frontends.
> >
> > Richard.
> >
> >> 2014-09-27  Kito Cheng  <kito@0xlab.org>
> >>
> >>     * lto-opts.c (lto_write_options): Output non-explicit
> >>     -fno-tree-loop-distribute-patterns.
> >>     * lto-wrapper.c (merge_and_complain): Merge
> >>     -fno-tree-loop-distribute-patterns conservatively.
> >>     (run_gcc): Pass through -fno-tree-loop-distribute-patterns.
> >>
> >>
> >> [1] https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=210100
> 
>
Kito Cheng - Aug. 28, 2014, 10:28 a.m.
Hi Richard:

thanks you comment :)

I send new patch for move -fno-builtin to common.opt and check it in
lto-lang.c (lto_post_options).
https://gcc.gnu.org/ml/gcc-patches/2014-08/msg02555.html
https://gcc.gnu.org/ml/gcc-patches/2014-08/msg02556.html

On Thu, Aug 28, 2014 at 5:29 PM, Richard Biener <rguenther@suse.de> wrote:
> On Thu, 28 Aug 2014, Kito Cheng wrote:
>
>> Hi Richard:
>>
>> I think preserve -fno-builtin is better than
>> -fno-tree-loop-distribute-patterns too,
>>
>> However if we preserve -fno-builtin, the coming problem is should we
>> preserve all -fbuiltin-* and do the check logic[1] in common code in
>> gcc?
>
> No, just -fno-builtin.
>
>> btw, in our internal gcc 4.9.x tree is move -fno-builtin to common
>> group (CL_COMMON) (preserve in lto since it's in CL_COMMON)  and check
>> it in tree-loop-distribution.c for temporary workaround .
>>
>> [1] gcc/c-family/c-common.c:disable_builtin_function
>>
>> On Thu, Aug 28, 2014 at 4:45 PM, Richard Biener
>> <richard.guenther@gmail.com> wrote:
>> > On Wed, Aug 27, 2014 at 4:42 PM, Kito Cheng <kito.cheng@gmail.com> wrote:
>> >> Hi all:
>> >>
>> >> This patch basically is extension for r210100[1], stream out
>> >> non-explicit -fno-tree-loop-distribute-patterns since compile with
>> >> `-flto -O3 -fno-builtin` still may gen builtin function call during
>> >> LTO phase.
>> >>
>> >> LTO bootstrapped and tested on x86_64-unknown-linux-gnu.
>> >
>> > Hmm, but that will for two units, one compiled with -O2 and one
>> > compiled with -O3, produce -O3 -fno-tree-loop-distribute-patterns.
>> > The previous patch restricted this to -ffreestanding / -fno-builtin.
>> >
>> > I think it makes more sense to preserve -fno-builtin, that is,
>> > add 'LTO' to the list of FEs supporting 'fbuiltin' (the non-joined version)
>> > and stream '-fno-builtin' if set, doing similar option post-processing
>> > in the LTO frontend as I added to the C family frontends.
>> >
>> > Richard.
>> >
>> >> 2014-09-27  Kito Cheng  <kito@0xlab.org>
>> >>
>> >>     * lto-opts.c (lto_write_options): Output non-explicit
>> >>     -fno-tree-loop-distribute-patterns.
>> >>     * lto-wrapper.c (merge_and_complain): Merge
>> >>     -fno-tree-loop-distribute-patterns conservatively.
>> >>     (run_gcc): Pass through -fno-tree-loop-distribute-patterns.
>> >>
>> >>
>> >> [1] https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=210100
>>
>>
>
> --
> Richard Biener <rguenther@suse.de>
> SUSE / SUSE Labs
> SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
> GF: Jeff Hawn, Jennifer Guild, Felix Imend"orffer

Patch

From a4d8d1218975413eba8a339e72066ef63649b8a6 Mon Sep 17 00:00:00 2001
From: Kito Cheng <kito@andestech.com>
Date: Tue, 26 Aug 2014 16:44:06 +0800
Subject: [PATCH] Steam out non-explicit -fno-tree-loop-distribute-patterns for
 LTO options

2014-09-26  Kito Cheng  <kito@0xlab.org>

	* lto-opts.c (lto_write_options): Output non-explicit
	-fno-tree-loop-distribute-patterns.
	* lto-wrapper.c (merge_and_complain): Merge
	-fno-tree-loop-distribute-patterns conservatively.
	(run_gcc): Pass through -fno-tree-loop-distribute-patterns.
---
 gcc/lto-opts.c    | 4 ++++
 gcc/lto-wrapper.c | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/gcc/lto-opts.c b/gcc/lto-opts.c
index 986fb97..250d734 100644
--- a/gcc/lto-opts.c
+++ b/gcc/lto-opts.c
@@ -127,6 +127,10 @@  lto_write_options (void)
       && !global_options.x_flag_strict_overflow)
     append_to_collect_gcc_options (&temporary_obstack, &first_p,
 			       "-fno-strict-overflow");
+  if (!global_options_set.x_flag_tree_loop_distribute_patterns
+      && !global_options.x_flag_tree_loop_distribute_patterns)
+    append_to_collect_gcc_options (&temporary_obstack, &first_p,
+				   "-fno-tree-loop-distribute-patterns");
 
   /* Output explicitly passed options.  */
   for (i = 1; i < save_decoded_options_count; ++i)
diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index 08fd090..242c128 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -247,6 +247,7 @@  merge_and_complain (struct cl_decoded_option **decoded_options,
 
 	case OPT_ftrapv:
 	case OPT_fstrict_overflow:
+	case OPT_ftree_loop_distribute_patterns:
 	case OPT_ffp_contract_:
 	  /* For selected options we can merge conservatively.  */
 	  for (j = 0; j < *decoded_options_count; ++j)
@@ -505,6 +506,7 @@  run_gcc (unsigned argc, char *argv[])
 	case OPT_fwrapv:
 	case OPT_ftrapv:
 	case OPT_fstrict_overflow:
+	case OPT_ftree_loop_distribute_patterns:
 	case OPT_O:
 	case OPT_Ofast:
 	case OPT_Og:
-- 
1.9.3