diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-01-04 13:25:28 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-01-04 13:25:28 +0000 |
commit | a6c23958b0f999e3d48b0679e263be234368dc99 (patch) | |
tree | 1a1582548b6899bb4dc7ba44390c5312e814253b /gcc/tree.c | |
parent | f48068845f391e30be9c0962ab50f70d8c7a4f4d (diff) | |
download | gcc-a6c23958b0f999e3d48b0679e263be234368dc99.tar.gz |
2012-01-04 Richard Guenther <rguenther@suse.de>
PR middle-end/51750
* tree.c (size_low_cst): New function.
* tree.h (size_low_cst): Declare.
* fold-const.c (fold_comparison): Use it to extract the low
part of the POINTER_PLUS_EXPR offset.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182872 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c index d7bbae3c675..76488f7528a 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -6509,6 +6509,17 @@ tree_low_cst (const_tree t, int pos) return TREE_INT_CST_LOW (t); } +/* Return the HOST_WIDE_INT least significant bits of T, a sizetype + kind INTEGER_CST. This makes sure to properly sign-extend the + constant. */ + +HOST_WIDE_INT +size_low_cst (const_tree t) +{ + double_int d = tree_to_double_int (t); + return double_int_sext (d, TYPE_PRECISION (TREE_TYPE (t))).low; +} + /* Return the most significant (sign) bit of T. */ int |