From: Martin Sebor Date: Sat, 25 Aug 2018 19:12:36 +0000 (+0000) Subject: re PR tree-optimization/87059 (internal compiler error: in set_value_range, at tree... X-Git-Tag: upstream/12.2.0~29569 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=75e96bc80cf32a302c27bdbbec1ec7119a690857;p=platform%2Fupstream%2Fgcc.git re PR tree-optimization/87059 (internal compiler error: in set_value_range, at tree-vrp.c:289) 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. From-SVN: r263855 --- 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 + + 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 * 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); }