gcc.git
4 years agosra: Avoid SRAing if there is an aout-of-bounds access (PR 96820)
Martin Jambor [Thu, 3 Sep 2020 20:43:49 +0000 (22:43 +0200)]
sra: Avoid SRAing if there is an aout-of-bounds access (PR 96820)

The testcase causes and ICE in the SRA verifier on x86_64 when
compiling with -m32 because build_user_friendly_ref_for_offset looks
at an out-of-bounds array_ref within an array_ref which accesses an
offset which does not fit into a signed 32bit integer and turns it
into an array-ref with a negative index.

The best thing is probably to bail out early when encountering an out
of bounds access to a local stack-allocated aggregate (and let the DSE
just delete such statements) which is what the patch does.

I also glanced over to the initial candidate vetting routine to make
sure the size would fit into HWI and noticed that it uses unsigned
variants whereas the rest of SRA operates on signed offsets and
sizes (because get_ref_and_extent does) and so changed that for the
sake of consistency.  These ancient checks operate on sizes of types
as opposed to DECLs but I hope that any issues potentially arising
from that are basically hypothetical.

gcc/ChangeLog:

2020-08-28  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/96820
* tree-sra.c (create_access): Disqualify candidates with accesses
beyond the end of the original aggregate.
(maybe_add_sra_candidate): Check that candidate type size fits
signed uhwi for the sake of consistency.

gcc/testsuite/ChangeLog:

2020-08-28  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/96820
* gcc.dg/tree-ssa/pr96820.c: New test.

4 years ago[PATCH, rs6000] Fix vector long long subtype (PR96139)
Will Schmidt [Mon, 20 Jul 2020 15:51:37 +0000 (10:51 -0500)]
[PATCH, rs6000] Fix vector long long subtype (PR96139)

Hi,
  This corrects an issue with the powerpc vector long long subtypes.
As reported by SjMunroe, when building some code with -Wall, and
attempting to print an element of a "long long vector" with a
long long printf format string, we will report an error because
the vector sub-type was improperly defined as int.

When defining a V2DI_type_node we use a TARGET_POWERPC64 ternary to
define the V2DI_type_node with "vector long" or "vector long long".
We also need to specify the proper sub-type when we define the type.

PR target/96139

2020-09-03  Will Schmidt  <will_schmidt@vnet.ibm.com>

gcc/ChangeLog:
* config/rs6000/rs6000-call.c (rs6000_init_builtin): Update V2DI_type_node
and unsigned_V2DI_type_node definitions.

gcc/testsuite/ChangeLog:
* gcc.target/powerpc/pr96139-a.c: New test.
* gcc.target/powerpc/pr96139-b.c: New test.
* gcc.target/powerpc/pr96139-c.c: New test.

4 years agoc++: Fix another PCH hash_map issue [PR96901]
Jakub Jelinek [Thu, 3 Sep 2020 19:53:40 +0000 (21:53 +0200)]
c++: Fix another PCH hash_map issue [PR96901]

The recent libstdc++ changes caused lots of libstdc++-v3 tests FAILs
on i686-linux, all of them in the same spot during constexpr evaluation
of a recursive _S_gcd call.
The problem is yet another hash_map that used the default hasing of
tree keys through pointer hashing which is preserved across PCH write/read.
During PCH handling, the addresses of GC objects are changed, which means
that the hash values of the keys in such hash tables change without those
hash tables being rehashed.  Which in the fundef_copies_table case usually
means we just don't find a copy of a FUNCTION_DECL body for recursive uses
and start from scratch.  But when the hash table keeps growing, the "dead"
elements in the hash table can sometimes reappear and break things.
In particular what I saw under the debugger is when the fundef_copies_table
hash map has been used on the outer _S_gcd call, it didn't find an entry for
it, so returned a slot with *slot == NULL, which is treated as that the
function itself is used directly (i.e. no recursion), but that addition of
a hash table slot caused the recursive _S_gcd call to actually find
something in the hash table, unfortunately not the new *slot == NULL spot,
but a different one from the pre-PCH streaming which contained the returned
toplevel (non-recursive) call entry for it, which means that for the
recursive _S_gcd call we actually used the same trees as for the outer ones
rather than a copy of those, which breaks constexpr evaluation.

2020-09-03  Jakub Jelinek  <jakub@redhat.com>

PR c++/96901
* tree.h (struct decl_tree_traits): New type.
(decl_tree_map): New typedef.

* constexpr.c (fundef_copies_table): Change type from
hash_map<tree, tree> * to decl_tree_map *.

4 years agoPR fortran/96890 - Wrong answer with intrinsic IALL
Harald Anlauf [Thu, 3 Sep 2020 18:33:14 +0000 (20:33 +0200)]
PR fortran/96890 - Wrong answer with intrinsic IALL

The IALL intrinsic would always return 0 when the DIM and MASK arguments
were present since the initial value of repeated BIT-AND operations was
set to 0 instead of -1.

libgfortran/ChangeLog:

* m4/iall.m4: Initial value for result should be -1.
* generated/iall_i1.c (miall_i1): Generated.
* generated/iall_i16.c (miall_i16): Likewise.
* generated/iall_i2.c (miall_i2): Likewise.
* generated/iall_i4.c (miall_i4): Likewise.
* generated/iall_i8.c (miall_i8): Likewise.

gcc/testsuite/ChangeLog:

* gfortran.dg/iall_masked.f90: New test.

4 years agoc++: Fix P0960 in member init list and array [PR92812]
Marek Polacek [Wed, 26 Aug 2020 12:27:33 +0000 (08:27 -0400)]
c++: Fix P0960 in member init list and array [PR92812]

This patch nails down the remaining P0960 case in PR92812:

  struct A {
    int ar[2];
    A(): ar(1, 2) {} // doesn't work without this patch
  };

Note that when the target object is not of array type, this already
works:

  struct S { int x, y; };
  struct A {
    S s;
    A(): s(1, 2) { } // OK in C++20
  };

because build_new_method_call_1 takes care of the P0960 magic.

It proved to be quite hairy.  When the ()-list has more than one
element, we can always create a CONSTRUCTOR, because the code was
previously invalid.  But when the ()-list has just one element, it
gets all kinds of difficult.  As usual, we have to handle a("foo")
so as not to wrap the STRING_CST in a CONSTRUCTOR.  Always turning
x(e) into x{e} would run into trouble as in c++/93790.  Another
issue was what to do about x({e}): previously, this would trigger
"list-initializer for non-class type must not be parenthesized".
I figured I'd make this work in C++20, so that given

  struct S { int x, y; };

you can do

   S a[2];
   [...]
   A(): a({1, 2}) // initialize a[0] with {1, 2} and a[1] with {}

It also turned out that, as an extension, we support compound literals:

  F (): m((S[1]) { 1, 2 })

so this has to keep working as before.  Moreover, make sure not to trigger
in compiler-generated code, like =default, where array assignment is allowed.

I've factored out a function that turns a TREE_LIST into a CONSTRUCTOR
to simplify handling of P0960.

paren-init35.C also tests this with vector types.

gcc/cp/ChangeLog:

PR c++/92812
* cp-tree.h (do_aggregate_paren_init): Declare.
* decl.c (do_aggregate_paren_init): New.
(grok_reference_init): Use it.
(check_initializer): Likewise.
* init.c (perform_member_init): Handle initializing an array from
a ()-list.  Use do_aggregate_paren_init.

gcc/testsuite/ChangeLog:

PR c++/92812
* g++.dg/cpp0x/constexpr-array23.C: Adjust dg-error.
* g++.dg/cpp0x/initlist69.C: Likewise.
* g++.dg/diagnostic/mem-init1.C: Likewise.
* g++.dg/init/array28.C: Likewise.
* g++.dg/cpp2a/paren-init33.C: New test.
* g++.dg/cpp2a/paren-init34.C: New test.
* g++.dg/cpp2a/paren-init35.C: New test.
* g++.old-deja/g++.brendan/crash60.C: Adjust dg-error.
* g++.old-deja/g++.law/init10.C: Likewise.
* g++.old-deja/g++.other/array3.C: Likewise.

4 years agoc++: Disable -frounding-math during manifestly constant evaluation [PR96862]
Jakub Jelinek [Thu, 3 Sep 2020 18:11:43 +0000 (20:11 +0200)]
c++: Disable -frounding-math during manifestly constant evaluation [PR96862]

As discussed in the PR, fold-const.c punts on floating point constant
evaluation if the result is inexact and -frounding-math is turned on.
      /* Don't constant fold this floating point operation if the
         result may dependent upon the run-time rounding mode and
         flag_rounding_math is set, or if GCC's software emulation
         is unable to accurately represent the result.  */
      if ((flag_rounding_math
           || (MODE_COMPOSITE_P (mode) && !flag_unsafe_math_optimizations))
          && (inexact || !real_identical (&result, &value)))
        return NULL_TREE;
Jonathan said that we should be evaluating them anyway, e.g. conceptually
as if they are done with the default rounding mode before user had a chance
to change that, and e.g. in C in initializers it is also ignored.
In fact, fold-const.c for C initializers turns off various other options:

/* Perform constant folding and related simplification of initializer
   expression EXPR.  These behave identically to "fold_buildN" but ignore
   potential run-time traps and exceptions that fold must preserve.  */

  int saved_signaling_nans = flag_signaling_nans;\
  int saved_trapping_math = flag_trapping_math;\
  int saved_rounding_math = flag_rounding_math;\
  int saved_trapv = flag_trapv;\
  int saved_folding_initializer = folding_initializer;\
  flag_signaling_nans = 0;\
  flag_trapping_math = 0;\
  flag_rounding_math = 0;\
  flag_trapv = 0;\
  folding_initializer = 1;

  flag_signaling_nans = saved_signaling_nans;\
  flag_trapping_math = saved_trapping_math;\
  flag_rounding_math = saved_rounding_math;\
  flag_trapv = saved_trapv;\
  folding_initializer = saved_folding_initializer;

So, shall cxx_eval_outermost_constant_expr instead turn off all those
options (then warning_sentinel wouldn't be the right thing to use, but given
the 8 or how many return stmts in cxx_eval_outermost_constant_expr, we'd
need a RAII class for this.  Not sure about the folding_initializer, that
one is affecting complex multiplication and division constant evaluation
somehow.

2020-09-03  Jakub Jelinek  <jakub@redhat.com>

PR c++/96862
* constexpr.c (cxx_eval_outermost_constant_expr): Temporarily disable
flag_rounding_math during manifestly constant evaluation.

* g++.dg/cpp1z/constexpr-96862.C: New test.

4 years agolibstdc++: Add workaround for weird std::tuple error [PR 96592]
Jonathan Wakely [Thu, 3 Sep 2020 15:26:16 +0000 (16:26 +0100)]
libstdc++: Add workaround for weird std::tuple error [PR 96592]

This "fix" makes no sense, but it avoids an error from G++ about
std::is_constructible being incomplete. The real problem is elsewhere,
but this "fixes" the regression for now.

libstdc++-v3/ChangeLog:

PR libstdc++/96592
* include/std/tuple (_TupleConstraints<true, T...>): Use
alternative is_constructible instead of std::is_constructible.
* testsuite/20_util/tuple/cons/96592.cc: New test.

4 years agolibstdc++: Optimise GCD algorithms
Jonathan Wakely [Thu, 3 Sep 2020 11:38:50 +0000 (12:38 +0100)]
libstdc++: Optimise GCD algorithms

The current std::gcd and std::chrono::duration::_S_gcd algorithms are
both recursive. This is potentially expensive to evaluate in constant
expressions, because each level of recursion makes a new copy of the
function to evaluate. The maximum number of steps is bounded
(proportional to the number of decimal digits in the smaller value) and
so unlikely to exceed the limit for constexpr nesting, but the memory
usage is still suboptimal. By using an iterative algorithm we avoid
that compile-time cost. Because looping in constexpr functions is not
allowed until C++14, we need to keep the recursive implementation in
duration::_S_gcd for C++11 mode.

For std::gcd we can also optimise runtime performance by using the
binary GCD algorithm.

libstdc++-v3/ChangeLog:

* include/std/chrono (duration::_S_gcd): Use iterative algorithm
for C++14 and later.
* include/std/numeric (__detail::__gcd): Replace recursive
Euclidean algorithm with iterative version of binary GCD algorithm.
* testsuite/26_numerics/gcd/1.cc: Test additional inputs.
* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error lines.
* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
* testsuite/experimental/numeric/gcd.cc: Test additional inputs.
* testsuite/26_numerics/gcd/2.cc: New test.

4 years agolto: Cache location_ts including BLOCKs in GIMPLE streaming [PR94311]
Jakub Jelinek [Thu, 3 Sep 2020 10:51:01 +0000 (12:51 +0200)]
lto: Cache location_ts including BLOCKs in GIMPLE streaming [PR94311]

As mentioned in the PR, when compiling valgrind even on fairly small
testcase where in one larger function the location keeps oscillating
between a small line number and 8000-ish line number in the same file
we very quickly run out of all possible location_t numbers and because of
that emit non-sensical line numbers in .debug_line.
There are ways how to decrease speed of depleting location_t numbers
in libcpp, but the main reason of this is that we use
stream_input_location_now for streaming in location_t for gimple_location
and phi arg locations.  libcpp strongly prefers that the locations
it is given are sorted by the different files and by line numbers in
ascending order, otherwise it depletes quickly no matter what and is much
more costly (many extra file changes etc.).
The reason for not caching those were the BLOCKs that were streamed
immediately after the location and encoded into the locations (and for PHIs
we failed to stream the BLOCKs altogether).
This patch enhances the location cache to handle also BLOCKs (but not for
everything, only for the spots we care about the BLOCKs) and also optimizes
the size of the LTO stream by emitting a single bit into a pack whether the
BLOCK changed from last case and only streaming the BLOCK tree if it
changed.

2020-09-03  Jakub Jelinek  <jakub@redhat.com>

PR lto/94311
* gimple.h (gimple_location_ptr, gimple_phi_arg_location_ptr): New
functions.
* streamer-hooks.h (struct streamer_hooks): Add
output_location_and_block callback.  Fix up formatting for
output_location.
(stream_output_location_and_block): Define.
* lto-streamer.h (class lto_location_cache): Fix comment typo.  Add
current_block member.
(lto_location_cache::input_location_and_block): New method.
(lto_location_cache::lto_location_cache): Initialize current_block.
(lto_location_cache::cached_location): Add block member.
(struct output_block): Add current_block member.
(lto_output_location): Formatting fix.
(lto_output_location_and_block): Declare.
* lto-streamer.c (lto_streamer_hooks_init): Initialize
streamer_hooks.output_location_and_block.
* lto-streamer-in.c (lto_location_cache::cmp_loc): Also compare
block members.
(lto_location_cache::apply_location_cache): Handle blocks.
(lto_location_cache::accept_location_cache,
lto_location_cache::revert_location_cache): Fix up function comments.
(lto_location_cache::input_location_and_block): New method.
(lto_location_cache::input_location): Implement using
input_location_and_block.
(input_function): Invoke apply_location_cache after streaming in all
bbs.
* lto-streamer-out.c (clear_line_info): Set current_block.
(lto_output_location_1): New function, moved from lto_output_location,
added block handling.
(lto_output_location): Implement using lto_output_location_1.
(lto_output_location_and_block): New function.
* gimple-streamer-in.c (input_phi): Use input_location_and_block
to input and cache both location and block.
(input_gimple_stmt): Likewise.
* gimple-streamer-out.c (output_phi): Use
stream_output_location_and_block.
(output_gimple_stmt): Likewise.

4 years agoImprove constant folding of vector lowering with vector bools
Richard Biener [Thu, 3 Sep 2020 10:44:40 +0000 (12:44 +0200)]
Improve constant folding of vector lowering with vector bools

This improves the situation somewhat when vector lowering tries
to access vector bools as seen in PR96814.

2020-09-03  Richard Biener  <rguenther@suse.de>

* tree-vect-generic.c (tree_vec_extract): Remove odd
special-casing of boolean vectors.
* fold-const.c (fold_ternary_loc): Handle boolean vector
type BIT_FIELD_REFs.

4 years agoPreliminary work on support for 128bits integers
Arnaud Charlet [Thu, 3 Sep 2020 08:34:48 +0000 (04:34 -0400)]
Preliminary work on support for 128bits integers

* fe.h, opt.ads (Enable_128bit_Types): New.
* stand.ads (Standard_Long_Long_Long_Integer,
S_Long_Long_Long_Integer): New.

4 years agoLook at fullest view when checking for static types in unnesting
Arnaud Charlet [Thu, 3 Sep 2020 07:38:40 +0000 (03:38 -0400)]
Look at fullest view when checking for static types in unnesting

When seeing if any bound involved in a type is an uplevel reference,
we must look at the fullest view of a type, since that's what the
backends will do.  Similarly for private types. We introduce
Get_Fullest_View for that purpose.

* sem_util.ads, sem_util.adb (Get_Fullest_View): New procedure.
* exp_unst.adb (Check Static_Type): Do all processing on fullest
view of specified type.

4 years agoOptimize memory broadcast for constant vector under AVX512.
liuhongt [Wed, 8 Jul 2020 09:14:36 +0000 (17:14 +0800)]
Optimize memory broadcast for constant vector under AVX512.

For constant vector having one duplicated value, there's no need to put
whole vector in the constant pool, using embedded broadcast instead.

2020-07-09  Hongtao Liu  <hongtao.liu@intel.com>

gcc/ChangeLog:

PR target/87767
* config/i386/i386-features.c
(replace_constant_pool_with_broadcast): New function.
(constant_pool_broadcast): Ditto.
(class pass_constant_pool_broadcast): New pass.
(make_pass_constant_pool_broadcast): Ditto.
(remove_partial_avx_dependency): Call
replace_constant_pool_with_broadcast under TARGET_AVX512F, it
would save compile time when both pass rpad and cpb are
available.
(remove_partial_avx_dependency_gate): New function.
(class pass_remove_partial_avx_dependency::gate): Call
remove_partial_avx_dependency_gate.
* config/i386/i386-passes.def: Insert new pass after combine.
* config/i386/i386-protos.h
(make_pass_constant_pool_broadcast): Declare.
* config/i386/sse.md (*avx512dq_mul<mode>3<mask_name>_bcst):
New define_insn.
(*avx512f_mul<mode>3<mask_name>_bcst): Ditto.
* config/i386/avx512fintrin.h (_mm512_set1_ps,
_mm512_set1_pd,_mm512_set1_epi32, _mm512_set1_epi64): Adjusted.

gcc/testsuite/ChangeLog:

PR target/87767
* gcc.target/i386/avx2-broadcast-pr87767-1.c: New test.
* gcc.target/i386/avx512f-broadcast-pr87767-1.c: New test.
* gcc.target/i386/avx512f-broadcast-pr87767-2.c: New test.
* gcc.target/i386/avx512f-broadcast-pr87767-3.c: New test.
* gcc.target/i386/avx512f-broadcast-pr87767-4.c: New test.
* gcc.target/i386/avx512f-broadcast-pr87767-5.c: New test.
* gcc.target/i386/avx512f-broadcast-pr87767-6.c: New test.
* gcc.target/i386/avx512f-broadcast-pr87767-7.c: New test.
* gcc.target/i386/avx512vl-broadcast-pr87767-1.c: New test.
* gcc.target/i386/avx512vl-broadcast-pr87767-1.c: New test.
* gcc.target/i386/avx512vl-broadcast-pr87767-2.c: New test.
* gcc.target/i386/avx512vl-broadcast-pr87767-3.c: New test.
* gcc.target/i386/avx512vl-broadcast-pr87767-4.c: New test.
* gcc.target/i386/avx512vl-broadcast-pr87767-5.c: New test.
* gcc.target/i386/avx512vl-broadcast-pr87767-6.c: New test.

4 years agoAdjust testcase.
liuhongt [Mon, 31 Aug 2020 02:54:13 +0000 (10:54 +0800)]
Adjust testcase.

gcc/testsuite/ChangeLog:
PR target/96246
PR target/96855
PR target/96856
PR target/96857
* g++.target/i386/avx512bw-pr96246-2.C: Add runtime check for
AVX512BW.
* g++.target/i386/avx512vl-pr96246-2.C: Add runtime check for
AVX512BW and AVX512VL
* g++.target/i386/avx512f-helper.h: New header.
* gcc.target/i386/pr92658-avx512f.c: Add
-mprefer-vector-width=512 to avoid impact of different default
mtune which gcc is built with.
* gcc.target/i386/avx512bw-pr95488-1.c: Ditto.
* gcc.target/i386/pr92645-4.c: Add -mno-avx512f to avoid
impact of different default march which gcc is built with.

4 years agoDaily bump.
GCC Administrator [Thu, 3 Sep 2020 00:16:26 +0000 (00:16 +0000)]
Daily bump.

4 years agod: __vectors unsupported in hardware should be rejected at compile-time.
Iain Buclaw [Mon, 31 Aug 2020 20:42:10 +0000 (22:42 +0200)]
d: __vectors unsupported in hardware should be rejected at compile-time.

gcc/d/ChangeLog:

PR d/96869
* d-builtins.cc (build_frontend_type): Don't expose intrinsics that
use unsupported vector types.
* d-target.cc (Target::isVectorTypeSupported): Restrict to supporting
only if TARGET_VECTOR_MODE_SUPPORTED_P is true.  Don't allow complex
or boolean vector types.

gcc/testsuite/ChangeLog:

PR d/96869
* gdc.dg/simd.d: Removed.
* gdc.dg/cast1.d: New test.
* gdc.dg/gdc213.d: Compile with target vect_sizes_16B_8B.
* gdc.dg/gdc284.d: Likewise.
* gdc.dg/gdc67.d: Likewise.
* gdc.dg/pr96869.d: New test.
* gdc.dg/simd1.d: New test.
* gdc.dg/simd10447.d: New test.
* gdc.dg/simd12776.d: New test.
* gdc.dg/simd13841.d: New test.
* gdc.dg/simd13927.d: New test.
* gdc.dg/simd15123.d: New test.
* gdc.dg/simd15144.d: New test.
* gdc.dg/simd16087.d: New test.
* gdc.dg/simd16697.d: New test.
* gdc.dg/simd17237.d: New test.
* gdc.dg/simd17695.d: New test.
* gdc.dg/simd17720a.d: New test.
* gdc.dg/simd17720b.d: New test.
* gdc.dg/simd19224.d: New test.
* gdc.dg/simd19627.d: New test.
* gdc.dg/simd19628.d: New test.
* gdc.dg/simd19629.d: New test.
* gdc.dg/simd19630.d: New test.
* gdc.dg/simd2a.d: New test.
* gdc.dg/simd2b.d: New test.
* gdc.dg/simd2c.d: New test.
* gdc.dg/simd2d.d: New test.
* gdc.dg/simd2e.d: New test.
* gdc.dg/simd2f.d: New test.
* gdc.dg/simd2g.d: New test.
* gdc.dg/simd2h.d: New test.
* gdc.dg/simd2i.d: New test.
* gdc.dg/simd2j.d: New test.
* gdc.dg/simd7951.d: New test.
* gdc.dg/torture/array2.d: New test.
* gdc.dg/torture/array3.d: New test.
* gdc.dg/torture/simd16488a.d: New test.
* gdc.dg/torture/simd16488b.d: New test.
* gdc.dg/torture/simd16703.d: New test.
* gdc.dg/torture/simd19223.d: New test.
* gdc.dg/torture/simd19607.d: New test.
* gdc.dg/torture/simd3.d: New test.
* gdc.dg/torture/simd4.d: New test.
* gdc.dg/torture/simd7411.d: New test.
* gdc.dg/torture/simd7413a.d: New test.
* gdc.dg/torture/simd7413b.d: New test.
* gdc.dg/torture/simd7414.d: New test.
* gdc.dg/torture/simd9200.d: New test.
* gdc.dg/torture/simd9304.d: New test.
* gdc.dg/torture/simd9449.d: New test.
* gdc.dg/torture/simd9910.d: New test.

4 years agod: Only test with default permutation flags for runnable tests.
Iain Buclaw [Mon, 31 Aug 2020 17:27:15 +0000 (19:27 +0200)]
d: Only test with default permutation flags for runnable tests.

Unless the test explicitly requests, all compilable tests as well as
fail_compilation tests will be ran without any extra flags.

The C++ tests now are checked against shared D runtime library.

gcc/testsuite/ChangeLog:

* lib/gdc-utils.exp (gdc-convert-test): Handle LINK directive.
Set PERMUTE_ARGS as DEFAULT_DFLAGS only for runnable tests.
(gdc-do-test): Set default action of compilable tests to compile.
Test SHARED_OPTION on runnable_cxx tests.

4 years agod: Move all runnable tests in gdc.dg to gdc.dg/torture
Iain Buclaw [Mon, 31 Aug 2020 16:23:12 +0000 (18:23 +0200)]
d: Move all runnable tests in gdc.dg to gdc.dg/torture

Tests that are not executed do not need to be compiled as torture tests,
they are only present for testing for a certain bug or ICE.

gcc/testsuite/ChangeLog:

* gdc.dg/dg.exp: Remove torture options.
* gdc.dg/gdc115.d: Move test to gdc.dg/torture.
* gdc.dg/gdc131.d: Likewise.
* gdc.dg/gdc141.d: Likewise.
* gdc.dg/gdc17.d: Likewise.
* gdc.dg/gdc171.d: Likewise.
* gdc.dg/gdc179.d: Likewise.
* gdc.dg/gdc186.d: Likewise.
* gdc.dg/gdc187.d: Likewise.
* gdc.dg/gdc191.d: Likewise.
* gdc.dg/gdc198.d: Likewise.
* gdc.dg/gdc200.d: Likewise.
* gdc.dg/gdc210.d: Likewise.
* gdc.dg/gdc240.d: Likewise.
* gdc.dg/gdc242b.d: Likewise.
* gdc.dg/gdc248.d: Likewise.
* gdc.dg/gdc250.d: Likewise.
* gdc.dg/gdc273.d: Likewise.
* gdc.dg/gdc283.d: Likewise.
* gdc.dg/gdc285.d: Likewise.
* gdc.dg/gdc286.d: Likewise.
* gdc.dg/gdc309.d: Likewise.
* gdc.dg/gdc35.d: Likewise.
* gdc.dg/gdc36.d: Likewise.
* gdc.dg/gdc51.d: Likewise.
* gdc.dg/gdc57.d: Likewise.
* gdc.dg/gdc66.d: Likewise.
* gdc.dg/imports/gdc36.d: Likewise.
* gdc.dg/init1.d: Likewise.
* gdc.dg/pr92309.d: Likewise.
* gdc.dg/pr94424.d: Likewise.
* gdc.dg/pr94777b.d: Likewise.
* gdc.dg/pr96152.d: Likewise.
* gdc.dg/pr96153.d: Likewise.
* gdc.dg/pr96156.d: Likewise.
* gdc.dg/pr96157a.d: Likewise.
* gdc.dg/torture/torture.exp: New file.

4 years agoc++: Stop defining true, false and bool as macros in <stdbool.h>
Jonathan Wakely [Wed, 2 Sep 2020 17:51:28 +0000 (18:51 +0100)]
c++: Stop defining true, false and bool as macros in <stdbool.h>

Since r216679 these macros have only been defined in C++98 mode, rather
than all modes. That is permitted as a GNU extension because that header
doesn't exist in the C++ standard until C++11, so we can make it do
whatever we want for C++98. But as discussed in the PR c++/60304
comments, these macros shouldn't ever be defined for C++.

This patch removes the macro definitions for C++98 too.

The new test already passed for C++98 (and the conversion is ill-formed
in C++11 and later) so this new test is arguably unnecessary.

gcc/ChangeLog:

PR c++/60304
* ginclude/stdbool.h (bool, false, true): Never define for C++.

gcc/testsuite/ChangeLog:

PR c++/60304
* g++.dg/warn/Wconversion-null-5.C: New test.

4 years agotestsuite: Add missing <exception> header to testcase
Jonathan Wakely [Wed, 2 Sep 2020 17:37:17 +0000 (18:37 +0100)]
testsuite: Add missing <exception> header to testcase

This test no longer compiles because <new> stopped including
<exception>, so std::set_terminate is not defined.

gcc/testsuite/ChangeLog:

* g++.old-deja/g++.abi/cxa_vec.C: Include <exception> for
std::set_terminate.

4 years agolibstdc++: Fix test to use correct function
Jonathan Wakely [Wed, 2 Sep 2020 16:20:37 +0000 (17:20 +0100)]
libstdc++: Fix test to use correct function

This was copied from a test for std::lcm but I forgot to change one of
the calls to use the experimental version of the function.

libstdc++-v3/ChangeLog:

PR libstdc++/92978
* testsuite/experimental/numeric/92978.cc: Use experimental::lcm
not std::lcm.

4 years agoMSP430: Fix -mlarge documentation to indicate size_t is a 20-bit type
Jozef Lawrynowicz [Wed, 2 Sep 2020 15:34:43 +0000 (16:34 +0100)]
MSP430: Fix -mlarge documentation to indicate size_t is a 20-bit type

gcc/ChangeLog:

* doc/invoke.texi (MSP430 options): Fix -mlarge description to
indicate size_t is a 20-bit type.

4 years agolibstdc++: Fix three-way comparison for std::array [PR 96851]
Jonathan Wakely [Wed, 2 Sep 2020 14:17:24 +0000 (15:17 +0100)]
libstdc++: Fix three-way comparison for std::array [PR 96851]

The spaceship operator for std::array uses memcmp when the
__is_byte<value_type> trait is true, but memcmp isn't usable in
constexpr contexts. Also, memcmp should only be used for unsigned byte
types, because it gives the wrong answer for signed chars with negative
values.

We can simply check std::is_constant_evaluated() so that we don't use
memcmp during constant evaluation.

To fix the problem of using memcmp for inappropriate types, this patch
adds new __is_memcmp_ordered and __is_memcmp_ordered_with traits. These
say whether using memcmp will give the right answer for ordering
operations such as lexicographical_compare and three-way comparisons.
The new traits can be used in several places, and can also be used to
implement my suggestion in PR 93059 comment 37 to use memcmp for
unsigned integers larger than one byte on big endian targets.

libstdc++-v3/ChangeLog:

PR libstdc++/96851
* include/bits/cpp_type_traits.h (__is_memcmp_ordered):
New trait that says if memcmp can be used for ordering.
(__is_memcmp_ordered_with): Likewise, for two types.
* include/bits/deque.tcc (__lex_cmp_dit): Use new traits
instead of __is_byte and __numeric_traits.
(__lexicographical_compare_aux1): Likewise.
* include/bits/ranges_algo.h (__lexicographical_compare_fn):
Likewise.
* include/bits/stl_algobase.h (__lexicographical_compare_aux1)
(__is_byte_iter): Likewise.
* include/std/array (operator<=>): Likewise. Only use memcmp
when std::is_constant_evaluated() is false.
* testsuite/23_containers/array/comparison_operators/96851.cc:
New test.
* testsuite/23_containers/array/tuple_interface/get_neg.cc:
Adjust dg-error line numbers.

4 years agoMSP430: Skip gcc.dg/pr55940.c in the small memory model
Jozef Lawrynowicz [Wed, 2 Sep 2020 12:42:39 +0000 (13:42 +0100)]
MSP430: Skip gcc.dg/pr55940.c in the small memory model

In the MSP430 small memory model, there is a 16-bit address space and
pointer arithmetic wraps around the address space, so any calculated
address is always within this range.

In this test, pointer arithmetic wraps when 0x1000 is added to the
address of a variable, causing the resulting address to be unexpectedly
less than 0x2000, which breaks the test.

gcc/testsuite/ChangeLog:

* gcc.dg/pr55940.c: Skip for msp430 unless -mlarge is specified.

4 years agolibstdc++: Break header cycle between <new> and <exception>
Jonathan Wakely [Wed, 2 Sep 2020 12:27:57 +0000 (13:27 +0100)]
libstdc++: Break header cycle between <new> and <exception>

The <new> and <exception> headers each include each other, which makes
building them as header-units "exciting". The <new> header only needs
the definition of std::exception (in order to derive from it) which is
already in its own header, so just include that.

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h: Include <bits/exception_defines.h>
for definitions of __try, __catch and __throw_exception_again.
(counted_iterator::operator++(int)): Use __throw_exception_again
instead of throw.
* libsupc++/new: Include <bits/exception.h> not <exception>.
* libsupc++/new_opvnt.cc: Include <bits/exception_defines.h>.
* testsuite/18_support/destroying_delete.cc: Include
<type_traits> for std::is_same_v definition.
* testsuite/20_util/variant/index_type.cc: Qualify size_t.

4 years agofortran: Fix o'...' boz to integer/real conversions [PR96859]
Jakub Jelinek [Wed, 2 Sep 2020 10:18:46 +0000 (12:18 +0200)]
fortran: Fix o'...' boz to integer/real conversions [PR96859]

The standard says that excess digits from boz are truncated.
For hexadecimal or binary, the routines copy just the number of digits
that will be needed, but for octal we copy number of digits that
contain one extra bit (for 8-bit, 32-bit or 128-bit, i.e. kind 1, 4 and 16)
or two extra bits (for 16-bit or 64-bit, i.e. kind 2 and 8).
The clearing of the first bit is done correctly by changing the first digit
if it is 4-7 to one smaller by 4 (i.e. modulo 4).
The clearing of the first two bits is done by changing 4 or 6 to 0
and 5 or 7 to 1, which is incorrect, because we really want to change the
first digit to 0 if it was even, or to 1 if it was odd, so digits
2 and 3 are mishandled by keeping them as is, rather than changing 2 to 0
and 3 to 1.

2020-09-02  Jakub Jelinek  <jakub@redhat.com>

PR fortran/96859
* check.c (gfc_boz2real, gfc_boz2int): When clearing first two bits,
change also '2' to '0' and '3' to '1' rather than just handling '4'
through '7'.

* gfortran.dg/pr96859.f90: New test.

4 years agohppa: Improve hppa_rtx_costs for shifts by constants.
Roger Sayle [Wed, 2 Sep 2020 08:30:50 +0000 (09:30 +0100)]
hppa: Improve hppa_rtx_costs for shifts by constants.

This patch provides more accurate rtx_costs estimates for shifts by
integer constants (which are cheaper than by a register amount).

2020-09-02  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/pa/pa.c (hppa_rtx_costs) [ASHIFT, ASHIFTRT, LSHIFTRT]:
Provide accurate costs for shifts of integer constants.

4 years agobpf: use the default asm_named_section target hook
Jose E. Marchesi [Wed, 2 Sep 2020 07:12:51 +0000 (09:12 +0200)]
bpf: use the default asm_named_section target hook

This patch makes the BPF backend to not provide its own implementation
of the asm_named_section hook; the default handler works perfectly
well.

2020-09-02  Jose E. Marchesi  <jose.marchesi@oracle.com>

gcc/
* config/bpf/bpf.c (bpf_asm_named_section): Delete.
(TARGET_ASM_NAMED_SECTION): Likewise.

4 years agobpf: use elfos.h
Jose E. Marchesi [Wed, 2 Sep 2020 07:12:21 +0000 (09:12 +0200)]
bpf: use elfos.h

BPF is an ELF-based target, so it definitely benefits from using
elfos.h.  This patch makes the target to use it, and removes
superfluous definitions from bpf.h which are better defined in
elfos.h.

Note that BPF, despite being an ELF target, doesn't use DWARF.  At
some point it will generate DWARF when generating xBPF (-mxbpf) and
BTF when generating plain eBPF, but for the time being it just
generates stabs.

2020-09-02  Jose E. Marchesi  <jemarch@gnu.org>

gcc/
* config.gcc: Use elfos.h in bpf-*-* targets.
* config/bpf/bpf.h (MAX_OFILE_ALIGNMENT): Remove definition.
(COMMON_ASM_OP): Likewise.
(INIT_SECTION_ASM_OP): Likewise.
(FINI_SECTION_ASM_OP): Likewise.
(ASM_OUTPUT_SKIP): Likewise.
(ASM_OUTPUT_ALIGNED_COMMON): Likewise.
(ASM_OUTPUT_ALIGNED_LOCAL): Likewise.

4 years agoDaily bump.
GCC Administrator [Wed, 2 Sep 2020 00:16:25 +0000 (00:16 +0000)]
Daily bump.

4 years agoUse the determined lower bound of the range of offsets in a PLUS_EXPR.
Martin Sebor [Tue, 1 Sep 2020 22:02:19 +0000 (16:02 -0600)]
Use the determined lower bound of the range of offsets in a PLUS_EXPR.

gcc/ChangeLog:

* builtins.c (compute_objsize):  Only replace the upper bound
of a POINTER_PLUS offset when it's less than the lower bound.

gcc/testsuite/ChangeLog:

* gcc.dg/Wstringop-overflow.c: Remove xfails.
* gcc.dg/Wstringop-overflow-42.c: New test.
* gcc.dg/Wstringop-overread-4.c: New test.

4 years agoc++: Allow new char[4]{"foo"} [PR77841]
Marek Polacek [Tue, 1 Sep 2020 15:44:16 +0000 (11:44 -0400)]
c++: Allow new char[4]{"foo"} [PR77841]

Currently, we allow new char[]{"foo"}, but not new char[4]{"foo"}.
We should accept the latter too: [dcl.init.list]p3.3 says to treat
this as [dcl.init.string].

We were rejecting this code because we never called reshape_init before
the digest_init in build_new_1.  reshape_init handles [dcl.init.string]
by unwrapping the STRING_CST from its enclosing { }, and digest_init
assumes that reshape_init has been called for aggregates anyway, and an
array is an aggregate.

gcc/cp/ChangeLog:

PR c++/77841
* init.c (build_new_1): Call reshape_init.

gcc/testsuite/ChangeLog:

PR c++/77841
* g++.dg/cpp0x/initlist-new4.C: New test.

4 years agolibstdc++: Add compile-time checks to__glibcxx_assert [PR 71960]
Jonathan Wakely [Tue, 1 Sep 2020 19:52:26 +0000 (20:52 +0100)]
libstdc++: Add compile-time checks to__glibcxx_assert [PR 71960]

This change evaluates __glibcxx_assert checks unconditionally when a
function is being constant evaluated (when std::is_constant_evaluated()
is true). If the check fails, compilation will fail with an error.

If the function isn't being constant evaluated, the normal runtime check
will be done if enabled by _GLIBCXX_ASSERTIONS or _GLIBCXX_DEBUG, the
same as before.

Tangentially, the __glibcxx_assert and _GLIBCXX_PARALLEL_ASSERT macros
are changed to expand to 'do { } while (false)' when assertions are
disabled, instead of expanding to nothing. This avoids -Wempty-body
warnings when a disabled assertion is used in an 'if' or 'else'
statement e.g.

  if constexpr (/* precondition is testable */)
    __glibcxx_assert(precondition);

a.C:9:27: warning: suggest braces around empty body in an â€˜if’ statement [-Wempty-body]
    9 |     __glibcxx_assert(precondition);
      |                                  ^

libstdc++-v3/ChangeLog:

PR libstdc++/71960
* include/bits/c++config (__glibcxx_assert_impl): Remove
do-while so that uses of the macro need to add it.
(__glibcxx_assert): Rename macro for runtime assertions
to __glibcxx_assert_2.
(__glibcxx_assert_1): Define macro for constexpr assertions.
(__glibcxx_assert): Define macro for constexpr and runtime
assertions.
* include/bits/range_access.h (ranges::advance): Remove
redundant precondition checks during constant evaluation.
* include/parallel/base.h (_GLIBCXX_PARALLEL_ASSERT): Always
use do-while in macro expansion.
* include/std/ranges (iota_view::iota_view(W, B)): Remove
redundant braces.

4 years agors6000: MMA built-in dies with incorrect sharing of tree nodes error
Peter Bergner [Tue, 1 Sep 2020 18:47:44 +0000 (13:47 -0500)]
rs6000: MMA built-in dies with incorrect sharing of tree nodes error

When we expand our MMA built-ins into gimple, we erroneously reused the
accumulator memory reference for both the source input value as well as
the destination output value.  This led to a tree sharing error.
The solution is to create separate memory references for the input
and output values.

2020-09-01  Peter Bergner  <bergner@linux.ibm.com>

gcc/
PR target/96808
* config/rs6000/rs6000-call.c (rs6000_gimple_fold_mma_builtin): Do not
reuse accumulator memory reference for source and destination accesses.

gcc/testsuite/
PR target/96808
* gcc.target/powerpc/pr96808.c: New test.

4 years agolibstdc++: Constrain chrono::duration conversions [LWG 2094]
Jonathan Wakely [Tue, 1 Sep 2020 17:18:26 +0000 (18:18 +0100)]
libstdc++: Constrain chrono::duration conversions [LWG 2094]

The chrono::duration constructor that converts from another duration
type is meant to be constrained so that it doesn't participate in
overload resolution if the ratio of the periods cannot be represented as
a std::ratio.

Because our std::ratio_divide is not SFINAE-friendly the evaluation of
__is_harmonic results in an error outside the immediate context when an
overflow occurs. I intend to make ratio_divide (and ratio_multiply)
SFINAE-friendly in a future patch, but for now this patch just
introduces a new SFINAE-friendly alias template for the division.

The standard doesn't require it, but it also seems right to constrain
the constructor with std::is_convertible_v<_Rep2, rep>.

libstdc++-v3/ChangeLog:

* include/std/chrono (duration::_S_gcd(intmax_t, intmax_t)):
New helper function for finding GCD of two positive intmax_t
values.
(duration::__divide): New helper alias for dividing one period
by another.
(duration::__is_harmonic): Use __divide not ratio_divide.
(duration(const duration<R2, P2>&)): Require the duration rep
types to be convertible.
* testsuite/20_util/duration/cons/dr2094.cc: New test.
* testsuite/20_util/duration/requirements/reduced_period.cc:
Fix definition of unused member functions in test type.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc:
Adjust expected errors.

4 years agoanalyzer: fix false NULL deref warning after previous deref [PR96792]
David Malcolm [Thu, 27 Aug 2020 11:42:27 +0000 (07:42 -0400)]
analyzer: fix false NULL deref warning after previous deref [PR96792]

gcc/analyzer/ChangeLog:
PR analyzer/96792
* region-model.cc (region_model::deref_rvalue): Add the constraint
that PTR_SVAL is non-NULL.

gcc/testsuite/ChangeLog:
PR analyzer/96792
* gcc.dg/analyzer/pr96792.c: New test.

4 years agovec: use inexact growth where possible.
Martin Liska [Mon, 10 Aug 2020 10:09:19 +0000 (12:09 +0200)]
vec: use inexact growth where possible.

gcc/ChangeLog:

* cfgrtl.c (rtl_create_basic_block): Use default value for
growth vector function.
* gimple.c (gimple_set_bb): Likewise.
* symbol-summary.h: Likewise.
* tree-cfg.c (init_empty_tree_cfg_for_function): Likewise.
(build_gimple_cfg): Likewise.
(create_bb): Likewise.
(move_block_to_fn): Likewise.

4 years agovec: default exect = false in grow functions.
Martin Liska [Mon, 10 Aug 2020 10:01:59 +0000 (12:01 +0200)]
vec: default exect = false in grow functions.

gcc/ChangeLog:

* vec.h (vec_safe_grow): Change default of exact to false.
(vec_safe_grow_cleared): Likewise.

4 years agoPR middle-end/90597: gcc_assert ICE in layout_type
Roger Sayle [Tue, 1 Sep 2020 11:03:21 +0000 (12:03 +0100)]
PR middle-end/90597: gcc_assert ICE in layout_type

This patch fixes the default implementation of TARGET_VECTOR_ALIGNMENT,
known as default_vector_alignment, using the same logic as my earlier
nvptx patch, as the ICE caused by TYPE_SIZE(type) being zero during
error handling in gcc.dg/attr-vector_size.c is common among backends,
and is known in bugzilla as PR middle-end/90597, apparently a recent
regression.

2020-09-01  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog:
PR middle-end/90597
* targhooks.c (default_vector_alignment): Return at least the
GET_MODE_ALIGNMENT for the type's mode.

4 years agoFortran : ICE on invalid code PR95398
Mark Eggleston [Mon, 1 Jun 2020 07:15:31 +0000 (08:15 +0100)]
Fortran  : ICE on invalid code PR95398

The CLASS_DATA macro is used to shorten the code accessing the derived
components of an expressions type specification.  If the type is not
BT_CLASS the derived pointer is NULL resulting in an ICE.  To avoid
dereferencing a NULL pointer the type should be BT_CLASS.

2020-09-01  Steven G. Kargl  <kargl@gcc.gnu.org>

gcc/fortran

PR fortran/95398
* resolve.c (resolve_select_type): Add check for BT_CLASS
type before using the CLASS_DATA macro which will have a
NULL pointer to derive components if it isn't BT_CLASS.

2020-09-01  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/testsuite

PR fortran/95398
* gfortran.dg/pr95398.f90: New test.

4 years agortl-optimization/96812 - remap dependence info on RTL loop unrolling
Richard Biener [Thu, 27 Aug 2020 12:21:33 +0000 (14:21 +0200)]
rtl-optimization/96812 - remap dependence info on RTL loop unrolling

This carries over the PR87609 fix also to RTL loop unrolling.  The
gcc.dg/torture/pr90328.c testcase otherwise is miscompiled with
the tree-ssa-address.c hunk (or alternatively with -fno-ivopts
on master).  I've tried to find the correct abstraction and
adjusted two other duplicate_insn_chain users for which I do not
have testcases.  There may be other insn-chain copying routines
that could be affected but hopefully most appropriately go through
CFG hooks.

2020-08-27  Richard Biener  <rguenther@suse.de>

PR rtl-optimization/96812
* tree-ssa-address.c (copy_ref_info): Also copy dependence info.
* cfgrtl.h (duplicate_insn_chain): Adjust prototype.
* cfgrtl.c (duplicate_insn_chain): Remap dependence info
if requested.
(cfg_layout_duplicate_bb): Make sure we remap dependence info.
* modulo-sched.c (duplicate_insns_of_cycles): Remap dependence
info.
(generate_prolog_epilog): Adjust.
* config/c6x/c6x.c (hwloop_optimize): Remap dependence info.

4 years agoopenmp: Check for PARM_DECL before using C_ARRAY_PARAMETER or DECL_ARRAY_PARAMETER_P...
Jakub Jelinek [Tue, 1 Sep 2020 07:17:58 +0000 (09:17 +0200)]
openmp: Check for PARM_DECL before using C_ARRAY_PARAMETER or DECL_ARRAY_PARAMETER_P [PR96867]

The C++ macro performs a PARM_DECL_CHECK, so will ICE if not tested on a PARM_DECL,
C_ARRAY_PARAMETER doesn't, but probably should, otherwise it is testing e.g.
C_DECL_VARIABLE_SIZE on VAR_DECLs.

2020-09-01  Jakub Jelinek  <jakub@redhat.com>

PR c++/96867
* c-typeck.c (handle_omp_array_sections_1): Test C_ARRAY_PARAMETER
only on PARM_DECLs.

* semantics.c (handle_omp_array_sections_1): Test
DECL_ARRAY_PARAMETER_P only on PARM_DECLs.

* c-c++-common/gomp/pr96867.c: New test.

4 years agoCorrect Changelog for fix to PR96806
Feng Xue [Tue, 1 Sep 2020 02:41:06 +0000 (10:41 +0800)]
Correct Changelog for fix to PR96806

4 years agotest/rs6000: Add Power9 and up as vect_len target
Kewen Lin [Tue, 1 Sep 2020 02:37:41 +0000 (02:37 +0000)]
test/rs6000: Add Power9 and up as vect_len target

Power9 supports vector with length in bytes load/store, this patch
is to teach check_effective_target_vect_len_load_store to take it
and its laters as effective vector with length targets.

Also supplement the documents for has_arch_pwr*.

Bootstrapped/regtested on powerpc64le-linux-gnu P8, also on
powerpc64le-linux-gnu P9 with explicit usage setting.

gcc/ChangeLog:

* doc/sourcebuild.texi (has_arch_pwr5, has_arch_pwr6, has_arch_pwr7,
has_arch_pwr8, has_arch_pwr9): Document.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp
(check_effective_target_vect_len_load_store): Call check function
check_effective_target_has_arch_pwr9.

4 years agoDaily bump.
GCC Administrator [Tue, 1 Sep 2020 00:16:25 +0000 (00:16 +0000)]
Daily bump.

4 years agors6000, remove improperly defined and unsupported builtins.
Carl Love [Thu, 27 Aug 2020 18:36:13 +0000 (13:36 -0500)]
rs6000, remove improperly defined and unsupported builtins.

gcc/ChangeLog

2020-08-31  Carl Love  <cel@us.ibm.com>

PR target/85830
* config/rs6000/altivec.h (vec_popcntb, vec_popcnth, vec_popcntw,
vec_popcntd): Remove defines.

4 years agoanalyzer: handle __builtin___memset_chk [PR96798]
David Malcolm [Mon, 31 Aug 2020 15:55:34 +0000 (11:55 -0400)]
analyzer: handle __builtin___memset_chk [PR96798]

gcc/analyzer/ChangeLog:
PR analyzer/96798
* region-model.cc (region_model::on_call_pre): Handle
BUILT_IN_MEMSET_CHK.

gcc/testsuite/ChangeLog:
PR analyzer/96798
* gcc.dg/analyzer/memset-1.c (test_5a): New.

4 years agoanalyzer: gather builtin/internal fn handling into switch statements
David Malcolm [Mon, 31 Aug 2020 20:20:55 +0000 (16:20 -0400)]
analyzer: gather builtin/internal fn handling into switch statements

Clean up this code in preparation for fixing PR analyzer/96798.

gcc/analyzer/ChangeLog:
* region-model.cc (region_model::on_call_pre): Gather handling of
builtins and of internal fns into switch statements.  Handle
"alloca" and BUILT_IN_ALLOCA_WITH_ALIGN.

4 years agoanalyzer: fix ICE on unknown index in CONSTRUCTOR [PR96860]
David Malcolm [Mon, 31 Aug 2020 13:00:23 +0000 (09:00 -0400)]
analyzer: fix ICE on unknown index in CONSTRUCTOR [PR96860]

PR analyzer/96860 reports an ICE inside CONSTRUCTOR-handling with
--param analyzer-max-svalue-depth=0 when attempting to build a
binding_map for the CONSTRUCTOR's values.

The issue is that when handling (index, value) pairs for initializing
an array, the index values for the elements exceeds the svalue
complexity limit, and the index is thus treated as unknown, leading to
a symbolic rather than concrete offset for each array element.

This patch updates the CONSTRUCTOR-handling code so that it can
fail, returning an unknown value for the overall value of the
constructor for this case, fixing the ICE.

gcc/analyzer/ChangeLog:
PR analyzer/96860
* region.cc (decl_region::get_svalue_for_constructor): Support
apply_ctor_to_region failing.
* store.cc (binding_map::apply_ctor_to_region): Add failure
handling.
(binding_map::apply_ctor_val_to_range): Likewise.
(binding_map::apply_ctor_pair_to_child_region): Likewise.  Replace
assertion that child_base_offset is not symbolic with error
handling.
* store.h (binding_map::apply_ctor_to_region): Convert return type
from void to bool.
(binding_map::apply_ctor_val_to_range): Likewise.
(binding_map::apply_ctor_pair_to_child_region): Likewise.

gcc/testsuite/ChangeLog:
PR analyzer/96860
* gcc.dg/analyzer/pr96860-1.c: New test.
* gcc.dg/analyzer/pr96860-2.c: New test.

4 years agoc++: Implement P1009: Array size deduction in new-expressions.
Marek Polacek [Thu, 13 Aug 2020 18:56:13 +0000 (14:56 -0400)]
c++: Implement P1009: Array size deduction in new-expressions.

This patch implements C++20 P1009, allowing code like

  new double[]{1,2,3}; // array bound will be deduced

Since this proposal makes the initialization rules more consistent, it is
applied to all previous versions of C++ (thus, effectively, all the way back
to C++11).

My patch is based on Jason's patch that handled the basic case.  I've
extended it to work with ()-init and also the string literal case.
Further testing revealed that to handle stuff like

  new int[]{t...};

in a template, we have to consider such a NEW_EXPR type-dependent.
Obviously, we first have to expand the pack to be able to deduce the
number of elements in the array.

Curiously, while implementing this proposal, I noticed that we fail
to accept

  new char[4]{"abc"};

so I've assigned 77841 to self.  I think the fix will depend on the
build_new_1 hunk in this patch.

The new tree.c function build_constructor_from_vec helps us morph
a vector into a CONSTRUCTOR more efficiently.

gcc/cp/ChangeLog:

PR c++/93529
* call.c (build_new_method_call_1): Use build_constructor_from_vec
instead of build_tree_list_vec + build_constructor_from_list.
* init.c (build_new_1): Handle new char[]{"foo"}.  Use
build_constructor_from_vec instead of build_tree_list_vec +
build_constructor_from_list.
(build_new): Deduce the array size in new-expression if not
present.  Handle ()-init.  Handle initializing an array from
a string literal.
* parser.c (cp_parser_new_type_id): Leave [] alone.
(cp_parser_direct_new_declarator): Allow [].
* pt.c (type_dependent_expression_p): In a NEW_EXPR, consider
array types whose dimension has to be deduced type-dependent.

gcc/ChangeLog:

PR c++/93529
* tree.c (build_constructor_from_vec): New.
* tree.h (build_constructor_from_vec): Declare.

gcc/testsuite/ChangeLog:

PR c++/93529
* g++.dg/cpp0x/sfinae4.C: Adjust expected result after P1009.
* g++.dg/cpp2a/new-array1.C: New test.
* g++.dg/cpp2a/new-array2.C: New test.
* g++.dg/cpp2a/new-array3.C: New test.
* g++.dg/cpp2a/new-array4.C: New test.

Co-authored-by: Jason Merrill <jason@redhat.com>
4 years agoanalyzer: fix ICE on RANGE_EXPR in CONSTRUCTORs [PR96763]
David Malcolm [Mon, 24 Aug 2020 13:33:42 +0000 (09:33 -0400)]
analyzer: fix ICE on RANGE_EXPR in CONSTRUCTORs [PR96763]

gcc/analyzer/ChangeLog:
PR analyzer/96763
* store.cc (binding_map::apply_ctor_to_region): Handle RANGE_EXPR
by calling a new binding_map::apply_ctor_val_to_range subroutine.
Split out the existing non-CONSTRUCTOR-handling code to a new
apply_ctor_pair_to_child_region subroutine.
(binding_map::apply_ctor_val_to_range): New.
(binding_map::apply_ctor_pair_to_child_region): New, split out
from binding_map::apply_ctor_to_region as noted above.
* store.h (binding_map::apply_ctor_val_to_range): New decl.
(binding_map::apply_ctor_pair_to_child_region): New decl.

gcc/testsuite/ChangeLog:
PR analyzer/96763
* g++.dg/analyzer/pr96763.C: New test.

4 years agoanalyzer: fix ICE on casting float to pointer [PR96764]
David Malcolm [Thu, 27 Aug 2020 22:20:24 +0000 (18:20 -0400)]
analyzer: fix ICE on casting float to pointer [PR96764]

gcc/analyzer/ChangeLog:
PR analyzer/96764
* region-model-manager.cc
(region_model_manager::maybe_fold_unaryop): Handle VIEW_CONVERT_EXPR.
(region_model_manager::get_or_create_cast): Move logic for
real->integer casting to...
(get_code_for_cast): ...this new function, and add logic for
real->non-integer casts.
(region_model_manager::maybe_fold_sub_svalue): Handle
VIEW_CONVERT_EXPR.
* region-model.cc
(region_model::add_any_constraints_from_gassign): Likewise.
* svalue.cc (svalue::maybe_undo_cast): Likewise.
(unaryop_svalue::dump_to_pp): Likewise.

gcc/testsuite/ChangeLog:
PR analyzer/96764
* gcc.dg/analyzer/pr96764.c: New test.

4 years agoPR tree-optimization/96818 - cast label range to type of switch operand
Aldy Hernandez [Fri, 28 Aug 2020 16:44:58 +0000 (18:44 +0200)]
PR tree-optimization/96818 - cast label range to type of switch operand

PR tree-optimization/96818
* tree-vrp.c (find_case_label_range): Cast label range to
type of switch operand.

4 years agod: Fix ICEs in the front-end when pointer size is 16-bit.
Iain Buclaw [Mon, 31 Aug 2020 11:31:04 +0000 (13:31 +0200)]
d: Fix ICEs in the front-end when pointer size is 16-bit.

In the lowering of `bt*' intrinsics, some integer constants had
mismatched types, and bitsize was set to the wrong value.

In base_vtable_offset, the base offset value was calculated incorrectly.
The TypeInfo_Class object is comprised of 18 pointers and 1 uint field,
so now the internal classinfo type size is used instead.

gcc/d/ChangeLog:

* d-target.cc (Target::_init): Don't set classinfosize.
* d-tree.h (base_vtable_offset): Move under typeinfo.cc section.
* decl.cc (base_vtable_offset): Move to...
* typeinfo.cc (base_vtable_offset): ...here.  Get base offset from
internal TypeInfo_Class type.
* intrinsics.cc (expand_intrinsic_bt): Use pointer TYPE_SIZE for
setting bitsize value.  Build integer constants of correct type.

4 years agotree-optimization/96854 - testcase for SLP reduction of two-operator
Richard Biener [Mon, 31 Aug 2020 11:36:09 +0000 (13:36 +0200)]
tree-optimization/96854 - testcase for SLP reduction of two-operator

This adds the testcase for the already fixed PR.

2020-08-31  Richard Biener  <rguenther@suse.de>

PR tree-optimization/96854
* gcc.dg/vect/pr96854.c: New testcase.

4 years agotestsuite: Fix aarch64/strcmpopt_6.c for -Wstringop-overread
Christophe Lyon [Mon, 31 Aug 2020 09:59:24 +0000 (09:59 +0000)]
testsuite: Fix aarch64/strcmpopt_6.c for -Wstringop-overread

2020-08-31  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/testsuite/
* gcc.target/aarch64/strcmpopt_6.c: Suppress -Wstringop-overread.

4 years agoRefine expander vec_unpacku_float_hi_v16si/vec_unpacku_float_lo_v16si
liuhongt [Tue, 11 Aug 2020 03:05:40 +0000 (11:05 +0800)]
Refine expander vec_unpacku_float_hi_v16si/vec_unpacku_float_lo_v16si

gcc/
PR target/96551
* config/i386/sse.md (vec_unpacku_float_hi_v16si): For vector
compare to integer mask, don't use gen_rtx_LT, use
ix86_expand_mask_vec_cmp instead.
(vec_unpacku_float_hi_v16si): Ditto.

gcc/testsuite
* gcc.target/i386/avx512f-pr96551-1.c: New test.
* gcc.target/i386/avx512f-pr96551-2.c: New test.

4 years agotree-cfg: Improve gimple switch verification
Jakub Jelinek [Mon, 31 Aug 2020 08:51:02 +0000 (10:51 +0200)]
tree-cfg: Improve gimple switch verification

When looking at the verification, I have noticed a bug in it.

The verification that CASE_HIGH (if present) has the same type as CASE_LOW
is only performed for the case label 2 and higher, case label 1 (the first
one after the default label) isn't checked.

The following patch fixes that, it will uselessly also compare
TREE_TYPE (CASE_LOW (elt)) != elt_type for the case label 1, but I think
that isn't that expensive and helps readability of the code.

2020-08-31  Jakub Jelinek  <jakub@redhat.com>

* tree-cfg.c (verify_gimple_switch): If the first non-default case
label has CASE_HIGH, verify it has the same type as CASE_LOW.

4 years agoipa/96806 - Fix ICE in ipa-cp due to integer addition overflow
Feng Xue [Mon, 31 Aug 2020 07:00:52 +0000 (15:00 +0800)]
ipa/96806 - Fix ICE in ipa-cp due to integer addition overflow

2020-08-31  Feng Xue  <fxue@os.amperecomputing.com>

gcc/
PR tree-optimization/96806
* ipa-cp.c (decide_about_value): Use safe_add to avoid cost addition
overflow.

gcc/testsuite/
PR tree-optimization/96806
* g++.dg/ipa/pr96806.C: New test.

4 years agovarasm: Optimize memory broadcast for constant vector under AVX512 [PR54201]
Jakub Jelinek [Mon, 31 Aug 2020 08:27:00 +0000 (10:27 +0200)]
varasm: Optimize memory broadcast for constant vector under AVX512 [PR54201]

I meant something like the following, which on e.g. a dumb:

typedef float V __attribute__((vector_size (4 * sizeof (float))));

void
foo (V *p, float *q)
{
  p[0] += (V) { 1.0f, 2.0f, 3.0f, 4.0f };
  q[0] += 4.0f;
  q[1] -= 3.0f;
  q[17] -= 2.0f;
  q[31] += 1.0f;
}

testcase merges all the 4 scalar constant pool entries into the CONST_VECTOR
one.

I'm punting for section anchors and not doing it in the per-function (i.e.
non-shared) constant pools simply because I don't know them well enough,
don't know whether backends use the offsets for something etc.
For section anchors, I guess it would need to be done before (re)computing the
offsets and arrange for the desc->mark < 0 entries not to be considered as
objects in the object block, for non-shared pools, perhaps it would be
enough to call the new function from output_constant_pool before calling
recompute_pool_offsets and adjust recompute_pool_offsets to ignore
desc->mark < 0.

Here is an adjusted patch that ought to merge even the same sized different
mode vectors with the same byte representation, etc.
It won't really help with avoiding the multiple reads of the constant in the
same function, but as you found, your patch doesn't help with that either.
Your patch isn't really incompatible with what the patch below does, though
I wonder whether a) it wouldn't be better to always canonicalize to an
integral mode with as few elts as possible even e.g. for floats b) whether
asserting that it simplify_rtx succeeds is safe, whether it shouldn't just
canonicalize if the canonicalization works and just do what it previously
did otherwise.

The following patch puts all pool entries which can be natively encoded
into a vector, sorts it by decreasing size, determines minimum size
of a pool entry and adds hash elts for each (aligned) min_size or wider
power of two-ish portion of the pool constant in addition to the whole pool
constant byte representation.

This is the version that passed bootstrap/regtest on both x86_64-linux and
i686-linux.  In both bootstraps/regtests together, it saved (from the
statistics I've gathered) 63104 .rodata bytes (before constant merging),
in 6814 hits of the data->desc->mark = ~(*slot)->desc->labelno;.

2020-08-31  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/54201
* varasm.c: Include alloc-pool.h.
(output_constant_pool_contents): Emit desc->mark < 0 entries as
aliases.
(struct constant_descriptor_rtx_data): New type.
(constant_descriptor_rtx_data_cmp): New function.
(struct const_rtx_data_hasher): New type.
(const_rtx_data_hasher::hash, const_rtx_data_hasher::equal): New
methods.
(optimize_constant_pool): New function.
(output_shared_constant_pool): Call it if TARGET_SUPPORTS_ALIASES.

4 years agotestsuite: Update some vect cases for partial vectors
Kewen Lin [Mon, 31 Aug 2020 00:52:03 +0000 (19:52 -0500)]
testsuite: Update some vect cases for partial vectors

This patch is to adjust some existing vectorization test cases
to work well with the newly introduced partial vector usages.

Bootstrapped/regtested on aarch64-linux-gnu and powerpc64le-linux-gnu
P9 (with explicit param vect-partial-vector-usage=1 and enablement on
check_effective_target_vect_partial_vectors_usage_1 check).

gcc/ChangeLog:

* doc/sourcebuild.texi (vect_len_load_store,
vect_partial_vectors_usage_1, vect_partial_vectors_usage_2,
vect_partial_vectors): Document.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/bb-slp-pr69907.c: Adjust for partial vector usages.
* gcc.dg/vect/slp-3.c: Likewise.
* gcc.dg/vect/slp-multitypes-11.c: Likewise.
* gcc.dg/vect/slp-perm-1.c: Likewise.
* gcc.dg/vect/slp-perm-5.c: Likewise.
* gcc.dg/vect/slp-perm-6.c: Likewise.
* gcc.dg/vect/slp-perm-7.c: Likewise.
* gcc.dg/vect/slp-perm-8.c: Likewise.
* gcc.dg/vect/slp-perm-9.c: Likewise.
* gcc.dg/vect/vect-version-2.c: Likewise.
* lib/target-supports.exp (check_vect_partial_vector_usage): New
function.
(check_effective_target_vect_len_load_store): Likewise.
(check_effective_target_vect_partial_vectors_usage_1): Likewise.
(check_effective_target_vect_partial_vectors_usage_2): Likewise.
(check_effective_target_vect_partial_vectors): Likewise.

4 years agoDaily bump.
GCC Administrator [Mon, 31 Aug 2020 00:16:22 +0000 (00:16 +0000)]
Daily bump.

4 years agoUse get_size_range instead of get_range to obtain range of valid sizes.
Martin Sebor [Sun, 30 Aug 2020 21:10:44 +0000 (15:10 -0600)]
Use get_size_range instead of get_range to obtain range of valid sizes.

gcc/ChangeLog:

* builtins.c (access_ref::access_ref): Call get_size_range instead
of get_range.

gcc/testsuite/ChangeLog:

* gcc.dg/Wstringop-overread-3.c: New test.

4 years ago 2020-8-20 José Rui Faustino de Sousa <jrfsousa@gmail.com>
José Rui Faustino de Sousa [Sun, 30 Aug 2020 18:10:15 +0000 (18:10 +0000)]
2020-8-20  José Rui Faustino de Sousa  <jrfsousa@gmail.com>

gcc/fortran/ChangeLog:

PR fortran/96728
* module.c (module_peek_char): Peek ahead function.
(parse_integer): Add code for parsing signed integers.
(parse_atom): Add code to handle signed integers.
(peek_atom): Add code to handle signed integers.

gcc/testsuite/ChangeLog:

PR fortran/96728
* gfortran.dg/PR96728.f90: New test.

4 years ago 2020-8-20 José Rui Faustino de Sousa <jrfsousa@gmail.com>
José Rui Faustino de Sousa [Sun, 30 Aug 2020 18:03:13 +0000 (18:03 +0000)]
2020-8-20  José Rui Faustino de Sousa  <jrfsousa@gmail.com>

gcc/fortran/ChangeLog:

PR fortran/96727
* expr.c (gfc_check_init_expr): Add default error message for the AS_ASSUMED_RANK case.

gcc/testsuite/ChangeLog:

PR fortran/96727
* gfortran.dg/PR96727.f90: New test.

4 years ago 2020-8-20 José Rui Faustino de Sousa <jrfsousa@gmail.com>
José Rui Faustino de Sousa [Sun, 30 Aug 2020 17:58:13 +0000 (17:58 +0000)]
2020-8-20  José Rui Faustino de Sousa  <jrfsousa@gmail.com>

gcc/fortran/ChangeLog:

PR fortran/96726
* expr.c (check_references): Change different relational operator
to less-than operator to avoid infinite loop.

gcc/testsuite/ChangeLog:

PR fortran/96726
* gfortran.dg/PR96726.f90: New test.

4 years ago 2020-8-21 Steve Kargl <sgk@troutmask.apl.washington.edu>
Steve Kargl [Sun, 30 Aug 2020 17:48:12 +0000 (17:48 +0000)]
2020-8-21  Steve Kargl <sgk@troutmask.apl.washington.edu>

gcc/fortran/ChangeLog:

PR fortran/95352
* simplify.c (simplify_bound_dim): Add check for NULL pointer
before trying to access structure member.

    José Rui Faustino de Sousa  <jrfsousa@gmail.com>

gcc/testsuite/ChangeLog:

* gfortran.dg/PR95352.f90: New test.

4 years ago 2020-8-20 José Rui Faustino de Sousa <jrfsousa@gmail.com>
José Rui Faustino de Sousa [Sun, 30 Aug 2020 17:28:08 +0000 (17:28 +0000)]
2020-8-20  José Rui Faustino de Sousa  <jrfsousa@gmail.com>

gcc/fortran/ChangeLog:

PR fortran/94110
* interface.c (gfc_compare_actual_formal): Add code to also raise
the actual argument cannot be an assumed-size array error when the
dummy arguments are deferred-shape or assumed-rank pointer.

gcc/testsuite/ChangeLog:

PR fortran/94110
* gfortran.dg/PR94110.f90: New test.

4 years agox86: Fix up ssse3_pshufbv8qi splitter
Jakub Jelinek [Sun, 30 Aug 2020 12:15:45 +0000 (14:15 +0200)]
x86: Fix up ssse3_pshufbv8qi splitter

The constant pool size optimization I was testing resulted in various ICEs
in gcc.target/i386/ testsuite, the problem is that the ssse3_pshufbv8qi
splitter emits invalid RTL, in V4SImode 0xf7f7f7f7 CONST_INTs shouldn't
appear, instead they should have been -0x8080809 (0xf7f7f7f7 sign extended
into 64 bits).

2020-08-30  Jakub Jelinek  <jakub@redhat.com>

* config/i386/sse.md (ssse3_pshufbv8qi): Use gen_int_mode instead of
GEN_INT, and ix86_build_const_vector instead of gen_rtvec and
gen_rtx_CONT_VECTOR.

4 years agoDaily bump.
GCC Administrator [Sun, 30 Aug 2020 00:16:20 +0000 (00:16 +0000)]
Daily bump.

4 years agolibstdc++: Fix deleted overload of __absu(bool)
Jonathan Wakely [Sat, 29 Aug 2020 17:24:08 +0000 (18:24 +0100)]
libstdc++: Fix deleted overload of __absu(bool)

libstdc++-v3/ChangeLog:

* include/std/numeric (__detail::__absu(bool)): Make deleted
function a function template, so it will be chosen for calls
with an explicit template argument list.
* testsuite/26_numerics/gcd/gcd_neg.cc: Add dg-prune-output.
* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.

4 years agors6000: Remove ALTIVEC_BUILTIN_MASK_FOR_STORE
Bill Schmidt [Sat, 29 Aug 2020 01:05:58 +0000 (20:05 -0500)]
rs6000: Remove ALTIVEC_BUILTIN_MASK_FOR_STORE

It turns out that the target hook that this is supposed to satisfy
disappeared in 2004.  Probably time to retire it.

2020-08-28  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
* config/rs6000/rs6000-builtin.def (MASK_FOR_STORE): Remove.
* config/rs6000/rs6000-call.c (rs6000_expand_builtin): Remove
all logic for ALTIVEC_BUILTIN_MASK_FOR_STORE.

4 years agoDaily bump.
GCC Administrator [Sat, 29 Aug 2020 00:16:21 +0000 (00:16 +0000)]
Daily bump.

4 years agolibstdc++: Fix common_type specializations for duration
Jonathan Wakely [Fri, 28 Aug 2020 22:41:13 +0000 (23:41 +0100)]
libstdc++: Fix common_type specializations for duration

My recent change to implement P0548 ("common_type and duration") was not
correct. The result of common_type_t<duration<R,P>, duration<R,P>>
should be duration<common_type_t<R>, P::type>, not duration<R, P::type>.
The common_type specialization for two different duration types was
correct, but the specializations for a single duration type (which only
exist to optimize compilation time) were wrong.

This fixes the partial specializations of common_type for a single
duration type, and also the return types of duration::operator+ and
duration::operator- which are supposed to use common_type_t<duration>.

libstdc++-v3/ChangeLog:

* include/std/chrono (common_type): Fix partial specializations
for a single duration type to use the common_type of the rep.
(duration::operator+, duration::operator-): Fix return types
to also use the common_type of the rep.
* testsuite/20_util/duration/requirements/reduced_period.cc:
Check duration using a rep that has common_type specialized.

4 years agolibstdc++: Fix std::gcd and std::lcm for unsigned integers [PR 92978]
Jonathan Wakely [Fri, 28 Aug 2020 21:45:24 +0000 (22:45 +0100)]
libstdc++: Fix std::gcd and std::lcm for unsigned integers [PR 92978]

This fixes a bug with mixed signed and unsigned types, where converting
a negative value to the unsigned result type alters the value. The
solution is to obtain the absolute values of the arguments immediately
and to perform the actual GCD or LCM algorithm on two arguments of the
same type.

In order to operate on the most negative number without overflow when
taking its absolute, use an unsigned type for the result of the abs
operation. For example, -INT_MIN will overflow, but -(unsigned)INT_MIN
is (unsigned)INT_MAX+1U which is the correct value.

libstdc++-v3/ChangeLog:

PR libstdc++/92978
* include/std/numeric (__abs_integral): Replace with ...
(__detail::__absu): New function template that returns an
unsigned type, guaranteeing it can represent the most
negative signed value.
(__detail::__gcd, __detail::__lcm): Require arguments to
be unsigned and therefore already non-negative.
(gcd, lcm): Convert arguments to absolute value as unsigned
type before calling __detail::__gcd or __detail::__lcm.
* include/experimental/numeric (gcd, lcm): Likewise.
* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust expected
errors.
* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
* testsuite/26_numerics/gcd/92978.cc: New test.
* testsuite/26_numerics/lcm/92978.cc: New test.
* testsuite/experimental/numeric/92978.cc: New test.

4 years agoAdd -Wstringop-overread for reading past the end by string functions.
Martin Sebor [Fri, 28 Aug 2020 19:13:28 +0000 (13:13 -0600)]
Add -Wstringop-overread for reading past the end by string functions.

gcc/ChangeLog:

* attribs.c (init_attr_rdwr_indices): Use global access_mode.
* attribs.h (struct attr_access): Same.
* builtins.c (fold_builtin_strlen): Add argument.
(compute_objsize): Declare.
(get_range): Declare.
(check_read_access): New function.
(access_ref::access_ref): Define ctor.
(warn_string_no_nul): Add arguments.  Handle -Wstrintop-overread.
(check_nul_terminated_array): Handle source strings of different
ranges of sizes.
(expand_builtin_strlen): Remove warning code, call check_read_access
instead.  Declare locals closer to their initialization.
(expand_builtin_strnlen): Same.
(maybe_warn_for_bound): New function.
(warn_for_access): Remove argument.  Handle -Wstrintop-overread.
(inform_access): Change argument type.
(get_size_range): New function.
(check_access): Remove unused arguments.  Add new arguments.  Handle
-Wstrintop-overread.  Move warning code to helpers and call them.
Call check_nul_terminated_array.
(check_memop_access): Remove unnecessary and provide additional
arguments in calls.
(expand_builtin_memchr): Call check_read_access.
(expand_builtin_strcat): Remove unnecessary and provide additional
arguments in calls.
(expand_builtin_strcpy): Same.
(expand_builtin_strcpy_args): Same.  Avoid testing no-warning bit.
(expand_builtin_stpcpy_1): Remove unnecessary and provide additional
arguments in calls.
(expand_builtin_stpncpy): Same.
(check_strncat_sizes): Same.
(expand_builtin_strncat): Remove unnecessary and provide additional
arguments in calls.  Adjust comments.
(expand_builtin_strncpy): Remove unnecessary and provide additional
arguments in calls.
(expand_builtin_memcmp): Remove warning code.  Call check_access.
(expand_builtin_strcmp): Call check_access instead of
check_nul_terminated_array.
(expand_builtin_strncmp): Handle -Wstrintop-overread.
(expand_builtin_fork_or_exec): Call check_access instead of
check_nul_terminated_array.
(expand_builtin): Same.
(fold_builtin_1): Pass additional argument.
(fold_builtin_n): Same.
(fold_builtin_strpbrk): Remove calls to check_nul_terminated_array.
(expand_builtin_memory_chk): Add comments.
(maybe_emit_chk_warning): Remove unnecessary and provide additional
arguments in calls.
(maybe_emit_sprintf_chk_warning): Same.  Adjust comments.
* builtins.h (warn_string_no_nul): Add arguments.
(struct access_ref): Add member and ctor argument.
(struct access_data): Add members and ctor.
(check_access): Adjust signature.
* calls.c (maybe_warn_nonstring_arg): Return an indication of
whether a warning was issued.  Issue -Wstrintop-overread instead
of -Wstringop-overflow.
(append_attrname): Adjust to naming changes.
(maybe_warn_rdwr_sizes): Same.  Remove unnecessary and provide
additional arguments in calls.
* calls.h (maybe_warn_nonstring_arg): Return bool.
* doc/invoke.texi (-Wstringop-overread): Document new option.
* gimple-fold.c (gimple_fold_builtin_strcpy): Provide an additional
argument in call.
(gimple_fold_builtin_stpcpy): Same.
* tree-ssa-uninit.c (maybe_warn_pass_by_reference): Adjust to naming
changes.
* tree.h (enum access_mode): New type.

gcc/c-family/ChangeLog:

* c.opt (Wstringop-overread): New option.

gcc/testsuite/ChangeLog:

* c-c++-common/Warray-bounds-7.c: Adjust expected warnings.
* c-c++-common/Wrestrict.c: Remove xfail.
* c-c++-common/attr-nonstring-3.c: Adjust text of expected warnings.
* c-c++-common/attr-nonstring-6.c: Suppress -Wstringop-overread
instead of -Wstringop-overflow.
* c-c++-common/attr-nonstring-8.c: Adjust text of expected warnings.
* g++.dg/torture/Wsizeof-pointer-memaccess1.C: Also suppress
 -Wstringop-overread.
* g++.dg/torture/Wsizeof-pointer-memaccess2.C: Same.
* gcc.dg/Warray-bounds-39.c: Adjust expected warnings.
* gcc.dg/Warray-bounds-40.c: Also suppress -Wstringop-overread.
* gcc.dg/Warray-bounds-58.c: Remove xfail.  Also expect
-Wstringop-overread.  Adjust text of expected warnings.
* gcc.dg/Wsizeof-pointer-memaccess1.c: Also suppress
 -Wstringop-overread.
* gcc.dg/Wstringop-overflow-22.c: Adjust text of expected warnings.
* gcc.dg/Wstringop-overflow-33.c: Expect -Wstringop-overread.
* gcc.dg/Wstringop-overflow-9.c: Expect -Wstringop-overread.
* gcc.dg/attr-nonstring-2.c: Adjust text of expected warnings.
* gcc.dg/attr-nonstring-3.c: Same.
* gcc.dg/attr-nonstring-4.c: Same.
* gcc.dg/attr-nonstring.c: Expect -Wstringop-overread.
* gcc.dg/builtin-stringop-chk-5.c: Adjust comment.
* gcc.dg/builtin-stringop-chk-8.c: Enable -Wstringop-overread instead
of -Wstringop-overflow.
* gcc.dg/pr78902.c: Also expect -Wstringop-overread.
* gcc.dg/pr79214.c: Adjust text of expected warnings.
* gcc.dg/strcmpopt_10.c: Suppress valid -Wno-stringop-overread.
* gcc.dg/strlenopt-57.c: Also expect -Wstringop-overread.
* gcc.dg/torture/Wsizeof-pointer-memaccess1.c: Also suppress valid
-Wno-stringop-overread.
* gcc.dg/tree-ssa/builtins-folding-gimple-ub.c: Same.
* gcc.dg/uninit-33.c: Same.
* gcc.dg/warn-strnlen-no-nul-2.c: Adjust text of expected warning.
* gcc.dg/warn-strnlen-no-nul.c: Same.
* gcc.target/i386/strcmpopt_6.c: Suppress -Wstringop-overread.
* gcc.dg/Wstringop-overread-2.c: New test.
* gcc.dg/Wstringop-overread.c: New test.

4 years agors6000: r12 copy cleanup
Bill Schmidt [Fri, 28 Aug 2020 16:47:01 +0000 (11:47 -0500)]
rs6000: r12 copy cleanup

Remove unnecessary tests before copying function address to r12.

2020-08-28  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
* config/rs6000/rs6000.c (rs6000_call_aix): Remove test for r12.
(rs6000_sibcall_aix): Likewise.

4 years agoamdgcn: Update vec_safe_grow_cleared usage
Andrew Stubbs [Fri, 28 Aug 2020 14:41:38 +0000 (15:41 +0100)]
amdgcn: Update vec_safe_grow_cleared usage

An API change broke the amdgcn build.

gcc/ChangeLog:

* config/gcn/gcn-tree.c (gcn_goacc_get_worker_red_decl): Add "true"
parameter to vec_safe_grow_cleared.

4 years agoCorrect calls to vec::safe_grow in conditionally compiled code.
Martin Sebor [Fri, 28 Aug 2020 14:31:50 +0000 (08:31 -0600)]
Correct calls to vec::safe_grow in conditionally compiled code.

gcc/ChangeLog:

* ggc-common.c (gt_pch_save): Add argument to a call.

gcc/jit/ChangeLog:

* jit-recording.c (recording::switch_::make_debug_string): Add argument
to a call.

4 years agoPR c/96596 - ICE in match_builtin_function_types on a declaration of a built-in with...
Martin Sebor [Fri, 28 Aug 2020 14:26:32 +0000 (08:26 -0600)]
PR c/96596 - ICE in match_builtin_function_types on a declaration of a built-in with invalid array argument

gcc/c/ChangeLog:

PR c/96596
* c-decl.c (match_builtin_function_types): Avoid dealing with erroneous
argument type.

gcc/testsuite/ChangeLog:

PR c/96596
* gcc.dg/Wbuiltin-declaration-mismatch-16.c: New test.

4 years agoFortran: Fix absent-optional handling for nondescriptor arrays (PR94672)
Tobias Burnus [Fri, 28 Aug 2020 11:54:10 +0000 (13:54 +0200)]
Fortran: Fix absent-optional handling for nondescriptor arrays (PR94672)

gcc/fortran/ChangeLog:

PR fortran/94672
* trans-array.c (gfc_trans_g77_array): Check against the parm decl and
set the nonparm decl used for the is-present check to NULL if absent.

gcc/testsuite/ChangeLog:

PR fortran/94672
* gfortran.dg/optional_assumed_charlen_2.f90: New test.

4 years ago[PATCH PR96357][GCC][AArch64]: could not split insn UNSPEC_COND_FSUB with AArch64 SVE
Przemyslaw Wirkus [Fri, 28 Aug 2020 10:31:04 +0000 (11:31 +0100)]
[PATCH PR96357][GCC][AArch64]: could not split insn UNSPEC_COND_FSUB with AArch64 SVE

Problem is related to that operand 4 (In original pattern
cond_sub<mode>_any_const) is no longer the same as operand 1, and so
the pattern doesn't match the split condition.

Pattern cond_sub<mode>_any_const is being split by this patch into two
separate patterns:
* Pattern cond_sub<mode>_relaxed_const now matches const_int
  SVE_RELAXED_GP operand.
* Pattern cond_sub<mode>_strict_const now matches const_int
  SVE_STRICT_GP operand.
* Remove aarch64_sve_pred_dominates_p condition from both patterns.

gcc/ChangeLog:

PR target/96357
* config/aarch64/aarch64-sve.md
(cond_sub<mode>_relaxed_const): Updated and renamed from
cond_sub<mode>_any_const pattern.
(cond_sub<mode>_strict_const): New pattern.

gcc/testsuite/ChangeLog:

PR target/96357
* gcc.target/aarch64/sve/pr96357.c: New test.

4 years agofix a typo in rtl.texi
Wei Wentao [Fri, 28 Aug 2020 09:43:56 +0000 (10:43 +0100)]
fix a typo in rtl.texi

gcc/
* doc/rtl.texi: Fix typo.

4 years agoaarch64: Disable mem-shift-canonical test on ILP32
Alex Coplan [Fri, 28 Aug 2020 09:30:59 +0000 (10:30 +0100)]
aarch64: Disable mem-shift-canonical test on ILP32

This test fails on ILP32 since we're looking for a pattern that could
only be hit on LP64. Disabling the test on ILP32 since the problematic
mult pattern was never hit there, so there's nothing to test.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/mem-shift-canonical.c: Skip on ILP32.

4 years agoThis patch fixes PR96624.
Paul Thomas [Fri, 28 Aug 2020 08:02:58 +0000 (09:02 +0100)]
This patch fixes PR96624.

2020-08-28  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/96624
* simplify.c (gfc_simplify_reshape): Detect zero shape and
clear index if found.

gcc/testsuite/
PR fortran/96624
* gfortran.dg/reshape_8.f90 : New test.

4 years agotestsuite: Run gcc.dg/pr96579.c only on targets with dfp support.
Christophe Lyon [Fri, 28 Aug 2020 07:56:51 +0000 (07:56 +0000)]
testsuite: Run gcc.dg/pr96579.c only on targets with dfp support.

gcc.dg/pr96579.c includes gcc.dg/pr96370.c which needs target dfp.

2020-08-28  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/testsuite/
* gcc.dg/pr96579.c: Compile only with target dfp.

4 years agoAdd expander for movp2hi and movp2qi.
liuhongt [Wed, 26 Aug 2020 07:24:10 +0000 (15:24 +0800)]
Add expander for movp2hi and movp2qi.

2020-08-30  Uros Bizjak    <ubizjak@gmail.com>

gcc/ChangeLog:
PR target/96744
* config/i386/i386-expand.c (split_double_mode): Also handle
E_P2HImode and E_P2QImode.
* config/i386/sse.md (MASK_DWI): New define_mode_iterator.
(mov<mode>): New expander for P2HI,P2QI.
(*mov<mode>_internal): New define_insn_and_split to split
movement of P2QI/P2HI to 2 movqi/movhi patterns after reload.

gcc/testsuite/ChangeLog:

* gcc.target/i386/double_mask_reg-1.c: New test.

4 years agoFix: AVX512VP2INTERSECT should imply AVX512DQ.
liuhongt [Fri, 28 Aug 2020 07:01:18 +0000 (15:01 +0800)]
Fix: AVX512VP2INTERSECT should imply AVX512DQ.

gcc/ChangeLog

* common/config/i386/i386-common.c (ix86_handle_option): Set
AVX512DQ when AVX512VP2INTERSECT exists.

4 years agoDaily bump.
GCC Administrator [Fri, 28 Aug 2020 00:16:24 +0000 (00:16 +0000)]
Daily bump.

4 years agogotest: use a space rather than a middle dot in target lists
Maciej W. Rozycki [Thu, 27 Aug 2020 21:02:28 +0000 (22:02 +0100)]
gotest: use a space rather than a middle dot in target lists

Replace the U+00B7 middle dot character, placed after "mips64p32le"
in the target lists, with a space.  The U+00B7 character may not be
considered whitespace by Bourne shell and any non-ASCII character
may render incorrectly in some terminal devices.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/251177

4 years agolibstdc++: Make std::chrono::duration use reduced ratio for period
Jonathan Wakely [Thu, 27 Aug 2020 21:36:03 +0000 (22:36 +0100)]
libstdc++: Make std::chrono::duration use reduced ratio for period

This implements the changes from P0548 "common_type and duration". That
was a change for C++17, but as it corrects some issues introduced by DRs
I'm also treating it as a DR and changing it for all modes from C++11
up.

The main change is that duration<R,P>::period no longer denotes P, but
rather P::type, the reduced ratio. The unary operator+ and operator-
members of duration should now return a duration using that reduced
ratio.

The requirement that common_type<T>::type is the same type as
common_type<T, T>::type (rather than simply T) was already implemented
for PR 89102.

The standard says that duration::operator+() and duration::operator-()
should return common_type_t<duration>, but that seems unnecessarily
expensive to compute. This change just uses duration<rep, period> which
is the same type, so we don't need to instantiate common_type.

As an optimization, this also adds partial specializations of
common_type for two durations of the same type, a single duration, two
time_points of the same type, and a single time_point. These
specializations avoid instantiating other specializations of common_type
and one or both of __duration_common_type or __timepoint_common_type for
the cases where the answer is trivial to obtain.

libstdc++-v3/ChangeLog:

* include/std/chrono (__duration_common_type): Ensure the
reduced ratio is used. Remove unused partial specialization
using __failure_type.
(common_type): Pass reduced ratios to __duration_common_type.
Add partial specializations for simple cases involving a single
duration or time_point type.
(duration::period): Use reduced ratio.
(duration::operator+(), duration::operator-()): Return duration
type using the reduced ratio.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc:
Adjust expected errors.
* testsuite/20_util/duration/requirements/reduced_period.cc: New test.

4 years agoFix shadd-2.c scan assembler count.
John David Anglin [Thu, 27 Aug 2020 19:21:22 +0000 (19:21 +0000)]
Fix shadd-2.c scan assembler count.

2020-08-27  John David Anglin  <danglin@gcc.gnu.org>

gcc/testsuite/
* gcc.target/hppa/shadd-2.c: Adjust times to 4.

4 years agolibstdc++: Fix arithmetic bug in chrono::year_month::operator+
Patrick Palka [Thu, 27 Aug 2020 18:11:24 +0000 (14:11 -0400)]
libstdc++: Fix arithmetic bug in chrono::year_month::operator+

This fixes the months-based addition for year_month when the
year_month's month component is 0.

libstdc++-v3/ChangeLog:

* include/std/chrono (year_month::operator+): Properly handle a
month value of 0 by casting the month value to int before
subtracting 1 from it so that the difference is sign-extended in
the subsequent addition.
* testsuite/std/time/year_month/1.cc: Test adding months to a
year_month whose month component is below or above the
normalized range of [1,12].

4 years agolibstdc++: Fix operator overload ambiguity with calendar types
Patrick Palka [Thu, 27 Aug 2020 18:09:52 +0000 (14:09 -0400)]
libstdc++: Fix operator overload ambiguity with calendar types

We currently don't enforce a constraint on some of the calendar types'
addition/subtraction operator overloads that take a 'months' arguments:

  Constraints: If the argument supplied by the caller for the months
  parameter is convertible to years, its implicit conversion sequence to
  years is worse than its implicit conversion sequence to months.

This constraint is relevant when adding/subtracting a duration to/from,
say, a year_month where the given duration is convertible to both
'months' and to 'years' (as in the new testcases below).  The correct
behavior here in light of this constraint is to perform the operation
through the (more efficient) 'years'-based overload, but we currently
emit an ambiguous overload error.

This patch templatizes the 'months'-based addition/subtraction operator
overloads so that in the event of an implicit-conversion tie, we select
the non-template 'years'-based overload.  This is the same approach
that the date library takes for enforcing this constraint.

libstdc++-v3/ChangeLog:

* include/std/chrono
(__detail::__months_years_conversion_disambiguator): Define.
(year_month::operator+=): Templatize the 'months'-based overload
so that the 'years'-based overload is selected in case of
equally-ranked implicit conversion sequences to both 'months'
and 'years' from the supplied argument.
(year_month::operator-=): Likewise.
(year_month::operator+): Likewise.
(year_month::operator-): Likewise.
(year_month_day::operator+=): Likewise.
(year_month_day::operator-=): Likewise.
(year_month_day::operator+): Likewise.
(year_month_day::operator-): Likewise.
(year_month_day_last::operator+=): Likewise.
(year_month_day_last::operator-=): Likewise.
(year_month_day_last::operator+): Likewise
(year_month_day_last::operator-): Likewise.
(year_month_day_weekday::operator+=): Likewise
(year_month_day_weekday::operator-=): Likewise.
(year_month_day_weekday::operator+): Likewise.
(year_month_day_weekday::operator-): Likewise.
(year_month_day_weekday_last::operator+=): Likewise
(year_month_day_weekday_last::operator-=): Likewise.
(year_month_day_weekday_last::operator+): Likewise.
(year_month_day_weekday_last::operator-): Likewise.
(testsuite/std/time/year_month/2.cc): New test.
(testsuite/std/time/year_month_day/2.cc): New test.
(testsuite/std/time/year_month_day_last/2.cc): New test.
(testsuite/std/time/year_month_weekday/2.cc): New test.
(testsuite/std/time/year_month_weekday_last/2.cc): New test.

4 years agoia32: Fix alignment of _Atomic fields [PR65146]
Jakub Jelinek [Thu, 27 Aug 2020 16:44:40 +0000 (18:44 +0200)]
ia32: Fix alignment of _Atomic fields [PR65146]

For _Atomic fields, lowering the alignment of long long or double etc.
fields on ia32 is undesirable, because then one really can't perform atomic
operations on those using cmpxchg8b.

The following patch stops lowering the alignment in fields for _Atomic
types (the x86_field_alignment change) and for -mpreferred-stack-boundary=2
also ensures we don't misalign _Atomic long long etc. automatic variables
(the ix86_{local,minimum}_alignment changes).
Not sure about iamcu_alignment change, I know next to nothing about IA MCU,
but unless it doesn't have cmpxchg8b instruction, it would surprise me if we
don't want to do it as well.
clang apparently doesn't lower the field alignment for _Atomic.

2020-08-27  Jakub Jelinek  <jakub@redhat.com>

PR target/65146
* config/i386/i386.c (iamcu_alignment): Don't decrease alignment
for TYPE_ATOMIC types.
(ix86_local_alignment): Likewise.
(ix86_minimum_alignment): Likewise.
(x86_field_alignment): Likewise, and emit a -Wpsabi diagnostic
for it.

* gcc.target/i386/pr65146.c: New test.

4 years agors6000: Support ELFv2 sibcall for indirect calls [PR96787]
Bill Schmidt [Thu, 27 Aug 2020 16:17:06 +0000 (11:17 -0500)]
rs6000: Support ELFv2 sibcall for indirect calls [PR96787]

Prior to P10, ELFv2 hasn't implemented nonlocal sibcalls.  Now that we do,
we need to be sure that r12 is set up prior to such a call.

2020-08-27  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
PR target/96787
* config/rs6000/rs6000.c (rs6000_sibcall_aix): Support
indirect call for ELFv2.

gcc/testsuite/

PR target/96787
* gcc.target/powerpc/pr96787-1.c: New.
* gcc.target/powerpc/pr96787-2.c: New.

4 years agoFortran : ICE for division by zero in declaration PR95882
Mark Eggleston [Fri, 21 Aug 2020 05:39:30 +0000 (06:39 +0100)]
Fortran  : ICE for division by zero in declaration PR95882

A length expression containing a divide by zero in a character
declaration will result in an ICE if the constant is anymore
complicated that a contant divided by a constant.

The cause was that char_len_param_value can return MATCH_YES
even if a divide by zero was seen.  Prior to returning check
whether a divide by zero was seen and if so set it to MATCH_ERROR.

2020-08-27  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/fortran

PR fortran/95882
* decl.c (char_len_param_value): Check gfc_seen_div0 and
if it is set return MATCH_ERROR.

2020-08-27  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/testsuite/

PR fortran/95882
* gfortran.dg/pr95882_1.f90: New test.
* gfortran.dg/pr95882_2.f90: New test.
* gfortran.dg/pr95882_3.f90: New test.
* gfortran.dg/pr95882_4.f90: New test.
* gfortran.dg/pr95882_5.f90: New test.

4 years agotree-optimization/96522 - transfer of flow-sensitive info in copy_ref_info
Richard Biener [Thu, 27 Aug 2020 09:48:15 +0000 (11:48 +0200)]
tree-optimization/96522 - transfer of flow-sensitive info in copy_ref_info

This removes the bogus tranfer of flow-sensitive info in copy_ref_info
plus fixes one oversight in FRE when flow-sensitive non-NULLness was added to
points-to info.

2020-08-27  Richard Biener  <rguenther@suse.de>

PR tree-optimization/96522
* tree-ssa-address.c (copy_ref_info): Reset flow-sensitive
info of the copied points-to.  Transfer bigger alignment
via the access type.
* tree-ssa-sccvn.c (eliminate_dom_walker::eliminate_stmt):
Reset all flow-sensitive info.

* gcc.dg/torture/pr96522.c: New testcase.

4 years agovec: add exact argument for various grow functions.
Martin Liska [Mon, 10 Aug 2020 09:11:05 +0000 (11:11 +0200)]
vec: add exact argument for various grow functions.

gcc/ada/ChangeLog:

* gcc-interface/trans.c (gigi): Set exact argument of a vector
growth function to true.
(Attribute_to_gnu): Likewise.

gcc/ChangeLog:

* alias.c (init_alias_analysis): Set exact argument of a vector
growth function to true.
* calls.c (internal_arg_pointer_based_exp_scan): Likewise.
* cfgbuild.c (find_many_sub_basic_blocks): Likewise.
* cfgexpand.c (expand_asm_stmt): Likewise.
* cfgrtl.c (rtl_create_basic_block): Likewise.
* combine.c (combine_split_insns): Likewise.
(combine_instructions): Likewise.
* config/aarch64/aarch64-sve-builtins.cc (function_expander::add_output_operand): Likewise.
(function_expander::add_input_operand): Likewise.
(function_expander::add_integer_operand): Likewise.
(function_expander::add_address_operand): Likewise.
(function_expander::add_fixed_operand): Likewise.
* df-core.c (df_worklist_dataflow_doublequeue): Likewise.
* dwarf2cfi.c (update_row_reg_save): Likewise.
* early-remat.c (early_remat::init_block_info): Likewise.
(early_remat::finalize_candidate_indices): Likewise.
* except.c (sjlj_build_landing_pads): Likewise.
* final.c (compute_alignments): Likewise.
(grow_label_align): Likewise.
* function.c (temp_slots_at_level): Likewise.
* fwprop.c (build_single_def_use_links): Likewise.
(update_uses): Likewise.
* gcc.c (insert_wrapper): Likewise.
* genautomata.c (create_state_ainsn_table): Likewise.
(add_vect): Likewise.
(output_dead_lock_vect): Likewise.
* genmatch.c (capture_info::capture_info): Likewise.
(parser::finish_match_operand): Likewise.
* genrecog.c (optimize_subroutine_group): Likewise.
(merge_pattern_info::merge_pattern_info): Likewise.
(merge_into_decision): Likewise.
(print_subroutine_start): Likewise.
(main): Likewise.
* gimple-loop-versioning.cc (loop_versioning::loop_versioning): Likewise.
* gimple.c (gimple_set_bb): Likewise.
* graphite-isl-ast-to-gimple.c (translate_isl_ast_node_user): Likewise.
* haifa-sched.c (sched_extend_luids): Likewise.
(extend_h_i_d): Likewise.
* insn-addr.h (insn_addresses_new): Likewise.
* ipa-cp.c (gather_context_independent_values): Likewise.
(find_more_contexts_for_caller_subset): Likewise.
* ipa-devirt.c (final_warning_record::grow_type_warnings): Likewise.
(ipa_odr_read_section): Likewise.
* ipa-fnsummary.c (evaluate_properties_for_edge): Likewise.
(ipa_fn_summary_t::duplicate): Likewise.
(analyze_function_body): Likewise.
(ipa_merge_fn_summary_after_inlining): Likewise.
(read_ipa_call_summary): Likewise.
* ipa-icf.c (sem_function::bb_dict_test): Likewise.
* ipa-prop.c (ipa_alloc_node_params): Likewise.
(parm_bb_aa_status_for_bb): Likewise.
(ipa_compute_jump_functions_for_edge): Likewise.
(ipa_analyze_node): Likewise.
(update_jump_functions_after_inlining): Likewise.
(ipa_read_edge_info): Likewise.
(read_ipcp_transformation_info): Likewise.
(ipcp_transform_function): Likewise.
* ipa-reference.c (ipa_reference_write_optimization_summary): Likewise.
* ipa-split.c (execute_split_functions): Likewise.
* ira.c (find_moveable_pseudos): Likewise.
* lower-subreg.c (decompose_multiword_subregs): Likewise.
* lto-streamer-in.c (input_eh_regions): Likewise.
(input_cfg): Likewise.
(input_struct_function_base): Likewise.
(input_function): Likewise.
* modulo-sched.c (set_node_sched_params): Likewise.
(extend_node_sched_params): Likewise.
(schedule_reg_moves): Likewise.
* omp-general.c (omp_construct_simd_compare): Likewise.
* passes.c (pass_manager::create_pass_tab): Likewise.
(enable_disable_pass): Likewise.
* predict.c (determine_unlikely_bbs): Likewise.
* profile.c (compute_branch_probabilities): Likewise.
* read-rtl-function.c (function_reader::parse_block): Likewise.
* read-rtl.c (rtx_reader::read_rtx_code): Likewise.
* reg-stack.c (stack_regs_mentioned): Likewise.
* regrename.c (regrename_init): Likewise.
* rtlanal.c (T>::add_single_to_queue): Likewise.
* sched-deps.c (init_deps_data_vector): Likewise.
* sel-sched-ir.c (sel_extend_global_bb_info): Likewise.
(extend_region_bb_info): Likewise.
(extend_insn_data): Likewise.
* symtab.c (symtab_node::create_reference): Likewise.
* tracer.c (tail_duplicate): Likewise.
* trans-mem.c (tm_region_init): Likewise.
(get_bb_regions_instrumented): Likewise.
* tree-cfg.c (init_empty_tree_cfg_for_function): Likewise.
(build_gimple_cfg): Likewise.
(create_bb): Likewise.
(move_block_to_fn): Likewise.
* tree-complex.c (tree_lower_complex): Likewise.
* tree-if-conv.c (predicate_rhs_code): Likewise.
* tree-inline.c (copy_bb): Likewise.
* tree-into-ssa.c (get_ssa_name_ann): Likewise.
(mark_phi_for_rewrite): Likewise.
* tree-object-size.c (compute_builtin_object_size): Likewise.
(init_object_sizes): Likewise.
* tree-predcom.c (initialize_root_vars_store_elim_1): Likewise.
(initialize_root_vars_store_elim_2): Likewise.
(prepare_initializers_chain_store_elim): Likewise.
* tree-ssa-address.c (addr_for_mem_ref): Likewise.
(multiplier_allowed_in_address_p): Likewise.
* tree-ssa-coalesce.c (ssa_conflicts_new): Likewise.
* tree-ssa-forwprop.c (simplify_vector_constructor): Likewise.
* tree-ssa-loop-ivopts.c (addr_offset_valid_p): Likewise.
(get_address_cost_ainc): Likewise.
* tree-ssa-loop-niter.c (discover_iteration_bound_by_body_walk): Likewise.
* tree-ssa-pre.c (add_to_value): Likewise.
(phi_translate_1): Likewise.
(do_pre_regular_insertion): Likewise.
(do_pre_partial_partial_insertion): Likewise.
(init_pre): Likewise.
* tree-ssa-propagate.c (ssa_prop_init): Likewise.
(update_call_from_tree): Likewise.
* tree-ssa-reassoc.c (optimize_range_tests_cmp_bitwise): Likewise.
* tree-ssa-sccvn.c (vn_reference_lookup_3): Likewise.
(vn_reference_lookup_pieces): Likewise.
(eliminate_dom_walker::eliminate_push_avail): Likewise.
* tree-ssa-strlen.c (set_strinfo): Likewise.
(get_stridx_plus_constant): Likewise.
(zero_length_string): Likewise.
(find_equal_ptrs): Likewise.
(printf_strlen_execute): Likewise.
* tree-ssa-threadedge.c (set_ssa_name_value): Likewise.
* tree-ssanames.c (make_ssa_name_fn): Likewise.
* tree-streamer-in.c (streamer_read_tree_bitfields): Likewise.
* tree-vect-loop.c (vect_record_loop_mask): Likewise.
(vect_get_loop_mask): Likewise.
(vect_record_loop_len): Likewise.
(vect_get_loop_len): Likewise.
* tree-vect-patterns.c (vect_recog_mask_conversion_pattern): Likewise.
* tree-vect-slp.c (vect_slp_convert_to_external): Likewise.
(vect_bb_slp_scalar_cost): Likewise.
(vect_bb_vectorization_profitable_p): Likewise.
(vectorizable_slp_permutation): Likewise.
* tree-vect-stmts.c (vectorizable_call): Likewise.
(vectorizable_simd_clone_call): Likewise.
(scan_store_can_perm_p): Likewise.
(vectorizable_store): Likewise.
* expr.c: Likewise.
* vec.c (test_safe_grow_cleared): Likewise.
* vec.h (vec_safe_grow): Likewise.
(vec_safe_grow_cleared): Likewise.
(vl_ptr>::safe_grow): Likewise.
(vl_ptr>::safe_grow_cleared): Likewise.
* config/c6x/c6x.c (insn_set_clock): Likewise.

gcc/c/ChangeLog:

* gimple-parser.c (c_parser_gimple_compound_statement): Set exact argument of a vector
growth function to true.

gcc/cp/ChangeLog:

* class.c (build_vtbl_initializer): Set exact argument of a vector
growth function to true.
* constraint.cc (get_mapped_args): Likewise.
* decl.c (cp_maybe_mangle_decomp): Likewise.
(cp_finish_decomp): Likewise.
* parser.c (cp_parser_omp_for_loop): Likewise.
* pt.c (canonical_type_parameter): Likewise.
* rtti.c (get_pseudo_ti_init): Likewise.

gcc/fortran/ChangeLog:

* trans-openmp.c (gfc_trans_omp_do): Set exact argument of a vector
growth function to true.

gcc/lto/ChangeLog:

* lto-common.c (lto_file_finalize): Set exact argument of a vector
growth function to true.

4 years agostreamline TARGET_MEM_REF dumping
Richard Biener [Thu, 27 Aug 2020 11:04:19 +0000 (13:04 +0200)]
streamline TARGET_MEM_REF dumping

The following streamlines TARGET_MEM_REF dumping building
on what we do for MEM_REF and thus dumping things like
access type, TBAA type and base/clique.  I've changed it
to do semantic dumping aka base + offset + step * index
rather than the odd base: A, step: way.

2020-08-27  Richard Biener  <rguenther@suse.de>

* tree-pretty-print.c (dump_mem_ref): Handle TARGET_MEM_REFs.
(dump_generic_node): Use dump_mem_ref also for TARGET_MEM_REF.

* gcc.dg/tree-ssa/loop-19.c: Adjust.
* gcc.dg/tree-ssa/loop-2.c: Likewise.
* gcc.dg/tree-ssa/loop-3.c: Likewise.