diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-01-31 16:52:22 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-01-31 16:52:22 +0000 |
commit | 90c0f5b719ead1fbc43ad728e55252c10efb94bb (patch) | |
tree | cf5d6a5c4c84d7cb898730f0e74189afecd15f95 /gcc/tree-ssa-ccp.c | |
parent | 43525f8a34ecd2571d692ddb5693223396d35279 (diff) | |
download | gcc-90c0f5b719ead1fbc43ad728e55252c10efb94bb.tar.gz |
PR tree-optimization/47538
* tree-ssa-ccp.c (bit_value_binop_1): For uns computation use
type instead of r1type, except for comparisons. For right
shifts and comparisons punt if there are mismatches in
sizetype vs. non-sizetype types.
* gcc.c-torture/execute/pr47538.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169441 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 57fc56d8ba7..8b8d996f508 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -1768,8 +1768,8 @@ bit_value_binop_1 (enum tree_code code, tree type, tree r1type, double_int r1val, double_int r1mask, tree r2type, double_int r2val, double_int r2mask) { - bool uns = (TREE_CODE (r1type) == INTEGER_TYPE - && TYPE_IS_SIZETYPE (r1type) ? 0 : TYPE_UNSIGNED (r1type)); + bool uns = (TREE_CODE (type) == INTEGER_TYPE + && TYPE_IS_SIZETYPE (type) ? 0 : TYPE_UNSIGNED (type)); /* Assume we'll get a constant result. Use an initial varying value, we fall back to varying in the end if necessary. */ *mask = double_int_minus_one; @@ -1836,6 +1836,13 @@ bit_value_binop_1 (enum tree_code code, tree type, } else if (shift < 0) { + /* ??? We can have sizetype related inconsistencies in + the IL. */ + if ((TREE_CODE (r1type) == INTEGER_TYPE + && (TYPE_IS_SIZETYPE (r1type) + ? 0 : TYPE_UNSIGNED (r1type))) != uns) + break; + shift = -shift; *mask = double_int_rshift (r1mask, shift, TYPE_PRECISION (type), !uns); @@ -1946,6 +1953,14 @@ bit_value_binop_1 (enum tree_code code, tree type, if (double_int_negative_p (r1mask) || double_int_negative_p (r2mask)) break; + /* For comparisons the signedness is in the comparison operands. */ + uns = (TREE_CODE (r1type) == INTEGER_TYPE + && TYPE_IS_SIZETYPE (r1type) ? 0 : TYPE_UNSIGNED (r1type)); + /* ??? We can have sizetype related inconsistencies in the IL. */ + if ((TREE_CODE (r2type) == INTEGER_TYPE + && TYPE_IS_SIZETYPE (r2type) ? 0 : TYPE_UNSIGNED (r2type)) != uns) + break; + /* If we know the most significant bits we know the values value ranges by means of treating varying bits as zero or one. Do a cross comparison of the max/min pairs. */ |