summaryrefslogtreecommitdiff
path: root/gcc/tree-chrec.c
diff options
context:
space:
mode:
authormrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4>2013-08-13 20:41:07 +0000
committermrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4>2013-08-13 20:41:07 +0000
commite913b5cd5b6a9bd3a2ad58c65f9e3cd2bb55a28c (patch)
treef52a097017e3dcf89fad6525984e4591489f961e /gcc/tree-chrec.c
parent9a5942c1d4d9116ab74b0741cfe3894a89fd17fb (diff)
downloadgcc-e913b5cd5b6a9bd3a2ad58c65f9e3cd2bb55a28c.tar.gz
Add wide-int branch.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@201707 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-chrec.c')
-rw-r--r--gcc/tree-chrec.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c
index c18ccd3f933..8aeefb90072 100644
--- a/gcc/tree-chrec.c
+++ b/gcc/tree-chrec.c
@@ -460,7 +460,7 @@ chrec_fold_multiply (tree type,
static tree
tree_fold_binomial (tree type, tree n, unsigned int k)
{
- double_int num, denom, idx, di_res;
+ wide_int num, denom, idx, di_res;
bool overflow;
unsigned int i;
tree res;
@@ -472,20 +472,20 @@ tree_fold_binomial (tree type, tree n, unsigned int k)
return fold_convert (type, n);
/* Numerator = n. */
- num = TREE_INT_CST (n);
+ num = n;
/* Check that k <= n. */
- if (num.ult (double_int::from_uhwi (k)))
+ if (num.ltu_p (k))
return NULL_TREE;
/* Denominator = 2. */
- denom = double_int::from_uhwi (2);
+ denom = wide_int::two (TYPE_PRECISION (TREE_TYPE (n)));
/* Index = Numerator-1. */
- idx = num - double_int_one;
+ idx = num - 1;
/* Numerator = Numerator*Index = n*(n-1). */
- num = num.mul_with_sign (idx, false, &overflow);
+ num = num.smul (idx, &overflow);
if (overflow)
return NULL_TREE;
@@ -495,17 +495,17 @@ tree_fold_binomial (tree type, tree n, unsigned int k)
--idx;
/* Numerator *= Index. */
- num = num.mul_with_sign (idx, false, &overflow);
+ num = num.smul (idx, &overflow);
if (overflow)
return NULL_TREE;
/* Denominator *= i. */
- denom *= double_int::from_uhwi (i);
+ denom *= i;
}
/* Result = Numerator / Denominator. */
- di_res = num.div (denom, true, EXACT_DIV_EXPR);
- res = build_int_cst_wide (type, di_res.low, di_res.high);
+ di_res = num.udiv_trunc (denom);
+ res = wide_int_to_tree (type, di_res);
return int_fits_type_p (res, type) ? res : NULL_TREE;
}