Re: [PATCH] Cleanup TODO handling for CFG clenaup & SSA update
On Fri, Mar 8, 2019 at 4:59 PM Richard Biener wrote: > > On March 8, 2019 3:52:36 PM GMT+01:00, Jeff Law wrote: > >On 3/8/19 7:23 AM, Richard Biener wrote: > >> > >> There's an old comment > >> > >> /* When cleanup_tree_cfg merges consecutive blocks, it may > >> perform some simplistic propagation when removing single > >> valued PHI nodes. This propagation may, in turn, cause the > >> SSA form to become out-of-date (see PR 22037). So, even > >> if the parent pass had not scheduled an SSA update, we may > >> still need to do one. */ > >> if (!(flags & TODO_update_ssa_any) && need_ssa_update_p (cfun)) > >> flags |= TODO_update_ssa; > >> > >> which is from times we've had multiple virtual operands. After > >> those went away we could still run into this for example when > >> propagating a non-const function address into an indirect call > >> through a const function type. This has been fixed as well > >> (we retain the const-ness of the call). Thus the above is > >> no longer necessary and we can simplify the code. > >> > >> Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. > >> > >> I'm not really nervous about this change but if you think it > >> should wait for GCC 10 speak up. > >> > >> Richard. > >> > >> 2019-03-08 Richard Biener > >> > >> * passes.c (execute_function_todo): Remove dead code. > >What's driving the desire to change this for gcc-9? I think it's a > >fine > >cleanup for gcc-10, but it's not clear to me we want to push it into > >gcc-9. > > Just that I came along this with the previous related CFG cleanup fix and got > the time to test it. > > Queued for GCC 10 instead. Applied as r270832. Richard. > Richard. > > >jeff >
Patch ping (was Re: [C++ PATCH] Fix up C++ loop construct debug info without -gno-statement-frontiers (PR debug/90197))
Hi! On Fri, Apr 26, 2019 at 05:45:27PM +0200, Jakub Jelinek wrote: > 2019-04-26 Jakub Jelinek > > PR debug/90197 > * cp-gimplify.c (genericize_cp_loop): Emit a DEBUG_BEGIN_STMT > before the condition (or if missing or constant non-zero at the end > of the loop. Emit a DEBUG_BEGIN_STMT before the increment expression > if any. I'd like to ping this patch for trunk. Thanks. Jakub
Re: Let ldist ignore clobbers
On Thu, May 2, 2019 at 8:41 PM Marc Glisse wrote: > > Hello, > > this lets ldist ignore clobbers. In the testcase, this makes us lose the > information that b is clobbered, but being able to distribute seems worth > it. > > Bootstrap+regtest on x86_64-pc-linux-gnu. OK. Thanks, Richard. > 2019-05-03 Marc Glisse > > PR tree-optimization/90269 > gcc/ > * tree-loop-distribution.c (find_seed_stmts_for_distribution): > Ignore clobbers. > > gcc/testsuite/ > * g++.dg/tree-ssa/ldist-1.C: New file. > > -- > Marc Glisse
Re: [PATCH] Fold unfolded constants from initializers
On Wed, Mar 13, 2019 at 12:35 PM Richard Biener wrote: > > > This fixes a missed optimization in the testcase in PR89698 > where we fail to fold an access to a virtual table slot because > it is (int (*) ()) 0 - yes, an unfolded INTEGER_CST. Callers > are not happy with this so the following makes sure to > return a properly folded constant via canonicalize_constructor_val. > > This avoids the dynamic_cast<> runtime overhead in the testcase. > > Bootstrap & regtest running on x86_64-unknown-linux-gnu, queued for GCC > 10. Applied as r270833. Richard. > Richard. > > 2019-03-14 Richard Biener > > PR tree-optimization/89698 > * gimple-fold.c (canonicalize_constructor_val): Early out > for constants, handle unfolded INTEGER_CSTs as they appear in > C++ virtual table ctors. > > * g++.dg/tree-ssa/pr89698.C: New testcase. > > Index: gcc/gimple-fold.c > === > --- gcc/gimple-fold.c (revision 269641) > +++ gcc/gimple-fold.c (working copy) > @@ -207,6 +207,9 @@ create_tmp_reg_or_ssa_name (tree type, g > tree > canonicalize_constructor_val (tree cval, tree from_decl) > { > + if (CONSTANT_CLASS_P (cval)) > +return cval; > + >tree orig_cval = cval; >STRIP_NOPS (cval); >if (TREE_CODE (cval) == POINTER_PLUS_EXPR > @@ -257,8 +260,15 @@ canonicalize_constructor_val (tree cval, > cval = fold_convert (TREE_TYPE (orig_cval), cval); >return cval; > } > - if (TREE_OVERFLOW_P (cval)) > -return drop_tree_overflow (cval); > + /* In CONSTRUCTORs we may see unfolded constants like (int (*) ()) 0. */ > + if (TREE_CODE (cval) == INTEGER_CST) > +{ > + if (TREE_OVERFLOW_P (cval)) > + cval = drop_tree_overflow (cval); > + if (!useless_type_conversion_p (TREE_TYPE (orig_cval), TREE_TYPE > (cval))) > + cval = fold_convert (TREE_TYPE (orig_cval), cval); > + return cval; > +} >return orig_cval; > } > > Index: gcc/testsuite/g++.dg/tree-ssa/pr89698.C > === > --- gcc/testsuite/g++.dg/tree-ssa/pr89698.C (nonexistent) > +++ gcc/testsuite/g++.dg/tree-ssa/pr89698.C (working copy) > @@ -0,0 +1,29 @@ > +// { dg-do compile } > +// { dg-options "-O -fdump-tree-fre1" } > + > +class A { > +virtual void f(){}; > +public: > +int x; > +A(int in): x(in) {}; > +}; > + > +class B: public A { > +public: > +int y; > +B(int in):A(in-1), y(in) {}; > +}; > + > +void bar(void *); > +void test() > +{ > + B b(2); > + A* bp = &b; > + void* vp = dynamic_cast(bp); > + bar (vp); > +} > + > +// We should be able to constant fold from the virtual table > +// the offset added to bp for the dynamic cast and forward > +// &b to the argument of bar > +// { dg-final { scan-tree-dump "bar \\\(&b" "fre1" } }
[PATCH] Fix build with offloading (Re: [RFC][PATCH] Postpone print of --help=* option.)
Hi! On Thu, May 02, 2019 at 01:04:07PM +0200, Jakub Jelinek wrote: > Well, that doesn't answer the question. > I was wondering why you couldn't: > > 2019-05-02 Jakub Jelinek > > * opts.h (finish_options): Remove lang_mask argument. > (print_help, help_option_argument): Declare. > * opts.c (print_help): Remove forward declaration, no longer static. > (finish_options): Remove lang_mask argument, don't call print_help > here. > * opts-global.c (decode_options): Adjust finish_option caller, call > print_help here. On Thu, May 02, 2019 at 01:13:22PM +0200, Martin Liška wrote: > On 5/2/19 1:04 PM, Jakub Jelinek wrote: > > Well, that doesn't answer the question. > > I was wondering why you couldn't: > > Ah sorry, you are right. The patch you suggested > is obviously nicer than what we have currently in trunk. Bootstrapped/regtested successfully now on x86_64-linux and i686-linux, ok for trunk? Jakub
[PATCH] Fix ipa-devirt ICEs with types requiring structural equality (PR tree-optimization/90303)
Hi! The following two functions assume that all types (in the latter case only the TYPE_MAIN_VARIANT of it) have non-NULL TYPE_CANONICAL. That is generally not something the FEs guarantee, if TYPE_CANONICAL is NULL, that is TYPE_STRUCTURAL_EQUALITY_P and generally the middle-end either punts on those, or does use more careful type comparison etc. In the testcase we have a FUNCTION_TYPE for which TYPE_STRUCTURAL_EQUALITY_P is true and the C++ FE sets template types where any of the template parameters requires structural equality also to require structural equality. In the following functions, we already have a type (TYPE_MAIN_VARIANT), using its TYPE_CANONICAL instead when it is NULL means a certain ICE, but I don't see why we couldn't just use those types. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk and later for 9.2? 2019-05-03 Jakub Jelinek PR tree-optimization/90303 * ipa-devirt.c (obj_type_ref_class, get_odr_type): Don't use TYPE_CANONICAL for TYPE_STRUCTURAL_EQUALITY_P types in !in_lto_p mode. * g++.target/i386/pr90303.C: New test. --- gcc/ipa-devirt.c.jj 2019-04-15 19:45:28.796340266 +0200 +++ gcc/ipa-devirt.c2019-05-02 10:46:03.077896176 +0200 @@ -2020,7 +2020,7 @@ obj_type_ref_class (const_tree ref) ref = TREE_VALUE (TYPE_ARG_TYPES (ref)); gcc_checking_assert (TREE_CODE (ref) == POINTER_TYPE); tree ret = TREE_TYPE (ref); - if (!in_lto_p) + if (!in_lto_p && !TYPE_STRUCTURAL_EQUALITY_P (ret)) ret = TYPE_CANONICAL (ret); else ret = get_odr_type (ret)->type; @@ -2042,7 +2042,7 @@ get_odr_type (tree type, bool insert) int base_id = -1; type = TYPE_MAIN_VARIANT (type); - if (!in_lto_p) + if (!in_lto_p && !TYPE_STRUCTURAL_EQUALITY_P (type)) type = TYPE_CANONICAL (type); gcc_checking_assert (can_be_name_hashed_p (type) --- gcc/testsuite/g++.target/i386/pr90303.C.jj 2019-05-02 10:51:42.208456515 +0200 +++ gcc/testsuite/g++.target/i386/pr90303.C 2019-05-02 10:52:15.300925960 +0200 @@ -0,0 +1,8 @@ +// PR tree-optimization/90303 +// { dg-do compile { target ia32 } } +// { dg-additional-options "-O2" } + +struct A { virtual void foo (); }; +template class B : A {}; +typedef void (__attribute__((fastcall)) F) (); +B e; Jakub
Re: [PATCH] Fix build with offloading (Re: [RFC][PATCH] Postpone print of --help=* option.)
On Fri, 3 May 2019, Jakub Jelinek wrote: > Hi! > > On Thu, May 02, 2019 at 01:04:07PM +0200, Jakub Jelinek wrote: > > Well, that doesn't answer the question. > > I was wondering why you couldn't: > > > > 2019-05-02 Jakub Jelinek > > > > * opts.h (finish_options): Remove lang_mask argument. > > (print_help, help_option_argument): Declare. > > * opts.c (print_help): Remove forward declaration, no longer static. > > (finish_options): Remove lang_mask argument, don't call print_help > > here. > > * opts-global.c (decode_options): Adjust finish_option caller, call > > print_help here. > > On Thu, May 02, 2019 at 01:13:22PM +0200, Martin Liška wrote: > > On 5/2/19 1:04 PM, Jakub Jelinek wrote: > > > Well, that doesn't answer the question. > > > I was wondering why you couldn't: > > > > Ah sorry, you are right. The patch you suggested > > is obviously nicer than what we have currently in trunk. > > Bootstrapped/regtested successfully now on x86_64-linux and i686-linux, ok > for trunk? OK. Richard.
[committed] Remove useless fincludedir from libitm/Makefile.am
Hi! When tweaking gcov_cdir, I've noticed libitm has completely useless fincludedir when it doesn't contain any fortran headers/modules. I assume it appeared just as a copy of the libgomp Makefile.am at some point initially. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk as obvious. 2019-05-03 Jakub Jelinek * Makefile.am (finclude): Remove. * Makefile.in: Regenerated. --- libitm/Makefile.am.jj 2018-11-01 12:05:59.542687510 +0100 +++ libitm/Makefile.am 2019-05-02 18:06:26.504730403 +0200 @@ -12,7 +12,6 @@ abi_version = -fabi-version=4 config_path = @config_path@ search_path = $(addprefix $(top_srcdir)/config/, $(config_path)) $(top_srcdir) -fincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/finclude libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include vpath % $(strip $(search_path)) --- libitm/Makefile.in.jj 2018-11-01 12:05:59.179693490 +0100 +++ libitm/Makefile.in 2019-05-02 18:06:35.585585582 +0200 @@ -458,7 +458,6 @@ SUBDIRS = testsuite gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER) abi_version = -fabi-version=4 search_path = $(addprefix $(top_srcdir)/config/, $(config_path)) $(top_srcdir) -fincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/finclude libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include AM_CPPFLAGS = $(addprefix -I, $(search_path)) AM_CFLAGS = $(XCFLAGS) Jakub
Re: [PATCH] Fix ipa-devirt ICEs with types requiring structural equality (PR tree-optimization/90303)
On Fri, 3 May 2019, Jakub Jelinek wrote: > Hi! > > The following two functions assume that all types (in the latter case only > the TYPE_MAIN_VARIANT of it) have non-NULL TYPE_CANONICAL. That is > generally not something the FEs guarantee, if TYPE_CANONICAL is NULL, that > is TYPE_STRUCTURAL_EQUALITY_P and generally the middle-end either punts on > those, or does use more careful type comparison etc. In the testcase > we have a FUNCTION_TYPE for which TYPE_STRUCTURAL_EQUALITY_P is true and > the C++ FE sets template types where any of the template parameters requires > structural equality also to require structural equality. > > In the following functions, we already have a type (TYPE_MAIN_VARIANT), > using its TYPE_CANONICAL instead when it is NULL means a certain ICE, but I > don't see why we couldn't just use those types. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk and > later for 9.2? OK. Richar. > 2019-05-03 Jakub Jelinek > > PR tree-optimization/90303 > * ipa-devirt.c (obj_type_ref_class, get_odr_type): Don't use > TYPE_CANONICAL for TYPE_STRUCTURAL_EQUALITY_P types in !in_lto_p mode. > > * g++.target/i386/pr90303.C: New test. > > --- gcc/ipa-devirt.c.jj 2019-04-15 19:45:28.796340266 +0200 > +++ gcc/ipa-devirt.c 2019-05-02 10:46:03.077896176 +0200 > @@ -2020,7 +2020,7 @@ obj_type_ref_class (const_tree ref) >ref = TREE_VALUE (TYPE_ARG_TYPES (ref)); >gcc_checking_assert (TREE_CODE (ref) == POINTER_TYPE); >tree ret = TREE_TYPE (ref); > - if (!in_lto_p) > + if (!in_lto_p && !TYPE_STRUCTURAL_EQUALITY_P (ret)) > ret = TYPE_CANONICAL (ret); >else > ret = get_odr_type (ret)->type; > @@ -2042,7 +2042,7 @@ get_odr_type (tree type, bool insert) >int base_id = -1; > >type = TYPE_MAIN_VARIANT (type); > - if (!in_lto_p) > + if (!in_lto_p && !TYPE_STRUCTURAL_EQUALITY_P (type)) > type = TYPE_CANONICAL (type); > >gcc_checking_assert (can_be_name_hashed_p (type) > --- gcc/testsuite/g++.target/i386/pr90303.C.jj2019-05-02 > 10:51:42.208456515 +0200 > +++ gcc/testsuite/g++.target/i386/pr90303.C 2019-05-02 10:52:15.300925960 > +0200 > @@ -0,0 +1,8 @@ > +// PR tree-optimization/90303 > +// { dg-do compile { target ia32 } } > +// { dg-additional-options "-O2" } > + > +struct A { virtual void foo (); }; > +template class B : A {}; > +typedef void (__attribute__((fastcall)) F) (); > +B e; > > Jakub > -- Richard Biener SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Felix Imendörffer, Mary Higgins, Sri Rasiah; HRB 21284 (AG Nürnberg)
Re: [PATCH] Use _GLIBCXX_NOEXCEPT_IF for std::swap
On 03/05/2019 00:30, Jonathan Wakely wrote: On 02/05/19 21:33 +0100, Jonathan Wakely wrote: This was also reported as https://gcc.gnu.org/PR90314 And here's what I've tested and committed. Thanks, that fixes things for me.
Patch ping (was Re: [WIP PATCH] Improve tail call analysis and inliner EH clobber through variable life analysis (PR tree-optimization/89060))
Hi! I'd like to ping this patch for stage1. Bootstrapped/regtested it again last night successfully. On Fri, Feb 08, 2019 at 08:36:33AM +0100, Jakub Jelinek wrote: > The following patch uses a simple data flow to find live (addressable) > variables at certain spots (for tail call discovery at the point of the > potential tail call, so that we don't reject tail calls because of variables > that can be known out of scope already so that people don't have to find > ugly workarounds if they really need tail calls, and for the recently > added inline EH pad clobber addition so that we don't add too many > variables). Bootstrapped/regtested on x86_64-linux and i686-linux. > > Haven't gathered statistics on how often does it trigger yet. > Shall I use double queue (pending/working sbitmaps) to speed it up (guess I > could gather statistics if that helps reasonably)? But if so, perhaps > add_scope_conflicts should change too. I haven't shared code with > what add_scope_conflicts does because it isn't really that big chunk of code > and would need many modifications to make it generic enough to handle > add_scope_conflicts needs, plus as I wanted to make it a helper for other > optimizations, I didn't want to use bb->aux etc. For tail call, I see > another option to compute it unconditionally once at the start of the pass > for all may_be_aliased auto_var_in_fn_p vars and then just walk a single > bb with each (potential) tail call, instead of computing it for every > potential tail call again (on the other side with perhaps smaller set of > variables). In that case e.g. vars == NULL argument could imply the > VAR_P && may_be_aliased && auto_var_in_fn_p test instead of bitmap_bit_p > test, we could drop the stop_after argument and instead export the _1 > function renamed to something to walk a single bb (or wrapper to it that > would set up the structure) until stop_after. > > Thoughts on this? > > 2019-02-08 Jakub Jelinek > > PR tree-optimization/89060 > * tree-ssa-live.h (compute_live_vars, destroy_live_vars): Declare. > * tree-ssa-live.c: Include gimple-walk.h and cfganal.h. > (struct compute_live_vars_data): New type. > (compute_live_vars_visit, compute_live_vars_1, compute_live_vars, > destroy_live_vars): New functions. > * tree-tailcall.c (find_tail_calls): Perform variable life analysis > before punting. > * tree-inline.h (struct copy_body_data): Add eh_landing_pad_dest > member. > * tree-inline.c (add_clobbers_to_eh_landing_pad): Remove BB argument. > Perform variable life analysis to select variables that really need > clobbers added. > (copy_edges_for_bb): Don't call add_clobbers_to_eh_landing_pad here, > instead set id->eh_landing_pad_dest and assert it is the same. > (copy_cfg_body): Call it here if id->eh_landing_pad_dest is non-NULL. > > * gcc.dg/tree-ssa/pr89060.c: New test. > > --- gcc/tree-ssa-live.h.jj2019-01-01 12:37:16.967978068 +0100 > +++ gcc/tree-ssa-live.h 2019-02-07 19:02:58.233530924 +0100 > @@ -265,6 +265,8 @@ extern tree_live_info_p calculate_live_r > extern void debug (tree_live_info_d &ref); > extern void debug (tree_live_info_d *ptr); > extern void dump_live_info (FILE *, tree_live_info_p, int); > +extern vec compute_live_vars (struct function *, bitmap, gimple > *); > +extern void destroy_live_vars (vec &); > > > /* Return TRUE if P is marked as a global in LIVE. */ > --- gcc/tree-ssa-live.c.jj2019-01-01 12:37:16.055993032 +0100 > +++ gcc/tree-ssa-live.c 2019-02-07 19:34:33.046401259 +0100 > @@ -41,6 +41,8 @@ along with GCC; see the file COPYING3. > #include "stringpool.h" > #include "attribs.h" > #include "optinfo.h" > +#include "gimple-walk.h" > +#include "cfganal.h" > > static void verify_live_on_entry (tree_live_info_p); > > @@ -1194,8 +1196,142 @@ calculate_live_ranges (var_map map, bool > >return live; > } > + > +/* Data structure for compute_live_vars* functions. */ > > +struct compute_live_vars_data { > + /* Vector of bitmaps for live vars at the end of basic blocks, > + indexed by bb->index. ACTIVE[ENTRY_BLOCK] must be empty bitmap, > + ACTIVE[EXIT_BLOCK] is used for STOP_AFTER. */ > + vec active; > + /* Work bitmap of currently live variables. */ > + bitmap work; > + /* Bitmap of interesting variables. Variables with uids not in this > + bitmap are not tracked. */ > + bitmap vars; > +}; > > +/* Callback for walk_stmt_load_store_addr_ops. If OP is a VAR_DECL with > + uid set in DATA->vars, enter its uid into bitmap DATA->work. */ > + > +static bool > +compute_live_vars_visit (gimple *, tree op, tree, void *pdata) > +{ > + compute_live_vars_data *data = (compute_live_vars_data *) pdata; > + op = get_base_address (op); > + if (op && VAR_P (op) && bitmap_bit_p (data->vars, DECL_UID (op))) > +bitmap_set_bit (data->work, DECL_UID (op)); > + return false; > +} > + > +/* Helper ro
Re: [PATCH][GCC][AArch64] Vectorise __builtin_signbit on aarch64
Hi Richard, New patch adds a new IFN_SIGNBIT internal function that maps to signbit_optab. gcc/ChangeLog: 2019-05-05 Przemyslaw Wirkus * gcc/internal-fn.def (SIGNBIT): New. * gcc/config/aarch64/aarch64-simd.md (signbitv4sf2): New expand defined. gcc/testsuite/ChangeLog: 2019-05-05 Przemyslaw Wirkus * gcc/testsuite/gcc.target/aarch64/signbitv4sf.c: New test.diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md index e3852c5d182b70978d7603225fce55c0b8ee2894..3374ce95b912cceaca49660df0579467f758974d 100644 --- a/gcc/config/aarch64/aarch64-simd.md +++ b/gcc/config/aarch64/aarch64-simd.md @@ -935,6 +935,21 @@ [(set_attr "type" "neon_ins")] ) +(define_expand "signbitv4sf2" + [(use (match_operand:V4SI 0 "register_operand")) + (use (match_operand:V4SF 1 "register_operand"))] + "TARGET_SIMD" +{ + int shift_amount = GET_MODE_UNIT_BITSIZE (V4SImode) - 1; + rtx shift_vector = aarch64_simd_gen_const_vector_dup (V4SImode, + shift_amount); + operands[1] = lowpart_subreg (V4SImode, operands[1], V4SFmode); + + emit_insn (gen_aarch64_simd_lshrv4si (operands[0], operands[1], + shift_vector)); + DONE; +}) + (define_insn "aarch64_simd_lshr" [(set (match_operand:VDQ_I 0 "register_operand" "=w") (lshiftrt:VDQ_I (match_operand:VDQ_I 1 "register_operand" "w") diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def index e370eaa84767839c827b6ebd0c86303bcc36fa54..016301a58d83d7128817824d7c7ef92825c7e03e 100644 --- a/gcc/internal-fn.def +++ b/gcc/internal-fn.def @@ -217,6 +217,7 @@ DEF_INTERNAL_FLT_FN (LOG10, ECF_CONST, log10, unary) DEF_INTERNAL_FLT_FN (LOG1P, ECF_CONST, log1p, unary) DEF_INTERNAL_FLT_FN (LOG2, ECF_CONST, log2, unary) DEF_INTERNAL_FLT_FN (LOGB, ECF_CONST, logb, unary) +DEF_INTERNAL_FLT_FN (SIGNBIT, ECF_CONST, signbit, unary) DEF_INTERNAL_FLT_FN (SIGNIFICAND, ECF_CONST, significand, unary) DEF_INTERNAL_FLT_FN (SIN, ECF_CONST, sin, unary) DEF_INTERNAL_FLT_FN (SINH, ECF_CONST, sinh, unary) diff --git a/gcc/testsuite/gcc.target/aarch64/signbitv4sf.c b/gcc/testsuite/gcc.target/aarch64/signbitv4sf.c new file mode 100644 index ..aa06a5df1dbb3e295355d485b39963127a828b68 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/signbitv4sf.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ +/* { dg-additional-options "-O3 --save-temps" } */ + +extern void abort (); + +#define N 1024 +float in[N] = {1.0, -1.0, -2.0, 3.0, -5.0, -8.0, 13.0, 21.0}; +int out[N]; + +void +foo () +{ + for (int i = 0; i < N; i++) +out[i] = __builtin_signbit (in[i]); +} + +/* { dg-final { scan-assembler-not {-2147483648} } } */ +/* { dg-final { scan-assembler {\tushr\tv[0-9]+.4s, v[0-9]+.4s, 31} } } */ + +int +main () +{ + foo (); + + for (int i = 0; i < N; i++) + { +if (in[i] >= 0.0 && out[i]) + abort (); +if (in[i] < 0.0 && !out[i]) + abort (); + } + + return 0; +} +
Re: [PATCH][stage1] Prefer to use strlen call instead of inline expansion (PR target/88809).
On 5/2/19 11:36 PM, Jakub Jelinek wrote: > On Tue, Apr 30, 2019 at 10:00:07AM -0600, Jeff Law wrote: >>> 2019-04-23 Martin Liska >>> >>> PR target/88809 >>> * config/i386/i386.c (ix86_expand_strlen): Use strlen call. >>> With -minline-all-stringops use inline expansion using 4B loop. >>> * doc/invoke.texi: Document the change of >>> -minline-all-stringops. >>> >>> gcc/testsuite/ChangeLog: >>> >>> 2019-04-23 Martin Liska >>> >>> PR target/88809 >>> * gcc.target/i386/pr88809.c: New test. >>> * gcc.target/i386/pr88809-2.c: New test. >> OK for the trunk. > > The pr88809-2.c test fails on i686-linux. > spawn -ignore SIGHUP /home/jakub/src/gcc/obj31/gcc/xgcc > -B/home/jakub/src/gcc/obj31/gcc/ > /home/jakub/src/gcc/gcc/testsuite/gcc.target/i386/pr88809- > 2.c -fno-diagnostics-show-caret -fno-diagnostics-show-line-numbers > -fdiagnostics-color=never -Os -ffat-lto-objects -fno-ident -S -o pr88809-2.s > PASS: gcc.target/i386/pr88809-2.c (test for excess errors) > FAIL: gcc.target/i386/pr88809-2.c scan-assembler call[ \t]strlen > > Jakub > There's an obvious fix that I tested with: $ make check -k RUNTESTFLAGS="i386.exp=pr88809* --target_board=unix/-m32/" and $ make check -k RUNTESTFLAGS="i386.exp=pr88809*" I'm going to install the patch soon. Martin >From 912f8913120d23085d589602da421e16cde0 Mon Sep 17 00:00:00 2001 From: marxin Date: Fri, 3 May 2019 10:58:42 +0200 Subject: [PATCH] Fix test-case for i386 (PR target/88809). gcc/testsuite/ChangeLog: 2019-05-03 Martin Liska PR target/88809 * gcc.target/i386/pr88809-2.c: Scan for call or jmp. --- gcc/testsuite/gcc.target/i386/pr88809-2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.target/i386/pr88809-2.c b/gcc/testsuite/gcc.target/i386/pr88809-2.c index b8ef51dab5b..8ff3499831d 100644 --- a/gcc/testsuite/gcc.target/i386/pr88809-2.c +++ b/gcc/testsuite/gcc.target/i386/pr88809-2.c @@ -6,4 +6,4 @@ unsigned int foo (const char *ptr) return __builtin_strlen (ptr); } -/* { dg-final { scan-assembler "call\[ \t\]strlen" } } */ +/* { dg-final { scan-assembler "(call|jmp)\[ \t\]strlen" } } */ -- 2.21.0
Re: [PATCH][stage1] Prefer to use strlen call instead of inline expansion (PR target/88809).
Hi Martin On Tue, Apr 30, 2019 at 10:00:07AM -0600, Jeff Law wrote: > > 2019-04-23 Martin Liska > > > > PR target/88809 > > * config/i386/i386.c (ix86_expand_strlen): Use strlen call. > > With -minline-all-stringops use inline expansion using 4B loop. > > * doc/invoke.texi: Document the change of > > -minline-all-stringops. > > > > gcc/testsuite/ChangeLog: > > > > 2019-04-23 Martin Liska > > > > PR target/88809 > > * gcc.target/i386/pr88809.c: New test. > > * gcc.target/i386/pr88809-2.c: New test. > OK for the trunk. The tests fail on darwin FAIL: gcc.target/i386/pr88809-2.c scan-assembler call[ \\t]strlen FAIL: gcc.target/i386/pr88809.c scan-assembler call[ \\t]strlen This is fixed with the following patch --- ../_clean/gcc/testsuite/gcc.target/i386/pr88809.c 2019-05-02 10:16:16.0 +0200 +++ gcc/testsuite/gcc.target/i386/pr88809.c 2019-05-03 10:11:37.0 +0200 @@ -6,4 +6,4 @@ unsigned int foo (const char *ptr) return __builtin_strlen (ptr); } -/* { dg-final { scan-assembler "call\[ \t\]strlen" } } */ +/* { dg-final { scan-assembler "call\[ \t\]_?strlen" } } */ --- ../_clean/gcc/testsuite/gcc.target/i386/pr88809-2.c 2019-05-02 10:16:16.0 +0200 +++ gcc/testsuite/gcc.target/i386/pr88809-2.c 2019-05-03 11:00:28.0 +0200 @@ -6,4 +6,4 @@ unsigned int foo (const char *ptr) return __builtin_strlen (ptr); } -/* { dg-final { scan-assembler "call\[ \t\]strlen" } } */ +/* { dg-final { scan-assembler "(jmp|call)\[ \t\]_?strlen" } } */ (the ‘call’ is replaced with a ‘amp’ when using -m32). TIA Dominique
Re: [PATCH][stage1] Prefer to use strlen call instead of inline expansion (PR target/88809).
On 5/3/19 11:04 AM, Dominique d'Humières wrote: > Hi Martin > > On Tue, Apr 30, 2019 at 10:00:07AM -0600, Jeff Law wrote: >>> 2019-04-23 Martin Liska >>> >>> PR target/88809 >>> * config/i386/i386.c (ix86_expand_strlen): Use strlen call. >>> With -minline-all-stringops use inline expansion using 4B loop. >>> * doc/invoke.texi: Document the change of >>> -minline-all-stringops. >>> >>> gcc/testsuite/ChangeLog: >>> >>> 2019-04-23 Martin Liska >>> >>> PR target/88809 >>> * gcc.target/i386/pr88809.c: New test. >>> * gcc.target/i386/pr88809-2.c: New test. >> OK for the trunk. > > The tests fail on darwin > > FAIL: gcc.target/i386/pr88809-2.c scan-assembler call[ \\t]strlen > FAIL: gcc.target/i386/pr88809.c scan-assembler call[ \\t]strlen > > This is fixed with the following patch > > --- ../_clean/gcc/testsuite/gcc.target/i386/pr88809.c 2019-05-02 > 10:16:16.0 +0200 > +++ gcc/testsuite/gcc.target/i386/pr88809.c 2019-05-03 10:11:37.0 > +0200 > @@ -6,4 +6,4 @@ unsigned int foo (const char *ptr) >return __builtin_strlen (ptr); > } > > -/* { dg-final { scan-assembler "call\[ \t\]strlen" } } */ > +/* { dg-final { scan-assembler "call\[ \t\]_?strlen" } } */ > --- ../_clean/gcc/testsuite/gcc.target/i386/pr88809-2.c 2019-05-02 > 10:16:16.0 +0200 > +++ gcc/testsuite/gcc.target/i386/pr88809-2.c 2019-05-03 11:00:28.0 > +0200 > @@ -6,4 +6,4 @@ unsigned int foo (const char *ptr) >return __builtin_strlen (ptr); > } > > -/* { dg-final { scan-assembler "call\[ \t\]strlen" } } */ > +/* { dg-final { scan-assembler "(jmp|call)\[ \t\]_?strlen" } } */ > > (the ‘call’ is replaced with a ‘amp’ when using -m32). > > TIA > > Dominique > Thanks for testing. Feel free to install the patch please. Martin
Re: [PATCH] PR libstdc++/61761 fix std::proj for targets without C99 cproj
On 01/05/2019 01:09, Jonathan Wakely wrote: > The current generic implementation of __complex_proj used when cproj is > not available calculates the wrong projection, giving a different result > than given by C99's cproj. > > When C99 cproj is not available but isinf and copysign are, use those to > give correct results for float, double and long double. Otherwise, and > for other specializations of std::complex, just use a generic version > that returns its argument, and so doesn't support infinities. > > We might want to consider adding additional overloads of __complex_proj > to support extended types such as _Float64x, _Float128 etc. > > PR libstdc++/61761 > * include/std/complex (__complex_proj): Return parameter unchanged. > [_GLIBCXX_USE_C99_COMPLEX] (__complex_proj): Change overloads for > floating-point types to take std::complex arguments. > [_GLIBCXX_USE_C99_MATH_TR1] (__complex_proj): Add overloads for > floating-point types. > * testsuite/26_numerics/complex/proj.cc: New test. > > Tested powerpc64le-linux, powerpc-aix7.2.0.0, x86_64-freebsd11.2, > committed to trunk. fails on aarch64-none-elf (newlib) with FAIL: 26_numerics/complex/proj.cc (test for excess errors) Excess errors: /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:32: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:32: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:34: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:34: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? i assume std::copysign should be visible in via but cmath does not have it.
Re: [PATCH][stage1] Prefer to use strlen call instead of inline expansion (PR target/88809).
Done as revision r270843. Dominique > Le 3 mai 2019 à 11:06, Martin Liška a écrit : > > Feel free to install the patch please. > > Martin
[PATCH] Fix compile-time regression with new VN
When installing the new VN I forgot to update DOM fast queries before running it from PRE. Bootstrap / regtest running on x86_64-unknown-linux-gnu, will install to trunk and branch. It doesn't solve the PR in full which is about a regression from GCC 7 - working on that. Richard. 2019-05-03 Richard Biener PR tree-optimization/90316 * tree-ssa-pre.c (pass_pre::execute): Re-compute DOM fast queries before running VN. Index: gcc/tree-ssa-pre.c === --- gcc/tree-ssa-pre.c (revision 270842) +++ gcc/tree-ssa-pre.c (working copy) @@ -4197,6 +4197,7 @@ pass_pre::execute (function *fun) loop_optimizer_init (LOOPS_NORMAL); split_critical_edges (); scev_initialize (); + calculate_dominance_info (CDI_DOMINATORS); run_rpo_vn (VN_WALK);
[PATCH] Improve load/store of non-native vector sizes (PR88963)
This helps code generated by vector lowering of large vectors to small target supported ones by applying the same logic to loads and stores. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2019-05-03 Richard Biener PR tree-optimization/88963 * tree-ssa-forwprop.c (pass_forwprop::execute): Rewrite vector loads feeding only BIT_FIELD_REFs to component loads. Rewrite stores fed by CONSTRUCTORs to component stores. * gcc.dg/tree-ssa/ssa-fre-31.c: Disable forwprop. * gcc.target/i386/pr88963-1.c: New testcase. * gcc.target/i386/pr88963-2.c: Likewise. Index: gcc/tree-ssa-forwprop.c === --- gcc/tree-ssa-forwprop.c (revision 268137) +++ gcc/tree-ssa-forwprop.c (working copy) @@ -2400,6 +2400,72 @@ pass_forwprop::execute (function *fun) else gsi_next (&gsi); } + else if (TREE_CODE (TREE_TYPE (lhs)) == VECTOR_TYPE + && TYPE_MODE (TREE_TYPE (lhs)) == BLKmode + && gimple_assign_load_p (stmt) + && !gimple_has_volatile_ops (stmt) + && (TREE_CODE (gimple_assign_rhs1 (stmt)) + != TARGET_MEM_REF) + && !stmt_can_throw_internal (cfun, stmt)) + { + /* Rewrite loads used only in BIT_FIELD_REF extractions to +component-wise loads. */ + use_operand_p use_p; + imm_use_iterator iter; + bool rewrite = true; + FOR_EACH_IMM_USE_FAST (use_p, iter, lhs) + { + gimple *use_stmt = USE_STMT (use_p); + if (is_gimple_debug (use_stmt)) + continue; + if (!is_gimple_assign (use_stmt) + || gimple_assign_rhs_code (use_stmt) != BIT_FIELD_REF) + { + rewrite = false; + break; + } + } + if (rewrite) + { + gimple *use_stmt; + FOR_EACH_IMM_USE_STMT (use_stmt, iter, lhs) + { + if (is_gimple_debug (use_stmt)) + { + if (gimple_debug_bind_p (use_stmt)) + { + gimple_debug_bind_reset_value (use_stmt); + update_stmt (use_stmt); + } + continue; + } + + tree bfr = gimple_assign_rhs1 (use_stmt); + tree new_rhs = fold_build3 (BIT_FIELD_REF, + TREE_TYPE (bfr), + unshare_expr (rhs), + TREE_OPERAND (bfr, 1), + TREE_OPERAND (bfr, 2)); + gimple *new_stmt + = gimple_build_assign (gimple_assign_lhs (use_stmt), + new_rhs); + + location_t loc = gimple_location (use_stmt); + gimple_set_location (new_stmt, loc); + gimple_stmt_iterator gsi2 = gsi_for_stmt (use_stmt); + unlink_stmt_vdef (use_stmt); + gsi_remove (&gsi2, true); + + gsi_insert_before (&gsi, new_stmt, GSI_SAME_STMT); + } + + release_defs (stmt); + gsi_remove (&gsi, true); + } + else + gsi_next (&gsi); + } + else if (code == COMPLEX_EXPR) { /* Rewrite stores of a single-use complex build expression @@ -2437,6 +2503,65 @@ pass_forwprop::execute (function *fun) release_defs (stmt); gsi_remove (&gsi, true); } + else + gsi_next (&gsi); + } + else if (code == CONSTRUCTOR + && VECTOR_TYPE_P (TREE_TYPE (rhs)) + && TYPE_MODE (TREE_TYPE (rhs)) == BLKmode + && CONSTRUCTOR_NELTS (rhs) > 0 + && (!VECTOR_TYPE_P (TREE_TYPE (CONSTRUCTOR_ELT (rhs, 0)->value)) + || (TYPE_MODE (TREE_TYPE (CONSTRUCTOR_ELT (rhs, 0)->value)) + != BLKmode))) + { + /* Rewrite stores of a single-use vector constructors +to component-wise stores if the mode isn't supported. */ + use_operand_p use_p; + gimple *use_stmt; + if (single_imm_use (lhs, &use_p, &use_stmt) + && gimple_store_p (use_stmt) + && !gimple_has_volatile_ops (use_stmt) + && is_gimple_assign (use_stmt) +
Re: [PATCH] Fix part of PR87314, folding of &decl != "foo"
On Thu, Jan 10, 2019 at 2:41 PM Richard Biener wrote: > > > This fixes $subject and also "foo" != "bar" folding which was > somehow missing. It fixes only parts of the PR since the PR > is about PTA tracking string constants. > > It might help PR88775 but unless I can confirm that this is > just queued for GCC10. > > You might notice I'm treating string merging possibilities > conservatively (defer to runtime). > > Bootstrapped and tested on x86_64-unknown-linux-gnu. Applied as r270845. > Richard. > > From 8f14bac370b8334a42f985027394e9f3fdf9e2f1 Mon Sep 17 00:00:00 2001 > From: Richard Guenther > Date: Thu, 10 Jan 2019 10:24:20 +0100 > Subject: [PATCH] fix-pr87314-1 > > 2019-01-10 Richard Biener > > PR middle-end/87314 > * match.pd (cmp (convert1?@2 addr@0) (convert2? addr@1)): > Handle STRING_CST vs DECL or STRING_CST. > > * gcc.dg/pr87314-1.c: New testcase. > > diff --git a/gcc/match.pd b/gcc/match.pd > index 60b12f94f9e..95fa4e4a4dd 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -3896,6 +3896,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > || TREE_CODE (base1) == SSA_NAME > || TREE_CODE (base1) == STRING_CST)) > equal = (base0 == base1); > + HOST_WIDE_INT ioff0 = -1, ioff1 = -1; > + off0.is_constant (&ioff0); > + off1.is_constant (&ioff1); > } > (if (equal == 1 > && (cmp == EQ_EXPR || cmp == NE_EXPR > @@ -3919,10 +3922,23 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > (if (cmp == GT_EXPR && (known_gt (off0, off1) || known_le (off0, > off1))) > { constant_boolean_node (known_gt (off0, off1), type); })) >(if (equal == 0 > - && DECL_P (base0) && DECL_P (base1) > - /* If we compare this as integers require equal offset. */ > - && (!INTEGRAL_TYPE_P (TREE_TYPE (@2)) > - || known_eq (off0, off1))) > + && ((DECL_P (base0) && DECL_P (base1) > + /* If we compare this as integers require equal offset. */ > + && (!INTEGRAL_TYPE_P (TREE_TYPE (@2)) > + || known_eq (off0, off1))) > + || (DECL_P (base0) && TREE_CODE (base1) == STRING_CST) > + || (TREE_CODE (base0) == STRING_CST && DECL_P (base1)) > + || (TREE_CODE (base0) == STRING_CST > + && TREE_CODE (base1) == STRING_CST > + && ioff0 >= 0 && ioff1 >= 0 > + && ioff0 < TREE_STRING_LENGTH (base0) > + && ioff1 < TREE_STRING_LENGTH (base1) > + /* This is a too conservative test that the STRING_CSTs > + will not end up being string-merged. */ > + && strncmp (TREE_STRING_POINTER (base0) + ioff0, > + TREE_STRING_POINTER (base1) + ioff1, > + MIN (TREE_STRING_LENGTH (base0) - ioff0, > + TREE_STRING_LENGTH (base1) - ioff1)) != > 0))) > (switch > (if (cmp == EQ_EXPR) > { constant_boolean_node (false, type); }) > diff --git a/gcc/testsuite/gcc.dg/pr87314-1.c > b/gcc/testsuite/gcc.dg/pr87314-1.c > new file mode 100644 > index 000..4dc85c8eee6 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pr87314-1.c > @@ -0,0 +1,11 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O -fdump-tree-original" } */ > + > +int f(){ int a; return &a==(void *)"hello"; } > +int g(){ return "bye"=="hello"; } > +int h() { return "bye"=="hellobye"+5; } > + > +/* { dg-final { scan-tree-dump-times "hello" 1 "original" } } */ > +/* The test in h() should be retained because the result depends on > + string merging. */ > +/* { dg-final { scan-assembler "hello" } } */
[PATCH] Fix PR89518
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2019-05-03 Richard Biener PR middle-end/89518 * match.pd: Add pattern to optimize (A / B) * B + (A % B) to A. * gcc.dg/pr89518.c: New testcase. Index: gcc/match.pd === --- gcc/match.pd(revision 269242) +++ gcc/match.pd(working copy) @@ -2729,6 +2729,13 @@ (define_operator_list COND_TERNARY (mult (convert1? (exact_div @0 @@1)) (convert2? @1)) (convert @0)) +/* Simplify (A / B) * B + (A % B) -> A. */ +(for div (trunc_div ceil_div floor_div round_div) + mod (trunc_mod ceil_mod floor_mod round_mod) + (simplify + (plus:c (mult:c (div @0 @1) @1) (mod @0 @1)) + @0)) + /* ((X /[ex] A) +- B) * A --> X +- A * B. */ (for op (plus minus) (simplify Index: gcc/testsuite/gcc.dg/pr89518.c === --- gcc/testsuite/gcc.dg/pr89518.c (nonexistent) +++ gcc/testsuite/gcc.dg/pr89518.c (working copy) @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-original" } */ + +unsigned foo (unsigned a, unsigned b) +{ + return a/b * b + a%b; +} + +int bar (int a, int b) +{ + return a/b * b + a%b; +} + +/* { dg-final { scan-tree-dump-times "return a;" 2 "original" } } */
Re: [PATCH] Avoid epilogue peeling for x264 vectorization in x264_pixel_sad_x4_8x8
On Wed, Dec 12, 2018 at 11:54 AM Richard Biener wrote: > > > The following improves x264 vectorization by avoiding peeling for gaps > noticing that when the upper half of a vector is unused we can > load the lower part only (and fill the upper half with zeros - this > is what x86 does automatically, GIMPLE doesn't allow us to leave > the upper half undefined as RTL would with using subregs). > > The implementation is a little bit awkward as for optimal GIMPLE > code-generation and costing we'd like to go the strided load path > instead. That proves somewhat difficult though thus the following > is easier but doesn't fill out the re-align paths nor the masked > paths (at least the fully masked path would never need peeling for > gaps). > > Bootstrapped and tested on x86_64-unknown-linux-gnu, tested with > SPEC CPU 2006 and 2017 with the expected (~4%) improvement for > 625.x264_s. Didn't see any positive or negative effects elsewhere. > > Queued for GCC 10. Applied as r270847. Richard. > Richard. > > 2018-12-12 Richard Biener > > * tree-vect-stmts.c (get_group_load_store_type): Avoid > peeling for gaps by loading only lower halves of vectors > if possible. > (vectorizable_load): Likewise. > > * gcc.dg/vect/slp-reduc-sad-2.c: New testcase. > > Index: gcc/tree-vect-stmts.c > === > --- gcc/tree-vect-stmts.c (revision 266744) > +++ gcc/tree-vect-stmts.c (working copy) > @@ -2194,6 +2194,29 @@ get_group_load_store_type (stmt_vec_info > && gap < (vect_known_alignment_in_bytes (first_dr_info) > / vect_get_scalar_dr_size (first_dr_info))) > overrun_p = false; > + > + /* If the gap splits the vector in half and the target > +can do half-vector operations avoid the epilogue peeling > +by simply loading half of the vector only. Usually > +the construction with an upper zero half will be elided. */ > + dr_alignment_support alignment_support_scheme; > + scalar_mode elmode = SCALAR_TYPE_MODE (TREE_TYPE (vectype)); > + machine_mode vmode; > + if (overrun_p > + && !masked_p > + && (((alignment_support_scheme > + = vect_supportable_dr_alignment (first_dr_info, false))) > + == dr_aligned > + || alignment_support_scheme == dr_unaligned_supported) > + && known_eq (nunits, (group_size - gap) * 2) > + && mode_for_vector (elmode, (group_size - gap)).exists (&vmode) > + && VECTOR_MODE_P (vmode) > + && targetm.vector_mode_supported_p (vmode) > + && (convert_optab_handler (vec_init_optab, > +TYPE_MODE (vectype), vmode) > + != CODE_FOR_nothing)) > + overrun_p = false; > + > if (overrun_p && !can_overrun_p) > { > if (dump_enabled_p ()) > @@ -8362,8 +8385,24 @@ vectorizable_load (stmt_vec_info stmt_in > } > else > { > + tree ltype = vectype; > + /* If there's no peeling for gaps but we have a gap > + with slp loads then load the lower half of the > + vector only. See get_group_load_store_type for > + when we apply this optimization. */ > + if (slp > + && loop_vinfo > + && !LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo) > + && DR_GROUP_GAP (first_stmt_info) != 0 > + && known_eq (nunits, > +(group_size > + - DR_GROUP_GAP (first_stmt_info)) * > 2)) > + ltype = build_vector_type (TREE_TYPE (vectype), > +(group_size > + - DR_GROUP_GAP > + (first_stmt_info))); > data_ref > - = fold_build2 (MEM_REF, vectype, dataref_ptr, > + = fold_build2 (MEM_REF, ltype, dataref_ptr, > dataref_offset > ? dataref_offset > : build_int_cst (ref_type, 0)); > @@ -8377,6 +8416,23 @@ vectorizable_load (stmt_vec_info stmt_in > TREE_TYPE (data_ref) > = build_aligned_type (TREE_TYPE (data_ref), > TYPE_ALIGN (elem_type)); > + if (ltype != vectype) > + { > + vect_c
Re: [PATCH] Error only when -mabi=ms is used on a non-MS_ABI system (PR sanitizer/90312).
On 5/2/19 5:19 PM, Jakub Jelinek wrote: > On Thu, May 02, 2019 at 05:11:02PM +0200, Martin Liška wrote: >> As mentioned in the PR, we should not provide an error on mingw and cygwin >> targets. >> >> Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Can one use sysv_abi in code compiled on windows (where msabi is the > default)? Who knows, probably not. > If yes, don't you get ICE in that case? As in, shouldn't the > test be that we do not support -fsanitize=address with non-default ABI? I like the approach. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin > > Jakub > >From b077a74e5dcc1e2868ee9d1480cc2d935533006a Mon Sep 17 00:00:00 2001 From: marxin Date: Thu, 2 May 2019 13:37:35 +0200 Subject: [PATCH] Error only when a non-default -mabi is used with sanitizers (PR sanitizer/90312). gcc/ChangeLog: 2019-05-02 Martin Liska PR sanitizer/90312 * config/i386/i386.c (ix86_option_override_internal): Error only when -mabi is selected to a non-default version. gcc/testsuite/ChangeLog: 2019-05-02 Martin Liska PR sanitizer/90312 * gcc.dg/asan/pr87930.c: Run the test only on *linux or *gnu systems. * gcc.dg/tsan/pr88017.c: Likewise. --- gcc/config/i386/i386.c | 17 +++-- gcc/testsuite/gcc.dg/asan/pr87930.c | 2 +- gcc/testsuite/gcc.dg/tsan/pr88017.c | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index bc2348c3bc7..37946e49efb 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -3706,12 +3706,17 @@ ix86_option_override_internal (bool main_args_p, error ("%<-mabi=ms%> not supported with X32 ABI"); gcc_assert (opts->x_ix86_abi == SYSV_ABI || opts->x_ix86_abi == MS_ABI); - if ((opts->x_flag_sanitize & SANITIZE_USER_ADDRESS) && opts->x_ix86_abi == MS_ABI) -error ("%<-mabi=ms%> not supported with %<-fsanitize=address%>"); - if ((opts->x_flag_sanitize & SANITIZE_KERNEL_ADDRESS) && opts->x_ix86_abi == MS_ABI) -error ("%<-mabi=ms%> not supported with %<-fsanitize=kernel-address%>"); - if ((opts->x_flag_sanitize & SANITIZE_THREAD) && opts->x_ix86_abi == MS_ABI) -error ("%<-mabi=ms%> not supported with %<-fsanitize=thread%>"); + const char *abi_name = opts->x_ix86_abi == MS_ABI ? "ms" : "sysv"; + if ((opts->x_flag_sanitize & SANITIZE_USER_ADDRESS) + && opts->x_ix86_abi != DEFAULT_ABI) +error ("%<-mabi=%s%> not supported with %<-fsanitize=address%>", abi_name); + if ((opts->x_flag_sanitize & SANITIZE_KERNEL_ADDRESS) + && opts->x_ix86_abi != DEFAULT_ABI) +error ("%<-mabi=%s%> not supported with %<-fsanitize=kernel-address%>", + abi_name); + if ((opts->x_flag_sanitize & SANITIZE_THREAD) + && opts->x_ix86_abi != DEFAULT_ABI) +error ("%<-mabi=%s%> not supported with %<-fsanitize=thread%>", abi_name); /* For targets using ms ABI enable ms-extensions, if not explicit turned off. For non-ms ABI we turn off this diff --git a/gcc/testsuite/gcc.dg/asan/pr87930.c b/gcc/testsuite/gcc.dg/asan/pr87930.c index 4f8e6999fde..5a65d3fb030 100644 --- a/gcc/testsuite/gcc.dg/asan/pr87930.c +++ b/gcc/testsuite/gcc.dg/asan/pr87930.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && lp64 } } } */ +/* { dg-do compile { target { { i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } && lp64 } } } */ /* { dg-options "-fsanitize=address -mabi=ms" } */ int i; diff --git a/gcc/testsuite/gcc.dg/tsan/pr88017.c b/gcc/testsuite/gcc.dg/tsan/pr88017.c index 82693a67e87..10df2818b0d 100644 --- a/gcc/testsuite/gcc.dg/tsan/pr88017.c +++ b/gcc/testsuite/gcc.dg/tsan/pr88017.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && lp64 } } } */ +/* { dg-do compile { target { { i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } && lp64 } } } */ /* { dg-options "-fsanitize=thread -mabi=ms" } */ int i; -- 2.21.0
[PATCH] Silent -Wformat-truncation warnings in date_and_time.c.
Hi. The patch is about suppression of the following warning: /home/gcc/buildworker/zenith-gcc-trunk-weekly/build/libgfortran/intrinsics/date_and_time.c:165:33: warning: ‘%04d’ directive output may be truncated writing between 4 and 11 bytes into a region of size 9 [-Wformat-truncation=] /home/gcc/buildworker/zenith-gcc-trunk-weekly/build/libgfortran/intrinsics/date_and_time.c:172:33: warning: ‘%+03d’ directive output may be truncated writing between 3 and 9 bytes into a region of size 6 [-Wformat-truncation=] Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin libgfortran/ChangeLog: 2019-05-03 Martin Liska * intrinsics/date_and_time.c (DATE_LEN): Enlarge in order to deal with the warning. (ZONE_LEN): Likewise. --- libgfortran/intrinsics/date_and_time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libgfortran/intrinsics/date_and_time.c b/libgfortran/intrinsics/date_and_time.c index d536404a214..ff7204762da 100644 --- a/libgfortran/intrinsics/date_and_time.c +++ b/libgfortran/intrinsics/date_and_time.c @@ -117,9 +117,9 @@ gmtime_r (const time_t * timep, struct tm * result) TODO : - Check year boundaries. */ -#define DATE_LEN 8 +#define DATE_LEN 24 #define TIME_LEN 10 -#define ZONE_LEN 5 +#define ZONE_LEN 11 #define VALUES_SIZE 8 extern void date_and_time (char *, char *, char *, gfc_array_i4 *,
[PATCH] Support again multiple --help options (PR other/90315).
Hi. The patch prints all values requested in multiple --help options. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin gcc/ChangeLog: 2019-05-03 Martin Liska PR other/90315 * opts-global.c (decode_options): Print help for all help_option_arguments. * opts.c (print_help): Add new argument. (common_handle_option): Remember all values into help_option_arguments. * opts.h (print_help): Add new argument. --- gcc/opts-global.c | 4 ++-- gcc/opts.c| 7 --- gcc/opts.h| 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gcc/opts-global.c b/gcc/opts-global.c index e6eaeb20bf7..ce0b1f61603 100644 --- a/gcc/opts-global.c +++ b/gcc/opts-global.c @@ -317,8 +317,8 @@ decode_options (struct gcc_options *opts, struct gcc_options *opts_set, finish_options (opts, opts_set, loc); /* Print --help=* if used. */ - if (help_option_argument != NULL) -print_help (opts, lang_mask); + for (unsigned i = 0; i < help_option_arguments.length (); i++) +print_help (opts, lang_mask, help_option_arguments[i]); } /* Hold command-line options associated with stack limitation. */ diff --git a/gcc/opts.c b/gcc/opts.c index 71adc21cb26..1658046d2be 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -856,7 +856,7 @@ control_options_for_live_patching (struct gcc_options *opts, } /* --help option argument if set. */ -const char *help_option_argument = NULL; +vec help_option_arguments; /* After all options at LOC have been read into OPTS and OPTS_SET, @@ -2061,7 +2061,8 @@ check_alignment_argument (location_t loc, const char *flag, const char *name) /* Print help when OPT__help_ is set. */ void -print_help (struct gcc_options *opts, unsigned int lang_mask) +print_help (struct gcc_options *opts, unsigned int lang_mask, + const char *help_option_argument) { const char *a = help_option_argument; unsigned int include_flags = 0; @@ -2254,7 +2255,7 @@ common_handle_option (struct gcc_options *opts, case OPT__help_: { - help_option_argument = arg; + help_option_arguments.safe_push (arg); opts->x_exit_after_options = true; break; } diff --git a/gcc/opts.h b/gcc/opts.h index a8afc2385a9..e5723a946f7 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -419,7 +419,8 @@ extern bool target_handle_option (struct gcc_options *opts, extern void finish_options (struct gcc_options *opts, struct gcc_options *opts_set, location_t loc); -extern void print_help (struct gcc_options *opts, unsigned int lang_mask); +extern void print_help (struct gcc_options *opts, unsigned int lang_mask, const + char *help_option_argument); extern void default_options_optimization (struct gcc_options *opts, struct gcc_options *opts_set, struct cl_decoded_option *decoded_options, @@ -443,7 +444,7 @@ extern const struct sanitizer_opts_s bool can_recover; } sanitizer_opts[]; -extern const char *help_option_argument; +extern vec help_option_arguments; extern void add_misspelling_candidates (auto_vec *candidates, const struct cl_option *option,
Re: [PATCH] PR libstdc++/61761 fix std::proj for targets without C99 cproj
On 03/05/19 09:23 +, Szabolcs Nagy wrote: On 01/05/2019 01:09, Jonathan Wakely wrote: The current generic implementation of __complex_proj used when cproj is not available calculates the wrong projection, giving a different result than given by C99's cproj. When C99 cproj is not available but isinf and copysign are, use those to give correct results for float, double and long double. Otherwise, and for other specializations of std::complex, just use a generic version that returns its argument, and so doesn't support infinities. We might want to consider adding additional overloads of __complex_proj to support extended types such as _Float64x, _Float128 etc. PR libstdc++/61761 * include/std/complex (__complex_proj): Return parameter unchanged. [_GLIBCXX_USE_C99_COMPLEX] (__complex_proj): Change overloads for floating-point types to take std::complex arguments. [_GLIBCXX_USE_C99_MATH_TR1] (__complex_proj): Add overloads for floating-point types. * testsuite/26_numerics/complex/proj.cc: New test. Tested powerpc64le-linux, powerpc-aix7.2.0.0, x86_64-freebsd11.2, committed to trunk. fails on aarch64-none-elf (newlib) with FAIL: 26_numerics/complex/proj.cc (test for excess errors) Excess errors: /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:32: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:32: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:34: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:34: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? i assume std::copysign should be visible in via It should, but only for C++11, and this needs to work for C++98 too. I missed that problem. but cmath does not have it. Hmm, which file in the source tree does the include/cmath symlink in the build tree point to?
[PATCH] Fix PR90316
I am testing the following patch to remove the code determining the target virtual operand to walk to and instead compute it based on the immediate dominator which we will reach anyways (or a dominating block) during maybe_skip_until. More simplifying might be possible but I'm trying to keep the patch small and suitable for backporting up to the GCC 8 branch where this regressed. Note this will handle even more CFG shapes now and seems to expose some uninit warnings in dwarf2out.c (at least). Bootstrap & regtest running on x86_64-unknown-linux-gnu. Richard. 2019-05-03 Richard Biener PR tree-optimization/90316 * tree-ssa-alias.c (maybe_skip_until): Pass in target BB, compute target on demand. (get_continuation_for_phi): Remove code walking stmts to get to a target virtual operand which could end up being quadratic. Index: gcc/tree-ssa-alias.c === --- gcc/tree-ssa-alias.c(revision 270847) +++ gcc/tree-ssa-alias.c(working copy) @@ -2598,8 +2598,8 @@ stmt_kills_ref_p (gimple *stmt, tree ref case false is returned. The walk starts with VUSE, one argument of PHI. */ static bool -maybe_skip_until (gimple *phi, tree target, ao_ref *ref, - tree vuse, unsigned int *cnt, bitmap *visited, +maybe_skip_until (gimple *phi, tree &target, basic_block target_bb, + ao_ref *ref, tree vuse, unsigned int *cnt, bitmap *visited, bool abort_on_visited, void *(*translate)(ao_ref *, tree, void *, bool *), void *data) @@ -2615,6 +2615,19 @@ maybe_skip_until (gimple *phi, tree targ while (vuse != target) { gimple *def_stmt = SSA_NAME_DEF_STMT (vuse); + /* If we are searching for the target VUSE by walking up to + TARGET_BB dominating the original PHI we are finished once +we reach a default def or a definition in a block dominating +that block. Update TARGET and return. */ + if (!target + && (gimple_nop_p (def_stmt) + || dominated_by_p (CDI_DOMINATORS, +target_bb, gimple_bb (def_stmt + { + target = vuse; + return true; + } + /* Recurse for PHI nodes. */ if (gimple_code (def_stmt) == GIMPLE_PHI) { @@ -2698,49 +2711,17 @@ get_continuation_for_phi (gimple *phi, a arg0 = NULL_TREE; } /* If not, look if we can reach such candidate by walking defs - of a PHI arg without crossing other PHIs. */ - if (! arg0) -for (i = 0; i < nargs; ++i) - { - arg0 = PHI_ARG_DEF (phi, i); - gimple *def = SSA_NAME_DEF_STMT (arg0); - /* Backedges can't work. */ - if (dominated_by_p (CDI_DOMINATORS, - gimple_bb (def), phi_bb)) - continue; - /* See below. */ - if (gimple_code (def) == GIMPLE_PHI) - continue; - while (! dominated_by_p (CDI_DOMINATORS, -phi_bb, gimple_bb (def))) - { - arg0 = gimple_vuse (def); - if (SSA_NAME_IS_DEFAULT_DEF (arg0)) - break; - def = SSA_NAME_DEF_STMT (arg0); - if (gimple_code (def) == GIMPLE_PHI) - { - /* Do not try to look through arbitrarily complicated - CFGs. For those looking for the first VUSE starting - from the end of the immediate dominator of phi_bb - is likely faster. */ - arg0 = NULL_TREE; - goto next; - } - } - break; -next:; - } - if (! arg0) -return NULL_TREE; + until we hit the immediate dominator. maybe_skip_until will + do that for us. */ + basic_block dom = get_immediate_dominator (CDI_DOMINATORS, phi_bb); - /* Then check against the found candidate. */ + /* Then check against the (to be) found candidate. */ for (i = 0; i < nargs; ++i) { arg1 = PHI_ARG_DEF (phi, i); if (arg1 == arg0) ; - else if (! maybe_skip_until (phi, arg0, ref, arg1, cnt, visited, + else if (! maybe_skip_until (phi, arg0, dom, ref, arg1, cnt, visited, abort_on_visited, /* Do not translate when walking over backedges. */
Re: [PATCH] PR libstdc++/61761 fix std::proj for targets without C99 cproj
On 03/05/2019 12:16, Jonathan Wakely wrote: > On 03/05/19 09:23 +, Szabolcs Nagy wrote: >> On 01/05/2019 01:09, Jonathan Wakely wrote: >>> The current generic implementation of __complex_proj used when cproj is >>> not available calculates the wrong projection, giving a different result >>> than given by C99's cproj. >>> >>> When C99 cproj is not available but isinf and copysign are, use those to >>> give correct results for float, double and long double. Otherwise, and >>> for other specializations of std::complex, just use a generic version >>> that returns its argument, and so doesn't support infinities. >>> >>> We might want to consider adding additional overloads of __complex_proj >>> to support extended types such as _Float64x, _Float128 etc. >>> >>> PR libstdc++/61761 >>> * include/std/complex (__complex_proj): Return parameter unchanged. >>> [_GLIBCXX_USE_C99_COMPLEX] (__complex_proj): Change overloads for >>> floating-point types to take std::complex arguments. >>> [_GLIBCXX_USE_C99_MATH_TR1] (__complex_proj): Add overloads for >>> floating-point types. >>> * testsuite/26_numerics/complex/proj.cc: New test. >>> >>> Tested powerpc64le-linux, powerpc-aix7.2.0.0, x86_64-freebsd11.2, >>> committed to trunk. >> >> fails on aarch64-none-elf (newlib) with >> >> FAIL: 26_numerics/complex/proj.cc (test for excess errors) >> Excess errors: >> /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:32: >> error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? >> /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:32: >> error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? >> /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:34: >> error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? >> /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:34: >> error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? >> >> i assume std::copysign should be visible in via > > It should, but only for C++11, and this needs to work for C++98 too. I > missed that problem. > >> but cmath does not have it. > > Hmm, which file in the source tree does the include/cmath symlink in > the build tree point to? /work/b/build-aarch64-none-elf/obj/gcc2/aarch64-none-elf/libstdc++-v3$ ls -l include/cmath lrwxrwxrwx 1 szabolcs szabolcs 51 May 1 18:06 include/cmath -> /work/b/src/gcc/libstdc++-v3/include/c_global/cmath
Re: [RFC][PATCH] Postpone print of --help=* option.
On 01/04/2019 13:11, Martin Liška wrote: > Hi. > > Last week I was curious which warnings are disabled by default on top > of -Wall and -Wextra. Thus I used --help=warning and noticed some discrepancy > in between documentation and output of the --help option. > > I created PR89885 where I explained that OPT__help_ option handling happens > early. That's why LangEnabledBy are not reflected and similarly target > overrides > don't take place. > > I'm attaching diff for --help=warning for C++ and -Ofast. > > Thoughts? since this change on arm-* and aarch64-* running RUNTESTFLAGS=help.exp i see FAIL: compiler driver --help=params --help=optimizers option(s): "maximum number of" present in output FAIL: compiler driver --help=params option(s): "[^.]$" absent from output: "e" (indeed previously there were several 'max-*' params in the output now there are none) > > gcc/ChangeLog: > > 2019-04-01 Martin Liska > > * gcc.c (process_command): Add dummy file only > if n_infiles == 0. > * opts-global.c (decode_options): Pass lang_mask. > * opts.c (print_help): New function. > (finish_options): Print --help if help_option_argument > is set. > (common_handle_option): Factor out content of OPT__help_ > into print_help. > * opts.h (finish_options): Add new argument. > --- > gcc/gcc.c | 3 +- > gcc/opts-global.c | 2 +- > gcc/opts.c| 267 -- > gcc/opts.h| 3 +- > 4 files changed, 146 insertions(+), 129 deletions(-) > >
Re: [RFC][PATCH] Postpone print of --help=* option.
On 5/3/19 1:33 PM, Szabolcs Nagy wrote: > On 01/04/2019 13:11, Martin Liška wrote: >> Hi. >> >> Last week I was curious which warnings are disabled by default on top >> of -Wall and -Wextra. Thus I used --help=warning and noticed some discrepancy >> in between documentation and output of the --help option. >> >> I created PR89885 where I explained that OPT__help_ option handling happens >> early. That's why LangEnabledBy are not reflected and similarly target >> overrides >> don't take place. >> >> I'm attaching diff for --help=warning for C++ and -Ofast. >> >> Thoughts? > > since this change on arm-* and aarch64-* running RUNTESTFLAGS=help.exp i see > > FAIL: compiler driver --help=params --help=optimizers option(s): "maximum > number of" present in output > FAIL: compiler driver --help=params option(s): "[^.]$" absent from output: "e" > > (indeed previously there were several 'max-*' params > in the output now there are none) > >> >> gcc/ChangeLog: >> >> 2019-04-01 Martin Liska >> >> * gcc.c (process_command): Add dummy file only >> if n_infiles == 0. >> * opts-global.c (decode_options): Pass lang_mask. >> * opts.c (print_help): New function. >> (finish_options): Print --help if help_option_argument >> is set. >> (common_handle_option): Factor out content of OPT__help_ >> into print_help. >> * opts.h (finish_options): Add new argument. >> --- >> gcc/gcc.c | 3 +- >> gcc/opts-global.c | 2 +- >> gcc/opts.c| 267 -- >> gcc/opts.h| 3 +- >> 4 files changed, 146 insertions(+), 129 deletions(-) >> >> > Sure, there's a patch candidate: https://gcc.gnu.org/ml/gcc-patches/2019-05/msg00114.html and PR: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90315 Should be fixed soon. Martin
Re: [PATCH] PR libstdc++/61761 fix std::proj for targets without C99 cproj
On 03/05/19 11:21 +, Szabolcs Nagy wrote: On 03/05/2019 12:16, Jonathan Wakely wrote: On 03/05/19 09:23 +, Szabolcs Nagy wrote: On 01/05/2019 01:09, Jonathan Wakely wrote: The current generic implementation of __complex_proj used when cproj is not available calculates the wrong projection, giving a different result than given by C99's cproj. When C99 cproj is not available but isinf and copysign are, use those to give correct results for float, double and long double. Otherwise, and for other specializations of std::complex, just use a generic version that returns its argument, and so doesn't support infinities. We might want to consider adding additional overloads of __complex_proj to support extended types such as _Float64x, _Float128 etc. PR libstdc++/61761 * include/std/complex (__complex_proj): Return parameter unchanged. [_GLIBCXX_USE_C99_COMPLEX] (__complex_proj): Change overloads for floating-point types to take std::complex arguments. [_GLIBCXX_USE_C99_MATH_TR1] (__complex_proj): Add overloads for floating-point types. * testsuite/26_numerics/complex/proj.cc: New test. Tested powerpc64le-linux, powerpc-aix7.2.0.0, x86_64-freebsd11.2, committed to trunk. fails on aarch64-none-elf (newlib) with FAIL: 26_numerics/complex/proj.cc (test for excess errors) Excess errors: /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:32: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:32: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:34: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:34: error: 'copysign' is not a member of 'std'; did you mean 'copy_n'? i assume std::copysign should be visible in via It should, but only for C++11, and this needs to work for C++98 too. I missed that problem. but cmath does not have it. Hmm, which file in the source tree does the include/cmath symlink in the build tree point to? /work/b/build-aarch64-none-elf/obj/gcc2/aarch64-none-elf/libstdc++-v3$ ls -l include/cmath lrwxrwxrwx 1 szabolcs szabolcs 51 May 1 18:06 include/cmath -> /work/b/src/gcc/libstdc++-v3/include/c_global/cmath Oh, I see the problem. and both guard use of copysign by _GLIBCXX_USE_C99_MATH_TR1 but the test just uses it unconditionally. Does the attached patch work? diff --git a/libstdc++-v3/testsuite/26_numerics/complex/proj.cc b/libstdc++-v3/testsuite/26_numerics/complex/proj.cc index b70ca4c58e9..e4e086936d1 100644 --- a/libstdc++-v3/testsuite/26_numerics/complex/proj.cc +++ b/libstdc++-v3/testsuite/26_numerics/complex/proj.cc @@ -21,6 +21,17 @@ #include #include +namespace test +{ +#ifdef _GLIBCXX_USE_C99_MATH_TR1 + using std::copysign; +#else + bool copysign(float f) { return __builtin_copysignf(f); } + bool copysign(double f) { return __builtin_copysign(f); } + bool copysign(long double f) { return __builtin_copysignl(f); } +#endif +} + template bool eq(const std::complex& x, const std::complex& y) { @@ -28,9 +39,9 @@ bool eq(const std::complex& x, const std::complex& y) bool nan_imags = std::isnan(x.imag()) && std::isnan(y.imag()); bool sign_reals -= std::copysign(T(1), x.real()) == std::copysign(T(1), y.real()); += test::copysign(T(1), x.real()) == test::copysign(T(1), y.real()); bool sign_imags -= std::copysign(T(1), x.imag()) == std::copysign(T(1), y.imag()); += test::copysign(T(1), x.imag()) == test::copysign(T(1), y.imag()); return ((x.real() == y.real() && sign_reals) || nan_reals) && ((x.imag() == y.imag() && sign_imags) || nan_imags);
Re: libstdc++/90277 Review rehash policy
On 03/05/19 06:21 +0200, François Dumont wrote: Hi This is a patch I already proposed in another thread but I review it and moreover there is now a PR associated so I am submitting it as a brand new one. So working on PR 68303 I noticed that one of the performance issue of current implementation is that initial sizing of buckets is small. In tr1 implementation we were starting at 11 but now we go through 2, 3, 5, 7 and eventually 11, a lot of intermediate reallocation/rehash. It can be considered as a fix for PR 90277 cause when initial bucket count is 11 there is no rehash anymore during those tests. Compared to initial submission this version has the refinement that if the user explicitly set initial bucket count we respect it and do not jump to 11. Additionally this patch extend the PR 87135 fix to the power of 2 rehash policy alternative and it adopts the long double versions of builtin ceil/floor as advised in another message thread. Last I realized that _Hashtable<>::reserve could leverage on rehash policy _M_bkt_for_elements rather than trying to compute it itself, it brings more consistency in the container behavior. * include/bits/hashtable.h (_Hashtable<>::rehash): Review comment. * include/bits/hashtable_policy.h (_Prime_rehash_policy::_M_bkt_for_elements): Use __builtin_ceill. (_Power2_rehash_policy::_M_bkt_for_elements): Likewise. (_Power2_rehash_policy::_M_next_bkt): Enforce returning a result not smaller than input value rather than always greater. Preserve _M_next_resize if called with 0 input. Use __builtin_floorl. (_Power2_rehash_policy::_M_need_rehash): Rehash only if number of elements + number of insertions is greater than _M_next_resize. Start with 11 buckets if not told otherwise. Use __builtin_floorl. (_Rehash_base<>::reserve): Use rehash policy _M_bkt_for_elements. * src/c++11/hashtable_c++0x.cc (_Prime_rehash_policy::_M_next_bkt): Preserve _M_next_resize if called with 0 input. Use __builtin_floorl. (_Prime_rehash_policy::_M_need_rehash): Start with 11 buckets if not told otherwise. Use __builtin_floorl. * testsuite/23_containers/unordered_set/hash_policy/71181.cc: Adapt test to also validate _Power2_rehash_policy. * testsuite/23_containers/unordered_set/hash_policy/power2_rehash.cc: Adapt. Tested under Linux x86_64 normal and debug modes. Ok to commit ? Yes, looks good - thanks!
[wwwdocs] C++17 library is no longer experimental
I've committed this patch to /gcc-9/changes.html (and a follow-up to fix some bad HTML markup). Index: htdocs/gcc-9/changes.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-9/changes.html,v retrieving revision 1.63 diff -u -r1.63 changes.html --- htdocs/gcc-9/changes.html 3 May 2019 07:52:47 - 1.63 +++ htdocs/gcc-9/changes.html 3 May 2019 12:24:02 - @@ -644,13 +644,18 @@ Runtime Library (libstdc++) - Improved experimental support for C++17, including: + Improved support for C++17, including: + The C++17 implementation is no longer experimental. Parallel algorithms and(requires TBB 2018 or newer). . + +Using the types and functions in +does not require linking with -lstdc++fs now. + Improved experimental support for C++2a,
[PATCH] Prep for PR88828 fix
The following refactors simplify_vector_constructor and adds handling of constants to it in a straight-forward way. A followup will handle the testcases posted in HJs patch. Bootstrap / regtest running on x86_64-unknown-linux-gnu. Richard. 2019-05-03 Richard Biener PR tree-optimization/88828 * tree-ssa-forwprop.c (get_bit_field_ref_def): Split out from... (simplify_vector_constructor): ...here. Handle constants in the constructor. * gcc.target/i386/pr88828-0.c: New testcase. Index: gcc/tree-ssa-forwprop.c === --- gcc/tree-ssa-forwprop.c (revision 270847) +++ gcc/tree-ssa-forwprop.c (working copy) @@ -1997,6 +1997,44 @@ simplify_permutation (gimple_stmt_iterat return 0; } +/* Get the BIT_FIELD_REF definition of VAL, if any, looking through + conversions with code CONV_CODE or update it if still ERROR_MARK. + Return NULL_TREE if no such matching def was found. */ + +static tree +get_bit_field_ref_def (tree val, enum tree_code &conv_code) +{ + if (TREE_CODE (val) != SSA_NAME) +return NULL_TREE ; + gimple *def_stmt = get_prop_source_stmt (val, false, NULL); + if (!def_stmt) +return NULL_TREE; + enum tree_code code = gimple_assign_rhs_code (def_stmt); + if (code == FLOAT_EXPR + || code == FIX_TRUNC_EXPR) +{ + tree op1 = gimple_assign_rhs1 (def_stmt); + if (conv_code == ERROR_MARK) + { + if (maybe_ne (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (val))), + GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op1) + return NULL_TREE; + conv_code = code; + } + else if (conv_code != code) + return NULL_TREE; + if (TREE_CODE (op1) != SSA_NAME) + return NULL_TREE; + def_stmt = SSA_NAME_DEF_STMT (op1); + if (! is_gimple_assign (def_stmt)) + return NULL_TREE; + code = gimple_assign_rhs_code (def_stmt); +} + if (code != BIT_FIELD_REF) +return NULL_TREE; + return gimple_assign_rhs1 (def_stmt); +} + /* Recognize a VEC_PERM_EXPR. Returns true if there were any changes. */ static bool @@ -2027,6 +2065,9 @@ simplify_vector_constructor (gimple_stmt orig[1] = NULL; conv_code = ERROR_MARK; maybe_ident = true; + tree one_constant = NULL_TREE; + auto_vec constants; + constants.safe_grow_cleared (nelts); FOR_EACH_VEC_SAFE_ELT (CONSTRUCTOR_ELTS (op), i, elt) { tree ref, op1; @@ -2034,68 +2075,55 @@ simplify_vector_constructor (gimple_stmt if (i >= nelts) return false; - if (TREE_CODE (elt->value) != SSA_NAME) - return false; - def_stmt = get_prop_source_stmt (elt->value, false, NULL); - if (!def_stmt) - return false; - code = gimple_assign_rhs_code (def_stmt); - if (code == FLOAT_EXPR - || code == FIX_TRUNC_EXPR) + op1 = get_bit_field_ref_def (elt->value, conv_code); + if (op1) { - op1 = gimple_assign_rhs1 (def_stmt); - if (conv_code == ERROR_MARK) + ref = TREE_OPERAND (op1, 0); + unsigned int j; + for (j = 0; j < 2; ++j) { - if (maybe_ne (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (elt->value))), - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op1) - return false; - conv_code = code; + if (!orig[j]) + { + if (TREE_CODE (ref) != SSA_NAME) + return false; + if (! VECTOR_TYPE_P (TREE_TYPE (ref)) + || ! useless_type_conversion_p (TREE_TYPE (op1), + TREE_TYPE (TREE_TYPE (ref + return false; + if (j && !useless_type_conversion_p (TREE_TYPE (orig[0]), + TREE_TYPE (ref))) + return false; + orig[j] = ref; + break; + } + else if (ref == orig[j]) + break; } - else if (conv_code != code) + if (j == 2) return false; - if (TREE_CODE (op1) != SSA_NAME) - return false; - def_stmt = SSA_NAME_DEF_STMT (op1); - if (! is_gimple_assign (def_stmt)) + + unsigned int elt; + if (maybe_ne (bit_field_size (op1), elem_size) + || !constant_multiple_p (bit_field_offset (op1), elem_size, &elt)) return false; - code = gimple_assign_rhs_code (def_stmt); + if (j) + elt += nelts; + if (elt != i) + maybe_ident = false; + sel.quick_push (elt); } - if (code != BIT_FIELD_REF) - return false; - op1 = gimple_assign_rhs1 (def_stmt); - ref = TREE_OPERAND (op1, 0); - unsigned int j; - for (j = 0; j < 2; ++j) + else if (CONSTANT_CLASS_P (elt->value)) { - if (!or
Re: [PATCH] Fix PR90316
On Fri, 3 May 2019, Richard Biener wrote: > > I am testing the following patch to remove the code determining > the target virtual operand to walk to and instead compute it > based on the immediate dominator which we will reach anyways > (or a dominating block) during maybe_skip_until. > > More simplifying might be possible but I'm trying to keep the > patch small and suitable for backporting up to the GCC 8 branch > where this regressed. > > Note this will handle even more CFG shapes now and seems to > expose some uninit warnings in dwarf2out.c (at least). I can't seem to find an initializer that would "trap" on use so I'm going to do Index: gcc/dwarf2out.c === --- gcc/dwarf2out.c (revision 270849) +++ gcc/dwarf2out.c (working copy) @@ -15461,7 +15461,7 @@ mem_loc_descriptor (rtx rtl, machine_mod if (mode != GET_MODE (rtl) && GET_MODE (rtl) != VOIDmode) return NULL; - scalar_int_mode int_mode, inner_mode, op1_mode; + scalar_int_mode int_mode = SImode, inner_mode, op1_mode; switch (GET_CODE (rtl)) { case POST_INC: unless somebody comes up with something clever over the weekend... Richard. > Bootstrap & regtest running on x86_64-unknown-linux-gnu. > > Richard. > > 2019-05-03 Richard Biener > > PR tree-optimization/90316 > * tree-ssa-alias.c (maybe_skip_until): Pass in target BB, > compute target on demand. > (get_continuation_for_phi): Remove code walking stmts to > get to a target virtual operand which could end up being > quadratic. > > Index: gcc/tree-ssa-alias.c > === > --- gcc/tree-ssa-alias.c (revision 270847) > +++ gcc/tree-ssa-alias.c (working copy) > @@ -2598,8 +2598,8 @@ stmt_kills_ref_p (gimple *stmt, tree ref > case false is returned. The walk starts with VUSE, one argument of PHI. > */ > > static bool > -maybe_skip_until (gimple *phi, tree target, ao_ref *ref, > - tree vuse, unsigned int *cnt, bitmap *visited, > +maybe_skip_until (gimple *phi, tree &target, basic_block target_bb, > + ao_ref *ref, tree vuse, unsigned int *cnt, bitmap *visited, > bool abort_on_visited, > void *(*translate)(ao_ref *, tree, void *, bool *), > void *data) > @@ -2615,6 +2615,19 @@ maybe_skip_until (gimple *phi, tree targ >while (vuse != target) > { >gimple *def_stmt = SSA_NAME_DEF_STMT (vuse); > + /* If we are searching for the target VUSE by walking up to > + TARGET_BB dominating the original PHI we are finished once > + we reach a default def or a definition in a block dominating > + that block. Update TARGET and return. */ > + if (!target > + && (gimple_nop_p (def_stmt) > + || dominated_by_p (CDI_DOMINATORS, > + target_bb, gimple_bb (def_stmt > + { > + target = vuse; > + return true; > + } > + >/* Recurse for PHI nodes. */ >if (gimple_code (def_stmt) == GIMPLE_PHI) > { > @@ -2698,49 +2711,17 @@ get_continuation_for_phi (gimple *phi, a >arg0 = NULL_TREE; > } >/* If not, look if we can reach such candidate by walking defs > - of a PHI arg without crossing other PHIs. */ > - if (! arg0) > -for (i = 0; i < nargs; ++i) > - { > - arg0 = PHI_ARG_DEF (phi, i); > - gimple *def = SSA_NAME_DEF_STMT (arg0); > - /* Backedges can't work. */ > - if (dominated_by_p (CDI_DOMINATORS, > - gimple_bb (def), phi_bb)) > - continue; > - /* See below. */ > - if (gimple_code (def) == GIMPLE_PHI) > - continue; > - while (! dominated_by_p (CDI_DOMINATORS, > - phi_bb, gimple_bb (def))) > - { > - arg0 = gimple_vuse (def); > - if (SSA_NAME_IS_DEFAULT_DEF (arg0)) > - break; > - def = SSA_NAME_DEF_STMT (arg0); > - if (gimple_code (def) == GIMPLE_PHI) > - { > - /* Do not try to look through arbitrarily complicated > -CFGs. For those looking for the first VUSE starting > -from the end of the immediate dominator of phi_bb > -is likely faster. */ > - arg0 = NULL_TREE; > - goto next; > - } > - } > - break; > -next:; > - } > - if (! arg0) > -return NULL_TREE; > + until we hit the immediate dominator. maybe_skip_until will > + do that for us. */ > + basic_block dom = get_immediate_dominator (CDI_DOMINATORS, phi_bb); > > - /* Then check against the found candidate. */ > + /* Then check against the (to be) found candidate. */ >for (i = 0; i < nargs; ++i) > { >arg1 = PHI_ARG_DEF (phi, i); >if (arg1 == arg0) > ; > - else if (! maybe_skip_until (phi, arg0, ref, arg1, cnt,
[arm] PR target/89400 fix thumb1 unaligned access expansion
Armv6 has support for unaligned accesses to memory. However, the thumb1 code patterns were trying to use the 32-bit code constraints. One failure mode from this was that the patterns are designed to be compatible with conditional execution and this was then causing an assert in the compiler. The unaligned_loadhis pattern is only used for expanding extv, which in turn is only enabled for systems supporting thumb2. Given that there is no simple expansion for a thumb1 sign-extending load (the instruction has no immediate offset form and requires two registers in the address) it seems simpler to just disable this for thumb1. Fixed thusly: PR target/89400 * config/arm/arm.md (unaligned_loadsi): Add variant for thumb1. Restrict 'all' variant to 32-bit configurations. (unaligned_loadhiu): Likewise. (unaligned_storehi): Likewise. (unaligned_storesi): Likewise. (unaligned_loadhis): Disable when compiling for thumb1. diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 0aecd03891c..ae582172ab9 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -4483,62 +4483,78 @@ (define_expand "extv_regsi" ; ARMv6+ unaligned load/store instructions (used for packed structure accesses). (define_insn "unaligned_loadsi" - [(set (match_operand:SI 0 "s_register_operand" "=l,r") - (unspec:SI [(match_operand:SI 1 "memory_operand" "Uw,m")] + [(set (match_operand:SI 0 "s_register_operand" "=l,l,r") + (unspec:SI [(match_operand:SI 1 "memory_operand" "m,Uw,m")] UNSPEC_UNALIGNED_LOAD))] "unaligned_access" - "ldr%?\t%0, %1\t@ unaligned" - [(set_attr "arch" "t2,any") - (set_attr "length" "2,4") - (set_attr "predicable" "yes") - (set_attr "predicable_short_it" "yes,no") + "@ + ldr\t%0, %1\t@ unaligned + ldr%?\t%0, %1\t@ unaligned + ldr%?\t%0, %1\t@ unaligned" + [(set_attr "arch" "t1,t2,32") + (set_attr "length" "2,2,4") + (set_attr "predicable" "no,yes,yes") + (set_attr "predicable_short_it" "no,yes,no") (set_attr "type" "load_4")]) +;; The 16-bit Thumb1 variant of ldrsh requires two registers in the +;; address (there's no immediate format). That's tricky to support +;; here and we don't really need this pattern for that case, so only +;; enable for 32-bit ISAs. (define_insn "unaligned_loadhis" [(set (match_operand:SI 0 "s_register_operand" "=r") (sign_extend:SI (unspec:HI [(match_operand:HI 1 "memory_operand" "Uh")] UNSPEC_UNALIGNED_LOAD)))] - "unaligned_access" + "unaligned_access && TARGET_32BIT" "ldrsh%?\t%0, %1\t@ unaligned" [(set_attr "predicable" "yes") (set_attr "type" "load_byte")]) (define_insn "unaligned_loadhiu" - [(set (match_operand:SI 0 "s_register_operand" "=l,r") + [(set (match_operand:SI 0 "s_register_operand" "=l,l,r") (zero_extend:SI - (unspec:HI [(match_operand:HI 1 "memory_operand" "Uw,m")] + (unspec:HI [(match_operand:HI 1 "memory_operand" "m,Uw,m")] UNSPEC_UNALIGNED_LOAD)))] "unaligned_access" - "ldrh%?\t%0, %1\t@ unaligned" - [(set_attr "arch" "t2,any") - (set_attr "length" "2,4") - (set_attr "predicable" "yes") - (set_attr "predicable_short_it" "yes,no") + "@ + ldrh\t%0, %1\t@ unaligned + ldrh%?\t%0, %1\t@ unaligned + ldrh%?\t%0, %1\t@ unaligned" + [(set_attr "arch" "t1,t2,32") + (set_attr "length" "2,2,4") + (set_attr "predicable" "no,yes,yes") + (set_attr "predicable_short_it" "no,yes,no") (set_attr "type" "load_byte")]) (define_insn "unaligned_storesi" - [(set (match_operand:SI 0 "memory_operand" "=Uw,m") - (unspec:SI [(match_operand:SI 1 "s_register_operand" "l,r")] + [(set (match_operand:SI 0 "memory_operand" "=m,Uw,m") + (unspec:SI [(match_operand:SI 1 "s_register_operand" "l,l,r")] UNSPEC_UNALIGNED_STORE))] "unaligned_access" - "str%?\t%1, %0\t@ unaligned" - [(set_attr "arch" "t2,any") - (set_attr "length" "2,4") - (set_attr "predicable" "yes") - (set_attr "predicable_short_it" "yes,no") + "@ + str\t%1, %0\t@ unaligned + str%?\t%1, %0\t@ unaligned + str%?\t%1, %0\t@ unaligned" + [(set_attr "arch" "t1,t2,32") + (set_attr "length" "2,2,4") + (set_attr "predicable" "no,yes,yes") + (set_attr "predicable_short_it" "no,yes,no") (set_attr "type" "store_4")]) (define_insn "unaligned_storehi" - [(set (match_operand:HI 0 "memory_operand" "=Uw,m") - (unspec:HI [(match_operand:HI 1 "s_register_operand" "l,r")] + [(set (match_operand:HI 0 "memory_operand" "=m,Uw,m") + (unspec:HI [(match_operand:HI 1 "s_register_operand" "l,l,r")] UNSPEC_UNALIGNED_STORE))] "unaligned_access" - "strh%?\t%1, %0\t@ unaligned" - [(set_attr "arch" "t2,any") - (set_attr "length" "2,4") - (set_attr "predicable" "yes") - (set_attr "predicable_short_it" "yes,no") + "@ + strh\t%1, %0\t@ unaligned + strh%?\t%1, %0\t@ unaligned + strh%?\t%1, %0\t@ unaligned" + [(set_attr "arch" "t1,t2,32") + (set_attr "length" "2,2,4") + (set_attr "predicable" "no,yes,yes") + (set_attr "pr
Re: [PATCH] PR libstdc++/61761 fix std::proj for targets without C99 cproj
On 03/05/2019 13:08, Jonathan Wakely wrote: > On 03/05/19 11:21 +, Szabolcs Nagy wrote: >> On 03/05/2019 12:16, Jonathan Wakely wrote: >>> Hmm, which file in the source tree does the include/cmath symlink in >>> the build tree point to? >> >> /work/b/build-aarch64-none-elf/obj/gcc2/aarch64-none-elf/libstdc++-v3$ ls -l >> include/cmath >> lrwxrwxrwx 1 szabolcs szabolcs 51 May 1 18:06 include/cmath -> >> /work/b/src/gcc/libstdc++-v3/include/c_global/cmath > > > Oh, I see the problem. and both guard use of > copysign by _GLIBCXX_USE_C99_MATH_TR1 but the test just uses it > unconditionally. > > Does the attached patch work? it fails because copysign takes two arguments, once that is fixed the test compiles. thanks. there is still an execution failure, but that's not related to copysign: proj(i*inf) returns i*inf instead of inf i haven't figured out why: /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:105: void test01(): Assertion 'eq( std::proj(c0p) , std::complex(pinf, +0.0) )' failed. FAIL: 26_numerics/complex/proj.cc execution test
Re: [PATCH] Silent -Wformat-truncation warnings in date_and_time.c.
Martin, With your patch I still see ../../../work/libgfortran/intrinsics/date_and_time.c:168:33: warning: '%03d' directive output may be truncated writing between 3 and 8 bytes into a region of size between 0 and 4 [-Wformat-truncation=] TIA Dominique
Re: [PATCH] Silent -Wformat-truncation warnings in date_and_time.c.
On Fri, May 03, 2019 at 12:53:06PM +0200, Martin Liška wrote: > > The patch is about suppression of the following warning: > > /home/gcc/buildworker/zenith-gcc-trunk-weekly/build/libgfortran/intrinsics/date_and_time.c:165:33: > warning: ‘%04d’ directive output may be truncated writing between 4 and 11 > bytes into a region of size 9 [-Wformat-truncation=] > /home/gcc/buildworker/zenith-gcc-trunk-weekly/build/libgfortran/intrinsics/date_and_time.c:172:33: > warning: ‘%+03d’ directive output may be truncated writing between 3 and 9 > bytes into a region of size 6 [-Wformat-truncation=] > > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? Why are you getting a warning? Is this a wchar issue? The comment in the code for DATE is DATE (optional) shall be scalar and of type default character. It is an INTENT(OUT) argument. It is assigned a value of the form CCYYMMDD, where CC is the century, YY the year within the century, MM the month within the year, and DD the day within the month. If there is no date available, they are assigned blanks. 12345678 CCYYMMDD That is 8 characters, so #define DATE_LEN 8 ... char date[DATE_LEN + 1]; would appear to be correct. The '+ 1' is for the terminating '\0'. Futhermore, 'date' appears as an argument to snprintf() and memset(), where both function will write at most DATE_LEN characters into 'date'. Arbitrarily, increasing the sizes of 'date' and 'zone' to silence a bogus warning seems dubious to me. Remove the -W option if the false positive offends you. -- Steve
[PATCH] simplify_vector_constructor: Rename the second elt to elem
simplify_vector_constructor has constructor_elt *elt; ... FOR_EACH_VEC_SAFE_ELT (CONSTRUCTOR_ELTS (op), i, elt) { ... unsigned int elt; ... } This patch renames the second elt to elem to avoid shadowing the first elt. * tree-ssa-forwprop.c (simplify_vector_constructor): Rename the second elt to elem to avoid shadowing the first elt. --- gcc/tree-ssa-forwprop.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index 7dd1e64335a..ab27a5ddbb1 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -2101,15 +2101,16 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi) if (j == 2) return false; - unsigned int elt; + unsigned int elem; if (maybe_ne (bit_field_size (op1), elem_size) - || !constant_multiple_p (bit_field_offset (op1), elem_size, &elt)) + || !constant_multiple_p (bit_field_offset (op1), elem_size, + &elem)) return false; if (j) - elt += nelts; - if (elt != i) + elem += nelts; + if (elem != i) maybe_ident = false; - sel.quick_push (elt); + sel.quick_push (elem); } else if (CONSTANT_CLASS_P (elt->value)) { -- 2.20.1
Merge from trunk to gccgo branch
I've merged trunk revision 270851 to the gccgo branch. Ian
V6 [PATCH] Optimize vector constructor
On Thu, May 2, 2019 at 10:53 AM H.J. Lu wrote: > > On Thu, May 2, 2019 at 7:55 AM Richard Biener > wrote: > > > > On Thu, May 2, 2019 at 4:54 PM Richard Biener > > wrote: > > > > > > On Mon, Mar 11, 2019 at 8:03 AM H.J. Lu wrote: > > > > > > > > On Fri, Mar 8, 2019 at 7:03 PM Richard Biener > > > > wrote: > > > > > > > > > > On Fri, Mar 8, 2019 at 9:49 AM H.J. Lu wrote: > > > > > > > > > > > > On Thu, Mar 7, 2019 at 9:51 AM H.J. Lu wrote: > > > > > > > > > > > > > > On Wed, Mar 6, 2019 at 8:33 PM Richard Biener > > > > > > > wrote: > > > > > > > > > > > > > > > > On Wed, Mar 6, 2019 at 8:46 AM H.J. Lu > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > On Tue, Mar 5, 2019 at 1:46 AM H.J. Lu > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > On Mon, Mar 04, 2019 at 12:55:04PM +0100, Richard Biener > > > > > > > > > > wrote: > > > > > > > > > > > On Sun, Mar 3, 2019 at 10:13 PM H.J. Lu > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > On Sun, Mar 03, 2019 at 06:40:09AM -0800, Andrew Pinski > > > > > > > > > > > > wrote: > > > > > > > > > > > > > ) > > > > > > > > > > > > > ,On Sun, Mar 3, 2019 at 6:32 AM H.J. Lu > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > For vector init constructor: > > > > > > > > > > > > > > > > > > > > > > > > > > > > --- > > > > > > > > > > > > > > typedef float __v4sf __attribute__ > > > > > > > > > > > > > > ((__vector_size__ (16))); > > > > > > > > > > > > > > > > > > > > > > > > > > > > __v4sf > > > > > > > > > > > > > > foo (__v4sf x, float f) > > > > > > > > > > > > > > { > > > > > > > > > > > > > > __v4sf y = { f, x[1], x[2], x[3] }; > > > > > > > > > > > > > > return y; > > > > > > > > > > > > > > } > > > > > > > > > > > > > > --- > > > > > > > > > > > > > > > > > > > > > > > > > > > > we can optimize vector init constructor with vector > > > > > > > > > > > > > > copy or permute > > > > > > > > > > > > > > followed by a single scalar insert: > > > > > > > > > > > > > > > > > > > > > and you want to advance to the _1 = BIT_INSERT_EXPR here. > > > > > > > > > > > The easiest way > > > > > > > > > > > is to emit a new stmt for _2 = copy ...; and do the > > > > > > > > > > > set_rhs with the > > > > > > > > > > > BIT_INSERT_EXPR. > > > > > > > > > > > > > > > > > > > > Thanks for BIT_INSERT_EXPR suggestion. I am testing this > > > > > > > > > > patch. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > H.J. > > > > > > > > > > --- > > > > > > > > > > We can optimize vector constructor with vector copy or > > > > > > > > > > permute followed > > > > > > > > > > by a single scalar insert: > > > > > > > > > > > > > > > > > > > > __v4sf y; > > > > > > > > > > __v4sf D.1930; > > > > > > > > > > float _1; > > > > > > > > > > float _2; > > > > > > > > > > float _3; > > > > > > > > > > > > > > > > > > > >: > > > > > > > > > > _1 = BIT_FIELD_REF ; > > > > > > > > > > _2 = BIT_FIELD_REF ; > > > > > > > > > > _3 = BIT_FIELD_REF ; > > > > > > > > > > y_6 = {f_5(D), _3, _2, _1}; > > > > > > > > > > return y_6; > > > > > > > > > > > > > > > > > > > > with > > > > > > > > > > > > > > > > > > > > __v4sf y; > > > > > > > > > > __v4sf D.1930; > > > > > > > > > > float _1; > > > > > > > > > > float _2; > > > > > > > > > > float _3; > > > > > > > > > > vector(4) float _8; > > > > > > > > > > > > > > > > > > > >: > > > > > > > > > > _1 = BIT_FIELD_REF ; > > > > > > > > > > _2 = BIT_FIELD_REF ; > > > > > > > > > > _3 = BIT_FIELD_REF ; > > > > > > > > > > _8 = x_9(D); > > > > > > > > > > y_6 = BIT_INSERT_EXPR ; > > > > > > > > > > return y_6; > > > > > > > > > > > > > > > > > > > > gcc/ > > > > > > > > > > > > > > > > > > > > PR tree-optimization/88828 > > > > > > > > > > * tree-ssa-forwprop.c > > > > > > > > > > (simplify_vector_constructor): Optimize > > > > > > > > > > vector init constructor with vector copy or permute > > > > > > > > > > followed > > > > > > > > > > by a single scalar insert. > > > > > > > > > > > > > > > > > > > > gcc/testsuite/ > > > > > > > > > > > > > > > > > > > > PR tree-optimization/88828 > > > > > > > > > > * gcc.target/i386/pr88828-1a.c: New test. > > > > > > > > > > * gcc.target/i386/pr88828-2b.c: Likewise. > > > > > > > > > > * gcc.target/i386/pr88828-2.c: Likewise. > > > > > > > > > > * gcc.target/i386/pr88828-3a.c: Likewise. > > > > > > > > > > * gcc.target/i386/pr88828-3b.c: Likewise. > > > > > > > > > > * gcc.target/i386/pr88828-3c.c: Likewise. > > > > > > > > > > * gcc.target/i386/pr88828-3d.c: Likewise. > > > > > > > > > > * gcc.target/i386/pr88828-4a.c: Likewise. > > > > > > > > > > * gcc.target/i386/pr88828-4b.c: Likewise. > > > > > > > > > > * gcc.target/i386/pr88828-5a.c: Likewise. > > > > > > > > > > * gcc.target/i386/pr88828-5b.c: Likewise. > > > > > > >
Re: [PATCH] Prep for PR88828 fix
On Fri, May 3, 2019 at 6:02 AM Richard Biener wrote: > > > The following refactors simplify_vector_constructor and adds > handling of constants to it in a straight-forward way. > > A followup will handle the testcases posted in HJs patch. > > Bootstrap / regtest running on x86_64-unknown-linux-gnu. > > Richard. > > 2019-05-03 Richard Biener > > PR tree-optimization/88828 > * tree-ssa-forwprop.c (get_bit_field_ref_def): Split out from... > (simplify_vector_constructor): ...here. Handle constants in > the constructor. > > * gcc.target/i386/pr88828-0.c: New testcase. > > Index: gcc/tree-ssa-forwprop.c > === > --- gcc/tree-ssa-forwprop.c (revision 270847) > +++ gcc/tree-ssa-forwprop.c (working copy) > @@ -1997,6 +1997,44 @@ simplify_permutation (gimple_stmt_iterat >return 0; > } > > +/* Get the BIT_FIELD_REF definition of VAL, if any, looking through > + conversions with code CONV_CODE or update it if still ERROR_MARK. > + Return NULL_TREE if no such matching def was found. */ > + > +static tree > +get_bit_field_ref_def (tree val, enum tree_code &conv_code) > +{ > + if (TREE_CODE (val) != SSA_NAME) > +return NULL_TREE ; > + gimple *def_stmt = get_prop_source_stmt (val, false, NULL); > + if (!def_stmt) > +return NULL_TREE; > + enum tree_code code = gimple_assign_rhs_code (def_stmt); > + if (code == FLOAT_EXPR > + || code == FIX_TRUNC_EXPR) > +{ > + tree op1 = gimple_assign_rhs1 (def_stmt); > + if (conv_code == ERROR_MARK) > + { > + if (maybe_ne (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (val))), > + GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op1) > + return NULL_TREE; > + conv_code = code; > + } > + else if (conv_code != code) > + return NULL_TREE; > + if (TREE_CODE (op1) != SSA_NAME) > + return NULL_TREE; > + def_stmt = SSA_NAME_DEF_STMT (op1); > + if (! is_gimple_assign (def_stmt)) > + return NULL_TREE; > + code = gimple_assign_rhs_code (def_stmt); > +} > + if (code != BIT_FIELD_REF) > +return NULL_TREE; > + return gimple_assign_rhs1 (def_stmt); > +} > + > /* Recognize a VEC_PERM_EXPR. Returns true if there were any changes. */ > > static bool > @@ -2027,6 +2065,9 @@ simplify_vector_constructor (gimple_stmt >orig[1] = NULL; >conv_code = ERROR_MARK; >maybe_ident = true; > + tree one_constant = NULL_TREE; > + auto_vec constants; > + constants.safe_grow_cleared (nelts); >FOR_EACH_VEC_SAFE_ELT (CONSTRUCTOR_ELTS (op), i, elt) > { >tree ref, op1; > @@ -2034,68 +2075,55 @@ simplify_vector_constructor (gimple_stmt >if (i >= nelts) > return false; > > - if (TREE_CODE (elt->value) != SSA_NAME) > - return false; > - def_stmt = get_prop_source_stmt (elt->value, false, NULL); > - if (!def_stmt) > - return false; > - code = gimple_assign_rhs_code (def_stmt); > - if (code == FLOAT_EXPR > - || code == FIX_TRUNC_EXPR) > + op1 = get_bit_field_ref_def (elt->value, conv_code); > + if (op1) > { > - op1 = gimple_assign_rhs1 (def_stmt); > - if (conv_code == ERROR_MARK) > + ref = TREE_OPERAND (op1, 0); > + unsigned int j; > + for (j = 0; j < 2; ++j) > { > - if (maybe_ne (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE > (elt->value))), > - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op1) > - return false; > - conv_code = code; > + if (!orig[j]) > + { > + if (TREE_CODE (ref) != SSA_NAME) > + return false; > + if (! VECTOR_TYPE_P (TREE_TYPE (ref)) > + || ! useless_type_conversion_p (TREE_TYPE (op1), > + TREE_TYPE (TREE_TYPE > (ref > + return false; > + if (j && !useless_type_conversion_p (TREE_TYPE (orig[0]), > + TREE_TYPE (ref))) > + return false; > + orig[j] = ref; > + break; > + } > + else if (ref == orig[j]) > + break; > } > - else if (conv_code != code) > + if (j == 2) > return false; > - if (TREE_CODE (op1) != SSA_NAME) > - return false; > - def_stmt = SSA_NAME_DEF_STMT (op1); > - if (! is_gimple_assign (def_stmt)) > + > + unsigned int elt; > + if (maybe_ne (bit_field_size (op1), elem_size) > + || !constant_multiple_p (bit_field_offset (op1), elem_size, > &elt)) > return false; > - code = gimple_assign_rhs_code (def_stmt); > + if (j) > + elt += nelts; > + if (elt != i) > + mayb
libgo patch committed: Disable TestGroupIds on AIX
This patch by Clément Chigot disables the os/user package TestGroupIds test on AIX. Bootstrapped and ran os/user tests on x86_64-pc-linux-gnu. Committed to mainline and GCC 9 branch. Ian Index: gcc/go/gofrontend/MERGE === --- gcc/go/gofrontend/MERGE (revision 270780) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -7e590184ae1ebc02e1b2577de00cf4fe842217dc +208521930c9b5adcfb495799ee01b6aec86c2ccf The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/os/user/user_test.go === --- libgo/go/os/user/user_test.go (revision 270552) +++ libgo/go/os/user/user_test.go (working copy) @@ -129,6 +129,9 @@ func TestLookupGroup(t *testing.T) { func TestGroupIds(t *testing.T) { checkGroup(t) + if runtime.GOOS == "aix" { + t.Skip("skipping GroupIds, see golang.org/issue/30563") + } if runtime.GOOS == "solaris" { t.Skip("skipping GroupIds, see golang.org/issue/14709") }
[PATCH] Avoid -Woverflow warning in __numeric_limits_integer
This is the same fix as was done for std::numeric_limits in r183905. PR libstdc++/52119 * include/ext/numeric_traits.h (__glibcxx_min): Avoid integer overflow warning with -Wpedantic -Wsystem-headers. Tested powerpc64le-linux, committed to trunk. commit 6320e854115f7bb9b3c943ee09c1a6a87deafb74 Author: Jonathan Wakely Date: Thu May 2 23:52:40 2019 +0100 Avoid -Woverflow warning in __numeric_limits_integer This is the same fix as was done for std::numeric_limits in r183905. PR libstdc++/52119 * include/ext/numeric_traits.h (__glibcxx_min): Avoid integer overflow warning with -Wpedantic -Wsystem-headers. diff --git a/libstdc++-v3/include/ext/numeric_traits.h b/libstdc++-v3/include/ext/numeric_traits.h index 67993fdc58e..43ba1c8740a 100644 --- a/libstdc++-v3/include/ext/numeric_traits.h +++ b/libstdc++-v3/include/ext/numeric_traits.h @@ -39,13 +39,13 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) _GLIBCXX_BEGIN_NAMESPACE_VERSION // Compile time constants for builtin types. - // Sadly std::numeric_limits member functions cannot be used for this. + // In C++98 std::numeric_limits member functions cannot be used for this. #define __glibcxx_signed(_Tp) ((_Tp)(-1) < 0) #define __glibcxx_digits(_Tp) \ (sizeof(_Tp) * __CHAR_BIT__ - __glibcxx_signed(_Tp)) #define __glibcxx_min(_Tp) \ - (__glibcxx_signed(_Tp) ? (_Tp)1 << __glibcxx_digits(_Tp) : (_Tp)0) + (__glibcxx_signed(_Tp) ? -__glibcxx_max(_Tp) - 1 : (_Tp)0) #define __glibcxx_max(_Tp) \ (__glibcxx_signed(_Tp) ? \
Re: [PATCH] PR libstdc++/61761 fix std::proj for targets without C99 cproj
On 03/05/19 14:34 +, Szabolcs Nagy wrote: On 03/05/2019 13:08, Jonathan Wakely wrote: On 03/05/19 11:21 +, Szabolcs Nagy wrote: On 03/05/2019 12:16, Jonathan Wakely wrote: Hmm, which file in the source tree does the include/cmath symlink in the build tree point to? /work/b/build-aarch64-none-elf/obj/gcc2/aarch64-none-elf/libstdc++-v3$ ls -l include/cmath lrwxrwxrwx 1 szabolcs szabolcs 51 May 1 18:06 include/cmath -> /work/b/src/gcc/libstdc++-v3/include/c_global/cmath Oh, I see the problem. and both guard use of copysign by _GLIBCXX_USE_C99_MATH_TR1 but the test just uses it unconditionally. Does the attached patch work? it fails because copysign takes two arguments, once that is fixed the test compiles. thanks. Doh! I'll commit the working version (attached). there is still an execution failure, but that's not related to copysign: proj(i*inf) returns i*inf instead of inf i haven't figured out why: /work/b/src/gcc/libstdc++-v3/testsuite/26_numerics/complex/proj.cc:105: void test01(): Assertion 'eq( std::proj(c0p) , std::complex(pinf, +0.0) )' failed. FAIL: 26_numerics/complex/proj.cc execution test If std::copysign isn't avilable then we only provide the generic std::proj which doesn't support infinities, so all the tests using positive or negative infinity will give the wrong answer. The r270759 change doesn't actually use std::copysign, only __builtin_copysign, but if the compiler doesn't expand that then it still requires libc to provide copysign. If autoconf decides copysign isn't available, std::proj doesn't support infinities. I'm not sure whether to XFAIL the test in that case, or just make the tests for infinities conditional on the necessary support in libc e.g. --- a/libstdc++-v3/testsuite/26_numerics/complex/proj.cc +++ b/libstdc++-v3/testsuite/26_numerics/complex/proj.cc @@ -101,6 +101,7 @@ test01() VERIFY( eq( std::proj(cqq) , cqq ) ); VERIFY( eq( std::proj(-cqq) , -cqq ) ); +#ifdef _GLIBCXX_USE_C99_MATH_TR1 const std::complex c0p(0, pinf); VERIFY( eq( std::proj(c0p) , std::complex(pinf, +0.0) ) ); VERIFY( eq( std::proj(-c0p) , std::complex(pinf, -0.0) ) ); @@ -164,6 +165,7 @@ test01() const std::complex cnp(ninf, pinf); VERIFY( eq( std::proj(cnp) , std::complex(pinf, +0.0) ) ); VERIFY( eq( std::proj(-cnp) , std::complex(pinf, -0.0) ) ); +#endif } void @@ -215,6 +217,7 @@ test02() VERIFY( eq( std::proj(cqq) , cqq ) ); VERIFY( eq( std::proj(-cqq) , -cqq ) ); +#ifdef _GLIBCXX_USE_C99_MATH_TR1 const std::complex c0p(0, pinf); VERIFY( eq( std::proj(c0p) , std::complex(pinf, +0.0) ) ); VERIFY( eq( std::proj(-c0p) , std::complex(pinf, -0.0) ) ); @@ -278,6 +281,7 @@ test02() const std::complex cnp(ninf, pinf); VERIFY( eq( std::proj(cnp) , std::complex(pinf, +0.0) ) ); VERIFY( eq( std::proj(-cnp) , std::complex(pinf, -0.0) ) ); +#endif } void @@ -329,6 +333,7 @@ test03() VERIFY( eq( std::proj(cqq) , cqq ) ); VERIFY( eq( std::proj(-cqq) , -cqq ) ); +#ifdef _GLIBCXX_USE_C99_MATH_TR1 const std::complex c0p(0, pinf); VERIFY( eq( std::proj(c0p) , std::complex(pinf, +0.0) ) ); VERIFY( eq( std::proj(-c0p) , std::complex(pinf, -0.0) ) ); @@ -392,6 +397,7 @@ test03() const std::complex cnp(ninf, pinf); VERIFY( eq( std::proj(cnp) , std::complex(pinf, +0.0) ) ); VERIFY( eq( std::proj(-cnp) , std::complex(pinf, -0.0) ) ); +#endif } int commit df733472463b868de2c9938e4ea6073105d07ee9 Author: Jonathan Wakely Date: Fri May 3 20:14:19 2019 +0100 Fix new testcase to not require std::copysign Use __builtin_copysign{,f,l} when std::copysign isn't available. PR libstdc++/61761 * testsuite/26_numerics/complex/proj.cc: Don't assume defines std::copysign. diff --git a/libstdc++-v3/testsuite/26_numerics/complex/proj.cc b/libstdc++-v3/testsuite/26_numerics/complex/proj.cc index b70ca4c58e9..caf12d25103 100644 --- a/libstdc++-v3/testsuite/26_numerics/complex/proj.cc +++ b/libstdc++-v3/testsuite/26_numerics/complex/proj.cc @@ -21,6 +21,22 @@ #include #include +namespace test +{ +#ifdef _GLIBCXX_USE_C99_MATH_TR1 + using std::copysign; +#else + bool copysign(float x, float y) + { return __builtin_copysignf(x, y); } + + bool copysign(double x, double y) + { return __builtin_copysign(x, y); } + + bool copysign(long double x, long double y) + { return __builtin_copysignl(x, y); } +#endif +} + template bool eq(const std::complex& x, const std::complex& y) { @@ -28,9 +44,9 @@ bool eq(const std::complex& x, const std::complex& y) bool nan_imags = std::isnan(x.imag()) && std::isnan(y.imag()); bool sign_reals -= std::copysign(T(1), x.real()) == std::copysign(T(1), y.real()); += test::copysign(T(1), x.real()) == test::copysign(T(1), y.real()); bool sign_imags -= std::copysign(T(1), x.imag()) == std::copysign(T(1), y.imag()); += test::copysign(T(1), x.imag()) == test::copysign(T(1), y.imag()); return ((x.real() == y.real() && sign_r
Re: [PATCH] libphobos: RISC-V: Fix soft-float build errors with IEEE exception flags
On Thu, 2 May 2019, Jim Wilson wrote: > > within inline assembly, to access IEEE exception flags. The use of > > these instructions is not allowed when building for a soft-float ABI. > > Technically it is an architecture issue not an ABI issue. If you > compile for -march=rv32imac -mabi=ilp32 then you can't use FP > instructions. If you compile for -march=rv32imafc -mabi=ilp32 then > you can use FP instructions, but we don't use FP regs for argument > passing. This is similar to the distinction that ARM makes between > the soft and softfp ABIs. The RISC-V newlib port for instance checks > __riscv_flen to decide whether to use FP instructions. The predefined > macro __riscv_flen is set to 0 if the target architecture doesn't have > FP registers. So the choice of using FP instructions depends on the > target architecture, not the target ABI. I found this a useful clarification, thank you! I wasn't aware of the `-march=rv32imafc -mabi=ilp32' hybrid mode. > This is how it works in the C front end. We have __riscv_flen which > can be 0, 4, or 8 and which indicates the hardware FP register size in > bytes. And we have __riscv_float_abi_soft, __riscv_float_abi_single, > and __riscv_float_abi_double, only one of which is defined, which > indicates the max size of arguments that can be passed in FP > registers. FWIW it makes sense to me, and I find the nomenclature somewhat clearer than ARM's `soft' vs `softfp' modes, though I think one still has to refer to documentation to understand the distinction between these variants. Maciej
Go patch committed: Optimize array range clear
This patch to the Go frontend by Cherry Zhang recognizes and optimizes array range clear. It looks for for i := range a { a[i] = zero } for array or slice a, and rewrites it to call memclr, as the gc compiler does. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE === --- gcc/go/gofrontend/MERGE (revision 270857) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -208521930c9b5adcfb495799ee01b6aec86c2ccf +4b3015de639cf22ed11ff96097555700909827c8 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/expressions.cc === --- gcc/go/gofrontend/expressions.cc(revision 270779) +++ gcc/go/gofrontend/expressions.cc(working copy) @@ -1672,6 +1672,10 @@ class Boolean_expression : public Expres { return true; } bool + do_is_zero_value() const + { return this->val_ == false; } + + bool do_is_static_initializer() const { return true; } @@ -2055,6 +2059,10 @@ class Integer_expression : public Expres { return true; } bool + do_is_zero_value() const + { return mpz_sgn(this->val_) == 0; } + + bool do_is_static_initializer() const { return true; } @@ -2475,6 +2483,13 @@ class Float_expression : public Expressi { return true; } bool + do_is_zero_value() const + { +return mpfr_zero_p(this->val_) != 0 + && mpfr_signbit(this->val_) == 0; + } + + bool do_is_static_initializer() const { return true; } @@ -2686,6 +2701,15 @@ class Complex_expression : public Expres { return true; } bool + do_is_zero_value() const + { +return mpfr_zero_p(mpc_realref(this->val_)) != 0 + && mpfr_signbit(mpc_realref(this->val_)) == 0 + && mpfr_zero_p(mpc_imagref(this->val_)) != 0 + && mpfr_signbit(mpc_imagref(this->val_)) == 0; + } + + bool do_is_static_initializer() const { return true; } @@ -2923,6 +2947,10 @@ class Const_expression : public Expressi { return true; } bool + do_is_zero_value() const + { return this->constant_->const_value()->expr()->is_zero_value(); } + + bool do_is_static_initializer() const { return true; } @@ -3290,6 +3318,10 @@ class Nil_expression : public Expression { return true; } bool + do_is_zero_value() const + { return true; } + + bool do_is_static_initializer() const { return true; } @@ -3533,6 +3565,28 @@ Type_conversion_expression::do_is_consta return true; } +// Return whether a type conversion is a zero value. + +bool +Type_conversion_expression::do_is_zero_value() const +{ + if (!this->expr_->is_zero_value()) +return false; + + // Some type conversion from zero value is still not zero value. + // For example, []byte("") or interface{}(0). + // Conservatively, only report true if the RHS is nil. + Type* type = this->type_; + if (type->integer_type() == NULL + && type->float_type() == NULL + && type->complex_type() == NULL + && !type->is_boolean_type() + && !type->is_string_type()) +return this->expr_->is_nil_expression(); + + return true; +} + // Return whether a type conversion can be used in a constant // initializer. @@ -6880,6 +6934,19 @@ String_concat_expression::do_is_constant } bool +String_concat_expression::do_is_zero_value() const +{ + for (Expression_list::const_iterator pe = this->exprs_->begin(); + pe != this->exprs_->end(); + ++pe) +{ + if (!(*pe)->is_zero_value()) + return false; +} + return true; +} + +bool String_concat_expression::do_is_static_initializer() const { for (Expression_list::const_iterator pe = this->exprs_->begin(); @@ -13007,6 +13074,33 @@ Struct_construction_expression::is_const return true; } +// Return whether this is a zero value. + +bool +Struct_construction_expression::do_is_zero_value() const +{ + if (this->vals() == NULL) +return true; + for (Expression_list::const_iterator pv = this->vals()->begin(); + pv != this->vals()->end(); + ++pv) +if (*pv != NULL && !(*pv)->is_zero_value()) + return false; + + const Struct_field_list* fields = this->type_->struct_type()->fields(); + for (Struct_field_list::const_iterator pf = fields->begin(); + pf != fields->end(); + ++pf) +{ + // Interface conversion may cause a zero value being converted + // to a non-zero value, like interface{}(0). Be conservative. + if (pf->type()->interface_type() != NULL) +return false; +} + + return true; +} + // Return whether this struct can be used as a constant initializer. bool @@ -13288,6 +13382,28 @@ Array_construction_expression::is_consta return true; } +// Return whether this is a zero value. + +bool +Array_construction_expression::do_is_zero_value() const +{ +
Re: [PATCH] libphobos: RISC-V: Fix soft-float build errors with IEEE exception flags
On Fri, 3 May 2019, Maciej W. Rozycki wrote: > > Technically it is an architecture issue not an ABI issue. If you > > compile for -march=rv32imac -mabi=ilp32 then you can't use FP > > instructions. If you compile for -march=rv32imafc -mabi=ilp32 then > > you can use FP instructions, but we don't use FP regs for argument > > passing. This is similar to the distinction that ARM makes between > > the soft and softfp ABIs. The RISC-V newlib port for instance checks > > __riscv_flen to decide whether to use FP instructions. The predefined > > macro __riscv_flen is set to 0 if the target architecture doesn't have > > FP registers. So the choice of using FP instructions depends on the > > target architecture, not the target ABI. > > I found this a useful clarification, thank you! I wasn't aware of the > `-march=rv32imafc -mabi=ilp32' hybrid mode. Hmm, I've been thinking a little bit about this hybrid mode and I have one question: how do we pass the IEEE rounding mode setting between `fcsr' and softfp where we have `-march=rv32imafc -mabi=ilp32' and `-march=rv32imac -mabi=ilp32' object modules interlinked? Maciej
Re: [v3 PATCH] Make stateful allocator propagation more consistent for operator+(basic_string) (P1165R1)
On 02/05/19 17:54 +0100, Nina Dinka Ranns wrote: Tested on Linux x86_64 Make stateful allocator propagation more consistent for operator+(basic_string) (P1165R1) 2019-05-01 Nina Dinka Ranns Make stateful allocator propagation more consistent for operator+(basic_string) (P1165R1) * include/bits/basic_string.tcc: (operator+(const _CharT*, const basic_string&)) : Changed resulting allocator to be SOCCC on the second parameter's allocator (operator+(_CharT, const basic_string&)) : Likewise The next change is in include/bits/basic_string.h but that file isn't named here: (operator+(basic_string&&,basic_string&&) : Changed resulting allocator to always be the one from the first parameter * testsuite/21_strings/basic_string/allocator/char/operator_plus.cc: New * testsuite/21_strings/basic_string/allocator/wchar_t/operator_plus.cc : New Index: libstdc++-v3/include/bits/basic_string.h === --- libstdc++-v3/include/bits/basic_string.h(revision 270655) +++ libstdc++-v3/include/bits/basic_string.h(working copy) @@ -6096,13 +6096,7 @@ inline basic_string<_CharT, _Traits, _Alloc> operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, basic_string<_CharT, _Traits, _Alloc>&& __rhs) -{ - const auto __size = __lhs.size() + __rhs.size(); - const bool __cond = (__size > __lhs.capacity() - && __size <= __rhs.capacity()); - return __cond ? std::move(__rhs.insert(0, __lhs)) - : std::move(__lhs.append(__rhs)); -} +{ return std::move(__lhs.append(__rhs)); } I know we already discussed this off-list and said just using the LHS is correct here, even if though it means losing the optimization, but something occured to me today. If the allocator traits say is_always_equal is true, or if the two allocators happen to be equal, then we could still do this optimization to use the RHS string if doing so will avoid a reallocation. So something like this (untested): { using _Alloc_traits = allocator_traits<_Alloc>; bool __use_rhs = false; if _GLIBCXX17_CONSTEXPR (_Alloc_traits::is_always_equal()) __use_rhs = true; else if (__lhs.get_allocator() == __rhs.get_allocator()) __use_rhs = true; if (__use_rhs) { const auto __size = __lhs.size() + __rhs.size(); if (__size > __lhs.capacity() && __size <= __rhs.capacity()) return std::move(__rhs.insert(0, __lhs)); } return std::move(__lhs.append(__rhs)); } I believe that should pass all your existing tests, because it will only use the RHS string when the allocators are equal, and so you can't detect whether the allocator from the LHS or RHS was used. Otherwise the patch looks good.
Re: Mention -std=c2x in GCC 9 release notes
On Thu, 2 May 2019, Joseph Myers wrote: > This patch adds a mention of -std=c2x and associated options, and the > single new C2X feature supported (given the early stage of C2X > development when we left development stage 1), to the GCC 9 release > notes. Nice! Thanks for doing this in time for the release. Gerald