diff options
author | Zdenek Dvorak <dvorakz@suse.cz> | 2006-08-28 23:15:19 +0200 |
---|---|---|
committer | Zdenek Dvorak <rakdver@gcc.gnu.org> | 2006-08-28 21:15:19 +0000 |
commit | f414f2f35e4cb2f18f2da8f28777ad797cf7b0fa (patch) | |
tree | 30bc9b33718fe7a8c347a8df8410345bef4030ee /gcc/double-int.c | |
parent | 689e7ddada015f50d4e535902f3079add578bbcc (diff) | |
download | gcc-f414f2f35e4cb2f18f2da8f28777ad797cf7b0fa.tar.gz |
re PR tree-optimization/28411 ("Illegal instruction" error with -ftrapv)
PR tree-optimization/28411
* double-int.c (double_int_div): Use double_int_divmod.
(double_int_divmod, double_int_sdivmod, double_int_udivmod,
double_int_mod, double_int_smod, double_int_umod): New functions.
* double-int.h (double_int_divmod, double_int_sdivmod,
double_int_udivmod, double_int_mod, double_int_smod, double_int_umod):
Declare.
* tree-ssa-loop-ivopts.c (constant_multiple_of): Returns the result
in double_int.
(get_computation_aff, get_computation_cost_at): Handle double_int
return type of constant_multiple_of.
From-SVN: r116529
Diffstat (limited to 'gcc/double-int.c')
-rw-r--r-- | gcc/double-int.c | 67 |
1 files changed, 62 insertions, 5 deletions
diff --git a/gcc/double-int.c b/gcc/double-int.c index 5a7b51dbe31..3be0abf4f3a 100644 --- a/gcc/double-int.c +++ b/gcc/double-int.c @@ -203,20 +203,48 @@ double_int_neg (double_int a) /* Returns A / B (computed as unsigned depending on UNS, and rounded as specified by CODE). CODE is enum tree_code in fact, but double_int.h - must be included before tree.h. */ + must be included before tree.h. The remainder after the division is + stored to MOD. */ double_int -double_int_div (double_int a, double_int b, bool uns, unsigned code) +double_int_divmod (double_int a, double_int b, bool uns, unsigned code, + double_int *mod) { - unsigned HOST_WIDE_INT rem_lo; - HOST_WIDE_INT rem_hi; double_int ret; div_and_round_double (code, uns, a.low, a.high, b.low, b.high, - &ret.low, &ret.high, &rem_lo, &rem_hi); + &ret.low, &ret.high, &mod->low, &mod->high); return ret; } +/* The same as double_int_divmod with UNS = false. */ + +double_int +double_int_sdivmod (double_int a, double_int b, unsigned code, double_int *mod) +{ + return double_int_divmod (a, b, false, code, mod); +} + +/* The same as double_int_divmod with UNS = true. */ + +double_int +double_int_udivmod (double_int a, double_int b, unsigned code, double_int *mod) +{ + return double_int_divmod (a, b, true, code, mod); +} + +/* Returns A / B (computed as unsigned depending on UNS, and rounded as + specified by CODE). CODE is enum tree_code in fact, but double_int.h + must be included before tree.h. */ + +double_int +double_int_div (double_int a, double_int b, bool uns, unsigned code) +{ + double_int mod; + + return double_int_divmod (a, b, uns, code, &mod); +} + /* The same as double_int_div with UNS = false. */ double_int @@ -233,6 +261,35 @@ double_int_udiv (double_int a, double_int b, unsigned code) return double_int_div (a, b, true, code); } +/* Returns A % B (computed as unsigned depending on UNS, and rounded as + specified by CODE). CODE is enum tree_code in fact, but double_int.h + must be included before tree.h. */ + +double_int +double_int_mod (double_int a, double_int b, bool uns, unsigned code) +{ + double_int mod; + + double_int_divmod (a, b, uns, code, &mod); + return mod; +} + +/* The same as double_int_mod with UNS = false. */ + +double_int +double_int_smod (double_int a, double_int b, unsigned code) +{ + return double_int_mod (a, b, false, code); +} + +/* The same as double_int_mod with UNS = true. */ + +double_int +double_int_umod (double_int a, double_int b, unsigned code) +{ + return double_int_mod (a, b, true, code); +} + /* Constructs tree in type TYPE from with value given by CST. */ tree |