aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-09-02 10:38:13 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2019-09-02 10:38:13 +0200
commit976f9aa1e8b30112c0932b761e815cafcc69641f (patch)
tree748ca02a13b7c28c337de39dce894845337d34c7
parent8756957f013a5fe8095890e0401fbf7dfd86c0c0 (diff)
downloadgcc-976f9aa1e8b30112c0932b761e815cafcc69641f.zip
gcc-976f9aa1e8b30112c0932b761e815cafcc69641f.tar.gz
gcc-976f9aa1e8b30112c0932b761e815cafcc69641f.tar.bz2
re PR go/91617 (Many go test case failures after r275026)
PR go/91617 * fold-const.c (range_check_type): For enumeral and boolean type, pass 1 to type_for_size langhook instead of TYPE_UNSIGNED (etype). Return unsigned_type_for result whenever etype isn't TYPE_UNSIGNED INTEGER_TYPE. (build_range_check): Don't call unsigned_type_for for pointer types. * match.pd (X / C1 op C2): Don't call unsigned_type_for on range_check_type result. From-SVN: r275299
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/fold-const.c10
-rw-r--r--gcc/match.pd2
3 files changed, 15 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c585787..a6bcdf9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2019-09-02 Jakub Jelinek <jakub@redhat.com>
+
+ PR go/91617
+ * fold-const.c (range_check_type): For enumeral and boolean
+ type, pass 1 to type_for_size langhook instead of
+ TYPE_UNSIGNED (etype). Return unsigned_type_for result whenever
+ etype isn't TYPE_UNSIGNED INTEGER_TYPE.
+ (build_range_check): Don't call unsigned_type_for for pointer types.
+ * match.pd (X / C1 op C2): Don't call unsigned_type_for on
+ range_check_type result.
+
2019-09-02 Eric Botcazou <ebotcazou@adacore.com>
* gimple-ssa-strength-reduction.c (valid_mem_ref_cand_p): New function.
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 0376cdb..a99dafe 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -4938,10 +4938,9 @@ range_check_type (tree etype)
/* First make sure that arithmetics in this type is valid, then make sure
that it wraps around. */
if (TREE_CODE (etype) == ENUMERAL_TYPE || TREE_CODE (etype) == BOOLEAN_TYPE)
- etype = lang_hooks.types.type_for_size (TYPE_PRECISION (etype),
- TYPE_UNSIGNED (etype));
+ etype = lang_hooks.types.type_for_size (TYPE_PRECISION (etype), 1);
- if (TREE_CODE (etype) == INTEGER_TYPE && !TYPE_OVERFLOW_WRAPS (etype))
+ if (TREE_CODE (etype) == INTEGER_TYPE && !TYPE_UNSIGNED (etype))
{
tree utype, minv, maxv;
@@ -4959,6 +4958,8 @@ range_check_type (tree etype)
else
return NULL_TREE;
}
+ else if (POINTER_TYPE_P (etype))
+ etype = unsigned_type_for (etype);
return etype;
}
@@ -5049,9 +5050,6 @@ build_range_check (location_t loc, tree type, tree exp, int in_p,
if (etype == NULL_TREE)
return NULL_TREE;
- if (POINTER_TYPE_P (etype))
- etype = unsigned_type_for (etype);
-
high = fold_convert_loc (loc, etype, high);
low = fold_convert_loc (loc, etype, low);
exp = fold_convert_loc (loc, etype, exp);
diff --git a/gcc/match.pd b/gcc/match.pd
index 13e41a9..cd75dac 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -1569,8 +1569,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
tree etype = range_check_type (TREE_TYPE (@0));
if (etype)
{
- if (! TYPE_UNSIGNED (etype))
- etype = unsigned_type_for (etype);
hi = fold_convert (etype, hi);
lo = fold_convert (etype, lo);
hi = const_binop (MINUS_EXPR, etype, hi, lo);