diff options
author | Jakub Jelinek <jakub@redhat.com> | 2013-04-12 10:18:59 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2013-04-12 10:18:59 +0200 |
commit | 06f9b387e517d6f54b6c9b35d4f972bc1542855c (patch) | |
tree | a5b70e4d1a91908233d26fcca4ff9a8cf10fcd82 /gcc/fold-const.c | |
parent | 953094d2f8d7963f52c26d177c62db7220efb1b3 (diff) | |
download | gcc-06f9b387e517d6f54b6c9b35d4f972bc1542855c.zip gcc-06f9b387e517d6f54b6c9b35d4f972bc1542855c.tar.gz gcc-06f9b387e517d6f54b6c9b35d4f972bc1542855c.tar.bz2 |
re PR tree-optimization/56918 (incorrect auto-vectorization of array initialization)
PR tree-optimization/56918
PR tree-optimization/56920
* fold-const.c (int_const_binop_1): Use op1.mul_with_sign (op2, ...)
instead of op1 - op2. Pass 2 * TYPE_PRECISION (type) as second
argument to rshift method. For 2 * HOST_BITS_PER_WIDE_INT precision
use wide_mul_with_sign method.
* gcc.dg/vect/pr56918.c: New test.
* gcc.dg/vect/pr56920.c: New test.
From-SVN: r197846
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index e8187cb..59dbc03 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -984,12 +984,22 @@ int_const_binop_1 (enum tree_code code, const_tree arg1, const_tree arg2, break; case MULT_HIGHPART_EXPR: - /* ??? Need quad precision, or an additional shift operand - to the multiply primitive, to handle very large highparts. */ if (TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT) - return NULL_TREE; - tmp = op1 - op2; - res = tmp.rshift (TYPE_PRECISION (type), TYPE_PRECISION (type), !uns); + { + bool dummy_overflow; + if (TYPE_PRECISION (type) != 2 * HOST_BITS_PER_WIDE_INT) + return NULL_TREE; + op1.wide_mul_with_sign (op2, uns, &res, &dummy_overflow); + } + else + { + bool dummy_overflow; + /* MULT_HIGHPART_EXPR can't ever oveflow, as the multiplication + is performed in twice the precision of arguments. */ + tmp = op1.mul_with_sign (op2, false, &dummy_overflow); + res = tmp.rshift (TYPE_PRECISION (type), + 2 * TYPE_PRECISION (type), !uns); + } break; case TRUNC_DIV_EXPR: |