Re: [PATCH] Avoid signed overflow in num_get::_M_extract_int (PR libstdc++/67214)
On 2017-05-19 15:38 +0100, Jonathan Wakely wrote: > On 18/05/17 19:10 +0800, Xi Ruoyao wrote: > > This UB has been hiding so long... > > Indeed! Thanks for the patch. > > > 2017-03-11 Xi Ruoyao > > > > PR libstdc++/67214 > > * include/bits/locale_facets.tcc (_M_extract_int): > > Add explicit conversion to avoid signed overflow. > > --- > > libstdc++-v3/include/bits/locale_facets.tcc | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/libstdc++-v3/include/bits/locale_facets.tcc > > b/libstdc++-v3/include/bits/locale_facets.tcc > > index 351190c..5f85d15 100644 > > --- a/libstdc++-v3/include/bits/locale_facets.tcc > > +++ b/libstdc++-v3/include/bits/locale_facets.tcc > > @@ -470,7 +470,8 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL > > bool __testoverflow = false; > > const __unsigned_type __max = > > (__negative && __gnu_cxx::__numeric_traits<_ValueT>::__is_signed) > > - ? -__gnu_cxx::__numeric_traits<_ValueT>::__min > > + ? -static_cast<__unsigned_type>(__gnu_cxx:: > > + __numeric_traits<_ValueT>::__min) > > Do we need to keep the negation, or can we just cast to > __unsigned_type? For 2's complement we can just cast to __unsigned_type. But for clarity and other strange architectures I think we should keep the negation. -- Xi Ruoyao School of Aerospace Science and Technology, Xidian University
Re: [PATCH 1/7] [ARC] Make mulsi for A700 pattern commutative.
* Claudiu Zissulescu [2017-05-19 12:30:56 +0200]: > gcc/ > 2016-11-10 Claudiu Zissulescu > > * config/arc/arc.md (mulsi3_700): Make it commutative. Looks good thanks, Andrew > --- > gcc/config/arc/arc.md | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md > index 71d076c..db5867c 100644 > --- a/gcc/config/arc/arc.md > +++ b/gcc/config/arc/arc.md > @@ -2127,7 +2127,7 @@ > ; like MPY or MPYU. > (define_insn "mulsi3_700" > [(set (match_operand:SI 0 "mpy_dest_reg_operand""=Rcr,r,r,Rcr,r") > - (mult:SI (match_operand:SI 1 "register_operand" " 0,c,0,0,c") > + (mult:SI (match_operand:SI 1 "register_operand" "%0,c,0,0,c") >(match_operand:SI 2 "nonmemory_operand" "cL,cL,I,Cal,Cal")))] > "TARGET_ARC700_MPY" >"mpyu%? %0,%1,%2" > -- > 1.9.1 >
Re: MinGW compilation warnings in libiberty's include/environ.h
> From: DJ Delorie > Cc: pal...@redhat.com, gcc-patches@gcc.gnu.org, gdb-patc...@sourceware.org > Date: Sat, 20 May 2017 02:16:14 -0400 > > Eli Zaretskii writes: > > My problem is, I don't have a GCC repository, so doing the above means > > In this case, a gdb repo would have sufficed. Thanks, I didn't know that.
Re: [wwwdocs] projects/prefetch.html - remove Itanium manual
On Sun, 14 May 2017, Gerald Pfeifer wrote: > The usual theme, but at least a redirect to a most generic page, > so let's just remove this. Somehow I made a silly mistake; fixed thusly. Gerald Index: htdocs/projects/prefetch.html === RCS file: /cvs/gcc/wwwdocs/htdocs/projects/prefetch.html,v retrieving revision 1.29 diff -u -r1.29 prefetch.html --- htdocs/projects/prefetch.html 14 May 2017 20:47:12 - 1.29 +++ htdocs/projects/prefetch.html 17 May 2017 16:48:41 - @@ -767,7 +767,7 @@ [8] Intel Itanium[tm] Architecture Software Developer's Manual Vol. 3 -rev. 2.1: Instruction Set Reference.. +rev. 2.1: Instruction Set Reference. [9] MIPS32[tm] Architecture for Programmers; Volume II: The MIPS32[tm]
New Spanish PO file for 'gcc' (version 7.1.0)
Hello, gentle maintainer. This is a message from the Translation Project robot. A revised PO file for textual domain 'gcc' has been submitted by the Spanish team of translators. The file is available at: http://translationproject.org/latest/gcc/es.po (This file, 'gcc-7.1.0.es.po', has just now been sent to you in a separate email.) All other PO files for your package are available in: http://translationproject.org/latest/gcc/ Please consider including all of these in your next release, whether official or a pretest. Whenever you have a new distribution with a new version number ready, containing a newer POT file, please send the URL of that distribution tarball to the address below. The tarball may be just a pretest or a snapshot, it does not even have to compile. It is just used by the translators when they need some extra translation context. The following HTML page has been updated: http://translationproject.org/domain/gcc.html If any question arises, please contact the translation coordinator. Thank you for all your work, The Translation Project robot, in the name of your translation coordinator.
Move "(A & C) == D is false when D & ~C != 0" to match.pd
Hello, as asked, I am adding some replacement in match.pd instead of just deleting this (redundant with CCP). It is not clear how general the match.pd version needs to be. (for instance it could handle some casts in addition to what I have written) The expansion results in a few non-canonical patterns (thus unreachable code), but avoiding them would make the code longer and less readable. I wondered about naming with_possible_nonzero_bits INTEGER_CST_or_SSA_NAME instead. I would like to rename get_nonzero_bits to get_possible_nonzero_bits or get_possibly_nonzero_bits, something more explicit, and introduce get_certain(ly)_nonzero_bits that would always return 0 for SSA_NAME for a start (but hopefully the next person who rewrites this stuff (merge CCP with VRP for instance?) will implement it). It would allow for more symmetry in the transformations and make the intent clearer. Bootstrap+testsuite on powerpc64le-unknown-linux-gnu. 2017-05-22 Marc Glisse * fold-const.c (fold_binary_loc) [(A & C) == D]: Remove transformation. * match.pd (X == C): Rewrite it here. (with_possible_nonzero_bits, with_possible_nonzero_bits2, with_certain_nonzero_bits2): New predicates. * tree-ssanames.c (get_nonzero_bits): Handle INTEGER_CST. -- Marc GlisseIndex: fold-const.c === --- fold-const.c (revision 248303) +++ fold-const.c (working copy) @@ -10629,38 +10629,20 @@ fold_binary_loc (location_t loc, ((X >> C1) & C2) != 0 is rewritten as (X,false), and ((X >> C1) & C2) == 0 is rewritten as (X,true). */ else return omit_one_operand_loc (loc, type, code == EQ_EXPR ? integer_one_node : integer_zero_node, arg000); } } - /* If we have (A & C) == D where D & ~C != 0, convert this into 0. - Similarly for NE_EXPR. */ - if (TREE_CODE (arg0) == BIT_AND_EXPR - && TREE_CODE (arg1) == INTEGER_CST - && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) - { - tree notc = fold_build1_loc (loc, BIT_NOT_EXPR, - TREE_TYPE (TREE_OPERAND (arg0, 1)), - TREE_OPERAND (arg0, 1)); - tree dandnotc - = fold_build2_loc (loc, BIT_AND_EXPR, TREE_TYPE (arg0), - fold_convert_loc (loc, TREE_TYPE (arg0), arg1), - notc); - tree rslt = code == EQ_EXPR ? integer_zero_node : integer_one_node; - if (integer_nonzerop (dandnotc)) - return omit_one_operand_loc (loc, type, rslt, arg0); - } - /* If this is a comparison of a field, we may be able to simplify it. */ if ((TREE_CODE (arg0) == COMPONENT_REF || TREE_CODE (arg0) == BIT_FIELD_REF) /* Handle the constant case even without -O to make sure the warnings are given. */ && (optimize || TREE_CODE (arg1) == INTEGER_CST)) { t1 = optimize_bit_field_compare (loc, code, type, arg0, arg1); if (t1) return t1; Index: match.pd === --- match.pd (revision 248303) +++ match.pd (working copy) @@ -1090,20 +1090,47 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) || TYPE_OVERFLOW_WRAPS (TREE_TYPE (@0 (op @1 @0 /* X == C - X can never be true if C is odd. */ (for cmp (eq ne) (simplify (cmp:c (convert? @0) (convert1? (minus INTEGER_CST@1 (convert2? @0 (if (TREE_INT_CST_LOW (@1) & 1) { constant_boolean_node (cmp == NE_EXPR, type); }))) +/* Arguments on which one can call get_nonzero_bits to get the bits + possibly set. */ +(match with_possible_nonzero_bits + INTEGER_CST@0) +(match with_possible_nonzero_bits + SSA_NAME@0 + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) || POINTER_TYPE_P (TREE_TYPE (@0) +/* Slightly extended version, do not make it recursive to keep it cheap. */ +(match (with_possible_nonzero_bits2 @0) + with_possible_nonzero_bits@0) +(match (with_possible_nonzero_bits2 @0) + (bit_and:c with_possible_nonzero_bits@0 @2)) + +/* Same for bits that are known to be set, but we do not have + an equivalent to get_nonzero_bits yet. */ +(match (with_certain_nonzero_bits2 @0) + INTEGER_CST@0) +(match (with_certain_nonzero_bits2 @0) + (bit_ior @1 INTEGER_CST@0)) + +/* X == C (or X & Z == Y | C) is impossible if ~nonzero(X) & C != 0. */ +(for cmp (eq ne) + (simplify + (cmp:c (with_possible_nonzero_bits2 @0) (with_certain_nonzero_bits2 @1)) + (if ((~get_nonzero_bits (@0) & @1) != 0) + { constant_boolean_node (cmp == NE_EXPR, type); }))) + /* ((X inner_op C0) outer_op C1) With X being a tree where value_range has reasoned certain bits to always be zero throughout its computed value range, inner_op = {|,^}, outer_op = {|,^} and inner_op != outer_op where zero_mask has 1's for all bits that are sure to be 0 in and 0's otherwise. if (inner_op == '^') C0 &= ~C1; if ((C0 & ~zero_mask) == 0) then emit (X outer_op (C0 outer_op C1) if ((C1 & ~zero_mask) == 0) then emit (X inner_op (C0 outer_op C1) */ Index: tree-ssanames