From 9fe3064bc60752a5252d88533cadb097ead5e05e Mon Sep 17 00:00:00 2001 From: Roman Zhuykov Date: Tue, 23 Apr 2019 13:14:57 +0000 Subject: [PATCH] modulo-sched: prevent division by zero (PR87979) PR rtl-optimization/87979 * modulo-sched.c (sms_schedule): Start ii value "mii" should not equal zero. testsuite: PR rtl-optimization/87979 * gcc.dg/pr87979.c: New test. From-SVN: r270512 --- gcc/ChangeLog | 6 ++++++ gcc/modulo-sched.c | 1 + gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr87979.c | 11 +++++++++++ 4 files changed, 23 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr87979.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f7109468b97..5ea2fa0c442 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-04-23 Roman Zhuykov + + PR rtl-optimization/87979 + * modulo-sched.c (sms_schedule): Start ii value "mii" should + not equal zero. + 2019-04-23 Roman Zhuykov PR rtl-optimization/84032 diff --git a/gcc/modulo-sched.c b/gcc/modulo-sched.c index 44014a06387..9954ea5cfa1 100644 --- a/gcc/modulo-sched.c +++ b/gcc/modulo-sched.c @@ -1597,6 +1597,7 @@ sms_schedule (void) mii = 1; /* Need to pass some estimate of mii. */ rec_mii = sms_order_nodes (g, mii, node_order, &max_asap); mii = MAX (res_MII (g), rec_mii); + mii = MAX (mii, 1); maxii = MAX (max_asap, MAXII_FACTOR * mii); if (dump_file) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 029bad5ae95..9946c868cf7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-04-23 Roman Zhuykov + + PR rtl-optimization/87979 + * gcc.dg/pr87979.c: New test. + 2019-04-23 Roman Zhuykov PR rtl-optimization/84032 diff --git a/gcc/testsuite/gcc.dg/pr87979.c b/gcc/testsuite/gcc.dg/pr87979.c new file mode 100644 index 00000000000..d3d595f4f81 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr87979.c @@ -0,0 +1,11 @@ +/* PR rtl-optimization/87979 */ +/* { dg-do compile } */ +/* { dg-options "-Os -fmodulo-sched -fno-tree-loop-im" } */ +/* { dg-additional-options "-march=z196" { target { s390*-*-* } } } */ + +void foo(void) +{ + static int m; + for (int i = 0; i < 10; ++i) + m++; +} -- 2.30.2