diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2020-04-27 15:31:30 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2020-04-28 18:26:31 +0200 |
commit | 6273e85ad801e9e0bfe60451708940cd90baa67a (patch) | |
tree | 476c2f7517353db9ab23ebaf2f9b239990762c86 | |
parent | 4a7bfd79b39b751f7fd864c4e65c478dea9d3dd2 (diff) | |
download | gcc-6273e85ad801e9e0bfe60451708940cd90baa67a.zip gcc-6273e85ad801e9e0bfe60451708940cd90baa67a.tar.gz gcc-6273e85ad801e9e0bfe60451708940cd90baa67a.tar.bz2 |
Fix operator_mult::op1_range for when overflow wraps.
We can't solve 0 = OP1 * N by dividing by N with a wrapping type.
For example: For 0 = OP1 * 2, OP1 could be 0, or MAXINT.
So bail, when overflow wraps.
-rw-r--r-- | gcc/range-op.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 85fb187..ec60af0 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -1123,6 +1123,18 @@ operator_mult::op1_range (irange &r, tree type, const irange &lhs, const irange &op2) const { tree offset; + + // FIXME: We can't solve 0 = OP1 * N by dividing by N with a + // wrapping type. Bail for now. + // + // For example: For 0 = OP1 * 2, OP1 could be 0, or + // MAXINT. + // + // For example: For 4 = OP1 * 2, OP1 could be 2 or 130 (unsigned + // 8-bit) + if (TYPE_OVERFLOW_WRAPS (type)) + return false; + if (op2.singleton_p (&offset) && !integer_zerop (offset)) return range_op_handler (TRUNC_DIV_EXPR, type)->fold_range (r, type, lhs, op2); |