From: Martin Liska Date: Fri, 17 Feb 2017 14:46:14 +0000 (+0100) Subject: Use HOST_WIDE_INT for a param calculation (PR rtl-optimization/79574). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a261ee491356c5d4a152bcf02415243bb9eb185b;p=gcc.git Use HOST_WIDE_INT for a param calculation (PR rtl-optimization/79574). 2017-02-17 Martin Liska PR rtl-optimization/79574 * gcc.dg/pr79574.c: New test. 2017-02-17 Martin Liska PR rtl-optimization/79574 * gcse.c (want_to_gcse_p): Prevent integer overflow. From-SVN: r245531 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index defd5431ef1..ec8049b6817 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-02-17 Martin Liska + + PR rtl-optimization/79574 + * gcse.c (want_to_gcse_p): Prevent integer overflow. + 2017-02-17 Martin Liska PR tree-optimization/79529 diff --git a/gcc/gcse.c b/gcc/gcse.c index d28288df95c..5c6984c3240 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -790,7 +790,7 @@ want_to_gcse_p (rtx x, machine_mode mode, int *max_distance_ptr) /* PRE doesn't implement max_distance restriction. */ { int cost; - int max_distance; + HOST_WIDE_INT max_distance; gcc_assert (!optimize_function_for_speed_p (cfun) && optimize_function_for_size_p (cfun)); @@ -798,7 +798,8 @@ want_to_gcse_p (rtx x, machine_mode mode, int *max_distance_ptr) if (cost < COSTS_N_INSNS (GCSE_UNRESTRICTED_COST)) { - max_distance = (GCSE_COST_DISTANCE_RATIO * cost) / 10; + max_distance + = ((HOST_WIDE_INT)GCSE_COST_DISTANCE_RATIO * cost) / 10; if (max_distance == 0) return 0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index abd9308a80a..d0a95d48af4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-02-17 Martin Liska + + PR rtl-optimization/79574 + * gcc.dg/pr79574.c: New test. + 2017-02-17 Marek Polacek PR middle-end/79536 diff --git a/gcc/testsuite/gcc.dg/pr79574.c b/gcc/testsuite/gcc.dg/pr79574.c new file mode 100644 index 00000000000..1b666e20d21 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr79574.c @@ -0,0 +1,10 @@ +/* PR rtl-optimization/79574 */ +/* { dg-do compile } */ +/* { dg-options "-Os --param gcse-cost-distance-ratio=2147483647" } */ + +void a (void) +{ + volatile int b; + for (;; b) + ; +}