diff options
author | Jakub Jelinek <jakub@redhat.com> | 2012-11-17 23:00:32 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2012-11-17 23:00:32 +0100 |
commit | 9abd8e8b634af19867783e19c17b2ee7bf1d35d4 (patch) | |
tree | be674b8ee271fc438ab948ffd1ea623f2c6a7725 /gcc/fold-const.c | |
parent | 2e63c69f49090e3b5bc73f91a12583ce3732907d (diff) | |
download | gcc-9abd8e8b634af19867783e19c17b2ee7bf1d35d4.zip gcc-9abd8e8b634af19867783e19c17b2ee7bf1d35d4.tar.gz gcc-9abd8e8b634af19867783e19c17b2ee7bf1d35d4.tar.bz2 |
re PR tree-optimization/55236 (gcc.c-torture/execute/pr22493-1.c FAILs with -fPIC)
PR tree-optimization/55236
* fold-const.c (make_range_step) <case NEGATE_EXPR>: For -fwrapv
and signed ARG0_TYPE, force low and high to be non-NULL.
* gcc.dg/pr55236.c: New test.
From-SVN: r193591
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 2e90864..56e0554 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3880,6 +3880,17 @@ make_range_step (location_t loc, enum tree_code code, tree arg0, tree arg1, return arg0; case NEGATE_EXPR: + /* If flag_wrapv and ARG0_TYPE is signed, make sure + low and high are non-NULL, then normalize will DTRT. */ + if (!TYPE_UNSIGNED (arg0_type) + && !TYPE_OVERFLOW_UNDEFINED (arg0_type)) + { + if (low == NULL_TREE) + low = TYPE_MIN_VALUE (arg0_type); + if (high == NULL_TREE) + high = TYPE_MAX_VALUE (arg0_type); + } + /* (-x) IN [a,b] -> x in [-b, -a] */ n_low = range_binop (MINUS_EXPR, exp_type, build_int_cst (exp_type, 0), |