diff mbox series

Fix thinko in estimate_local_effects in IPA-CP

Message ID ri6in3qlqlk.fsf@suse.cz
State New
Headers show
Series Fix thinko in estimate_local_effects in IPA-CP | expand

Commit Message

Martin Jambor Aug. 31, 2018, 11:31 a.m. UTC
Hi,

I have discovered the following thinko in IPA-CP's
estimate_local_effects added during conversion to use nonspecialized
time.  The intent clearly was to add an upper bound to the time
difference, not a lower one.

The patch introduces a guality failure:

  gcc.dg/guality/pr41616-1.c   -O3 -g  -DPREVENT_OPTIMIZATION  execution test

the testcase however also already fails at -O2 and -O3 -flto and it
occurs now also at -O3 because we do not clone a function which we quite
clearly shouldn't.

Bootstrapped and tested on x86_64-linux, I have also made sure the
change does not affect SPEC 2006 and 2017 -Ofast.  OK for trunk?

Thanks,

Martin


2018-08-23  Martin Jambor  <mjambor@suse.cz>

	* ipa-cp.c (estimate_local_effects): Replace wrong MAX with MIN.
---
 gcc/ipa-cp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Richard Biener Aug. 31, 2018, 11:34 a.m. UTC | #1
On Fri, Aug 31, 2018 at 1:31 PM Martin Jambor <mjambor@suse.cz> wrote:
>
> Hi,
>
> I have discovered the following thinko in IPA-CP's
> estimate_local_effects added during conversion to use nonspecialized
> time.  The intent clearly was to add an upper bound to the time
> difference, not a lower one.
>
> The patch introduces a guality failure:
>
>   gcc.dg/guality/pr41616-1.c   -O3 -g  -DPREVENT_OPTIMIZATION  execution test
>
> the testcase however also already fails at -O2 and -O3 -flto and it
> occurs now also at -O3 because we do not clone a function which we quite
> clearly shouldn't.
>
> Bootstrapped and tested on x86_64-linux, I have also made sure the
> change does not affect SPEC 2006 and 2017 -Ofast.  OK for trunk?

OK.

> Thanks,
>
> Martin
>
>
> 2018-08-23  Martin Jambor  <mjambor@suse.cz>
>
>         * ipa-cp.c (estimate_local_effects): Replace wrong MAX with MIN.
> ---
>  gcc/ipa-cp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
> index 42dd4cc2904..2117529aebb 100644
> --- a/gcc/ipa-cp.c
> +++ b/gcc/ipa-cp.c
> @@ -2911,7 +2911,7 @@ estimate_local_effects (struct cgraph_node *node)
>                      "known contexts, code not going to grow.\n");
>         }
>        else if (good_cloning_opportunity_p (node,
> -                                          MAX ((base_time - time).to_int (),
> +                                          MIN ((base_time - time).to_int (),
>                                                 65536),
>                                            stats.freq_sum, stats.count_sum,
>                                            size))
> --
> 2.18.0
>
diff mbox series

Patch

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 42dd4cc2904..2117529aebb 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -2911,7 +2911,7 @@  estimate_local_effects (struct cgraph_node *node)
 		     "known contexts, code not going to grow.\n");
 	}
       else if (good_cloning_opportunity_p (node,
-					   MAX ((base_time - time).to_int (),
+					   MIN ((base_time - time).to_int (),
 						65536),
 					   stats.freq_sum, stats.count_sum,
 					   size))