diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2020-06-17 07:50:57 -0400 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2020-06-17 07:50:57 -0400 |
commit | b9e67f2840ce0d8859d96e7f8df8fe9584af5eba (patch) | |
tree | ed3b7284ff15c802583f6409b9c71b3739642d15 /gcc/tree-affine.c | |
parent | 1957047ed1c94bf17cf993a2b1866965f493ba87 (diff) | |
parent | 56638b9b1853666f575928f8baf17f70e4ed3517 (diff) | |
download | gcc-b9e67f2840ce0d8859d96e7f8df8fe9584af5eba.zip gcc-b9e67f2840ce0d8859d96e7f8df8fe9584af5eba.tar.gz gcc-b9e67f2840ce0d8859d96e7f8df8fe9584af5eba.tar.bz2 |
Merge from trunk at:
commit 56638b9b1853666f575928f8baf17f70e4ed3517
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date: Wed Jun 17 00:16:36 2020 +0000
Daily bump.
Diffstat (limited to 'gcc/tree-affine.c')
-rw-r--r-- | gcc/tree-affine.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/gcc/tree-affine.c b/gcc/tree-affine.c index 0eb8db1..5620e6b 100644 --- a/gcc/tree-affine.c +++ b/gcc/tree-affine.c @@ -343,24 +343,28 @@ expr_to_aff_combination (aff_tree *comb, tree_code code, tree type, wide_int minv, maxv; /* If inner type has wrapping overflow behavior, fold conversion for below case: - (T1)(X - CST) -> (T1)X - (T1)CST - if X - CST doesn't overflow by range information. Also handle - (T1)(X + CST) as (T1)(X - (-CST)). */ + (T1)(X *+- CST) -> (T1)X *+- (T1)CST + if X *+- CST doesn't overflow by range information. */ if (TYPE_UNSIGNED (itype) && TYPE_OVERFLOW_WRAPS (itype) - && TREE_CODE (op0) == SSA_NAME && TREE_CODE (op1) == INTEGER_CST - && icode != MULT_EXPR - && get_range_info (op0, &minv, &maxv) == VR_RANGE) + && determine_value_range (op0, &minv, &maxv) == VR_RANGE) { + wi::overflow_type overflow = wi::OVF_NONE; + signop sign = UNSIGNED; if (icode == PLUS_EXPR) - op1 = wide_int_to_tree (itype, -wi::to_wide (op1)); - if (wi::geu_p (minv, wi::to_wide (op1))) + wi::add (maxv, wi::to_wide (op1), sign, &overflow); + else if (icode == MULT_EXPR) + wi::mul (maxv, wi::to_wide (op1), sign, &overflow); + else + wi::sub (minv, wi::to_wide (op1), sign, &overflow); + + if (overflow == wi::OVF_NONE) { op0 = fold_convert (otype, op0); op1 = fold_convert (otype, op1); - return expr_to_aff_combination (comb, MINUS_EXPR, otype, - op0, op1); + return expr_to_aff_combination (comb, icode, otype, op0, + op1); } } } |