summaryrefslogtreecommitdiff
path: root/gcc/gcse.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2017-02-17 15:46:14 +0100
committerMartin Liska <marxin@gcc.gnu.org>2017-02-17 14:46:14 +0000
commita261ee491356c5d4a152bcf02415243bb9eb185b (patch)
tree7954301496dfe1429e4202e6c3eb06ba39578afd /gcc/gcse.c
parentc6b0d21d49a2605b2c667cec37b31140133b1fd5 (diff)
Use HOST_WIDE_INT for a param calculation (PR rtl-optimization/79574).
2017-02-17 Martin Liska <mliska@suse.cz> PR rtl-optimization/79574 * gcc.dg/pr79574.c: New test. 2017-02-17 Martin Liska <mliska@suse.cz> PR rtl-optimization/79574 * gcse.c (want_to_gcse_p): Prevent integer overflow. From-SVN: r245531
Diffstat (limited to 'gcc/gcse.c')
-rw-r--r--gcc/gcse.c5
1 files changed, 3 insertions, 2 deletions
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;