From 8a7df0316d5332199127912ef048cccdc8d86bac Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 9 Mar 2017 11:10:02 +0100 Subject: [PATCH] Fix ICE in tree-chkp-opt.c (PR tree-optimization/79631). 2017-03-09 Martin Liska PR tree-optimization/79631 * tree-chkp-opt.c (chkp_is_constant_addr): Call tree_int_cst_sign_bit just for INTEGER constants. 2017-03-09 Martin Liska PR tree-optimization/79631 * gcc.target/i386/mpx/pr79631.c: New test. From-SVN: r245998 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/mpx/pr79631.c | 15 +++++++++++++++ gcc/tree-chkp-opt.c | 4 +++- 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/mpx/pr79631.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 33670abf0f2..c3718e31b04 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-03-09 Martin Liska + + PR tree-optimization/79631 + * tree-chkp-opt.c (chkp_is_constant_addr): Call + tree_int_cst_sign_bit just for INTEGER constants. + 2017-03-09 Martin Liska PR target/65705 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e31735b3391..f576273d9c1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-03-09 Martin Liska + + PR tree-optimization/79631 + * gcc.target/i386/mpx/pr79631.c: New test. + 2017-03-09 Martin Liska PR target/65705 diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79631.c b/gcc/testsuite/gcc.target/i386/mpx/pr79631.c new file mode 100644 index 00000000000..075d46b835f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/pr79631.c @@ -0,0 +1,15 @@ +/* { dg-do compile { target { ! x32 } } } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */ + +typedef struct { int _mp_size; } mpz_t[1]; +int a, b; +void fn1() +{ + mpz_t c[1][b]; + for (;;) { + int d = 0 >= 0 ? 0 == 0 ? c[0][0]->_mp_size ? -1 : 0 : 0 : 0, + e = 0 >= 0 ? 0 == 0 ? c[1][1]->_mp_size ? -1 : 0 : 0 : 0; + if (d != e) + a++; + } +} diff --git a/gcc/tree-chkp-opt.c b/gcc/tree-chkp-opt.c index ebe05459773..ab98edb4f40 100644 --- a/gcc/tree-chkp-opt.c +++ b/gcc/tree-chkp-opt.c @@ -239,9 +239,11 @@ chkp_is_constant_addr (const address_t &addr, int *sign) return false; else if (addr.pol[0].var) return false; + else if (TREE_CODE (addr.pol[0].cst) != INTEGER_CST) + return false; else if (integer_zerop (addr.pol[0].cst)) *sign = 0; - else if (tree_int_cst_sign_bit (addr.pol[0].cst)) + else if (tree_int_cst_sign_bit (addr.pol[0].cst)) *sign = -1; else *sign = 1; -- 2.30.2