aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2015-07-02 11:33:16 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2015-07-02 11:33:16 +0000
commit5fa79de857ef94a396c313826b290c4bb548c135 (patch)
treede2a914d4fee104b8455d4f67d8432cac9176a9d /gcc/builtins.c
parentcc2af70593133757b1671e184145eaa0b57db3bf (diff)
downloadgcc-5fa79de857ef94a396c313826b290c4bb548c135.zip
gcc-5fa79de857ef94a396c313826b290c4bb548c135.tar.gz
gcc-5fa79de857ef94a396c313826b290c4bb548c135.tar.bz2
builtins.c (get_pointer_alignment_1): Handle POINTER_PLUS_EXPR.
2015-07-02 Richard Biener <rguenther@suse.de> * builtins.c (get_pointer_alignment_1): Handle POINTER_PLUS_EXPR. * fold-const.c (get_pointer_modulus_and_residue): Remove. (fold_binary_loc): Implement (T)ptr & CST in terms of get_pointer_alignment_1. * tree-vect-loop-manip.c (vect_gen_niters_for_prolog_loop): Make sure to build the alignment test on a SSA name without final alignment info valid only after the prologue. From-SVN: r225310
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 4dc8a15..5f53342 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -473,6 +473,28 @@ get_pointer_alignment_1 (tree exp, unsigned int *alignp,
if (TREE_CODE (exp) == ADDR_EXPR)
return get_object_alignment_2 (TREE_OPERAND (exp, 0),
alignp, bitposp, true);
+ else if (TREE_CODE (exp) == POINTER_PLUS_EXPR)
+ {
+ unsigned int align;
+ unsigned HOST_WIDE_INT bitpos;
+ bool res = get_pointer_alignment_1 (TREE_OPERAND (exp, 0),
+ &align, &bitpos);
+ if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
+ bitpos += TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)) * BITS_PER_UNIT;
+ else
+ {
+ unsigned int trailing_zeros = tree_ctz (TREE_OPERAND (exp, 1));
+ if (trailing_zeros < HOST_BITS_PER_INT)
+ {
+ unsigned int inner = (1U << trailing_zeros) * BITS_PER_UNIT;
+ if (inner)
+ align = MIN (align, inner);
+ }
+ }
+ *alignp = align;
+ *bitposp = bitpos & (align - 1);
+ return res;
+ }
else if (TREE_CODE (exp) == SSA_NAME
&& POINTER_TYPE_P (TREE_TYPE (exp)))
{