aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/builtins.c5
-rw-r--r--gcc/fold-const.c8
3 files changed, 19 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1816d48..b183818 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2018-08-25 Martin Sebor <msebor@redhat.com>
+
+ PR tree-optimization/87059
+ * builtins.c (expand_builtin_strncmp): Convert MIN_EXPR operand
+ to the same type as the other.
+ * fold-const.c (fold_binary_loc): Assert expectation.
+
2018-08-25 Iain Sandoe <iain@sandoe.co.uk>
* config/darwin.c (machopic_legitimize_pic_address): Clean up
diff --git a/gcc/builtins.c b/gcc/builtins.c
index b1a79f3..6a992bd 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -4759,7 +4759,10 @@ expand_builtin_strncmp (tree exp, ATTRIBUTE_UNUSED rtx target,
/* If we are not using the given length, we must incorporate it here.
The actual new length parameter will be MIN(len,arg3) in this case. */
if (len != len3)
- len = fold_build2_loc (loc, MIN_EXPR, TREE_TYPE (len), len, len3);
+ {
+ len = fold_convert_loc (loc, sizetype, len);
+ len = fold_build2_loc (loc, MIN_EXPR, TREE_TYPE (len), len, len3);
+ }
rtx arg1_rtx = get_memory_rtx (arg1, len);
rtx arg2_rtx = get_memory_rtx (arg2, len);
rtx arg3_rtx = expand_normal (len);
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index b318fc7..1e44a24 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -9326,6 +9326,14 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type,
if (kind == tcc_comparison || code == MIN_EXPR || code == MAX_EXPR)
{
+ if (code == MIN_EXPR || code == MAX_EXPR)
+ {
+ tree typ0 = TREE_TYPE (arg0);
+ tree typ1 = TREE_TYPE (arg1);
+ gcc_assert (TYPE_SIGN (typ0) == TYPE_SIGN (typ1)
+ && TYPE_MODE (typ0) == TYPE_MODE (typ1));
+ }
+
STRIP_SIGN_NOPS (arg0);
STRIP_SIGN_NOPS (arg1);
}