diff options
author | Zdenek Dvorak <dvorakz@suse.cz> | 2004-10-27 22:27:20 +0200 |
---|---|---|
committer | Zdenek Dvorak <rakdver@gcc.gnu.org> | 2004-10-27 20:27:20 +0000 |
commit | 38b0dcb81effec70e61bb1e652c0cab254245115 (patch) | |
tree | 36323e61beca852219425c346a9efad5a6b0dfb5 /gcc/tree.c | |
parent | 89e73849fd8fe510b1e5b8b91b5ce1211d377f95 (diff) | |
download | gcc-38b0dcb81effec70e61bb1e652c0cab254245115.zip gcc-38b0dcb81effec70e61bb1e652c0cab254245115.tar.gz gcc-38b0dcb81effec70e61bb1e652c0cab254245115.tar.bz2 |
re PR tree-optimization/18048 (mgrid loop performance regression with ivopts (register pressure))
PR tree-optimization/18048
* fold-const.c (try_move_mult_to_index): New function.
(fold): Use try_move_mult_to_index.
* tree-ssa-loop-ivopts.c (try_add_cand_for): Prefer common candidates.
* tree-ssa-loop-niter.c (number_of_iterations_cond): Produce
an all-ones unsigned constant without extra bits.
* tree.c (build_low_bits_mask): New function.
* tree.h (build_low_bits_mask): Declare.
From-SVN: r89708
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -609,6 +609,40 @@ build_int_cst_wide (tree type, unsigned HOST_WIDE_INT low, HOST_WIDE_INT hi) return t; } +/* Builds an integer constant in TYPE such that lowest BITS bits are ones + and the rest are zeros. */ + +tree +build_low_bits_mask (tree type, unsigned bits) +{ + unsigned HOST_WIDE_INT low; + HOST_WIDE_INT high; + unsigned HOST_WIDE_INT all_ones = ~(unsigned HOST_WIDE_INT) 0; + + gcc_assert (bits <= TYPE_PRECISION (type)); + + if (bits == TYPE_PRECISION (type) + && !TYPE_UNSIGNED (type)) + { + /* Sign extended all-ones mask. */ + low = all_ones; + high = -1; + } + else if (bits <= HOST_BITS_PER_WIDE_INT) + { + low = all_ones >> (HOST_BITS_PER_WIDE_INT - bits); + high = 0; + } + else + { + bits -= HOST_BITS_PER_WIDE_INT; + low = all_ones; + high = all_ones >> (HOST_BITS_PER_WIDE_INT - bits); + } + + return build_int_cst_wide (type, low, high); +} + /* Checks that X is integer constant that can be expressed in (unsigned) HOST_WIDE_INT without loss of precision. */ |