diff options
author | Jakub Jelinek <jakub@redhat.com> | 2013-10-31 14:57:05 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2013-10-31 14:57:05 +0100 |
commit | eae76e53d9f28035a072e2722ffafdd3ad913936 (patch) | |
tree | 724d536345f0d153b316b5c50064d6336fea231b /gcc/builtins.c | |
parent | c853f62af3d69969bfca8e29c2ee17cb77fc6b1a (diff) | |
download | gcc-eae76e53d9f28035a072e2722ffafdd3ad913936.zip gcc-eae76e53d9f28035a072e2722ffafdd3ad913936.tar.gz gcc-eae76e53d9f28035a072e2722ffafdd3ad913936.tar.bz2 |
tree.c (tree_ctz): New function.
* tree.c (tree_ctz): New function.
* tree.h (tree_ctz): New prototype.
* tree-ssanames.h (get_range_info, get_nonzero_bits): Change
first argument from tree to const_tree.
* tree-ssanames.c (get_range_info, get_nonzero_bits): Likewise.
* tree-vectorizer.h (vect_generate_tmps_on_preheader): New prototype.
* tree-vect-loop-manip.c (vect_generate_tmps_on_preheader): No longer
static.
* expr.c (highest_pow2_factor): Reimplemented using tree_ctz.
* tree-vect-loop.c (vect_analyze_loop_operations,
vect_transform_loop): Don't force scalar loop for bound just because
number of iterations is unknown, only do it if it is not known to be
a multiple of vectorization_factor.
* builtins.c (get_object_alignment_2): Use tree_ctz on offset.
From-SVN: r204257
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 48 |
1 files changed, 7 insertions, 41 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 1b08545..f84789e 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -314,7 +314,7 @@ get_object_alignment_2 (tree exp, unsigned int *alignp, tree offset; enum machine_mode mode; int unsignedp, volatilep; - unsigned int inner, align = BITS_PER_UNIT; + unsigned int align = BITS_PER_UNIT; bool known_alignment = false; /* Get the innermost object and the constant (bitpos) and possibly @@ -423,50 +423,16 @@ get_object_alignment_2 (tree exp, unsigned int *alignp, /* If there is a non-constant offset part extract the maximum alignment that can prevail. */ - inner = ~0U; - while (offset) + if (offset) { - tree next_offset; - - if (TREE_CODE (offset) == PLUS_EXPR) - { - next_offset = TREE_OPERAND (offset, 0); - offset = TREE_OPERAND (offset, 1); - } - else - next_offset = NULL; - if (host_integerp (offset, 1)) - { - /* Any overflow in calculating offset_bits won't change - the alignment. */ - unsigned offset_bits - = ((unsigned) tree_low_cst (offset, 1) * BITS_PER_UNIT); - - if (offset_bits) - inner = MIN (inner, (offset_bits & -offset_bits)); - } - else if (TREE_CODE (offset) == MULT_EXPR - && host_integerp (TREE_OPERAND (offset, 1), 1)) - { - /* Any overflow in calculating offset_factor won't change - the alignment. */ - unsigned offset_factor - = ((unsigned) tree_low_cst (TREE_OPERAND (offset, 1), 1) - * BITS_PER_UNIT); - - if (offset_factor) - inner = MIN (inner, (offset_factor & -offset_factor)); - } - else + int trailing_zeros = tree_ctz (offset); + if (trailing_zeros < HOST_BITS_PER_INT) { - inner = MIN (inner, BITS_PER_UNIT); - break; + unsigned int inner = (1U << trailing_zeros) * BITS_PER_UNIT; + if (inner) + align = MIN (align, inner); } - offset = next_offset; } - /* Alignment is innermost object alignment adjusted by the constant - and non-constant offset parts. */ - align = MIN (align, inner); *alignp = align; *bitposp = bitpos & (*alignp - 1); |