Hi,

On Mon, Aug 31 2020, Feng Xue OS wrote:
> This patch is to fix a bug that cost that is used to evaluate clone candidate
> becomes negative due to integer overflow.
>
> Feng
> ---
> 2020-08-31  Feng Xue  <f...@os.amperecomputing.com>
>
> gcc/
>         PR tree-optimization/96806

the component is "ipa," please change that when you commit the patch.

>         * ipa-cp.c (decide_about_value): Use safe_add to avoid cost addition
>         overflow.

assuming you have bootstrapped and tested it, it is OK for both trunk
and all affected release branches.

Thank you,

Martin

>
> gcc/testsuite/
>         PR tree-optimization/96806
>         * g++.dg/ipa/pr96806.C: New test.
> From 8d92b4ca4be2303a73f0a2441e57564488ca1c23 Mon Sep 17 00:00:00 2001
> From: Feng Xue <f...@os.amperecomputing.com>
> Date: Mon, 31 Aug 2020 15:00:52 +0800
> Subject: [PATCH] ipa/96806 - Fix ICE in ipa-cp due to integer addition
>  overflow
>
> 2020-08-31  Feng Xue  <f...@os.amperecomputing.com>
>
> gcc/
>         PR tree-optimization/96806
>         * ipa-cp.c (decide_about_value): Use safe_add to avoid cost addition
>       overflow.
>
> gcc/testsuite/
>         PR tree-optimization/96806
>         * g++.dg/ipa/pr96806.C: New test.
> ---
>  gcc/ipa-cp.c                       |  8 ++---
>  gcc/testsuite/g++.dg/ipa/pr96806.C | 53 ++++++++++++++++++++++++++++++
>  2 files changed, 57 insertions(+), 4 deletions(-)
>  create mode 100644 gcc/testsuite/g++.dg/ipa/pr96806.C
>
> diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
> index e4910a04ffa..8e5d6e2a393 100644
> --- a/gcc/ipa-cp.c
> +++ b/gcc/ipa-cp.c
> @@ -5480,11 +5480,11 @@ decide_about_value (struct cgraph_node *node, int 
> index, HOST_WIDE_INT offset,
>                                  freq_sum, count_sum,
>                                  val->local_size_cost)
>        && !good_cloning_opportunity_p (node,
> -                                   val->local_time_benefit
> -                                   + val->prop_time_benefit,
> +                                   safe_add (val->local_time_benefit,
> +                                             val->prop_time_benefit),
>                                     freq_sum, count_sum,
> -                                   val->local_size_cost
> -                                   + val->prop_size_cost))
> +                                   safe_add (val->local_size_cost,
> +                                             val->prop_size_cost)))
>      return false;
>  
>    if (dump_file)

[...]

Reply via email to