Commit Graph

190106 Commits

Author SHA1 Message Date
Martin Liska c2e681059b jit: Initialize function::m_blocks in ctor
This resolves the problem reported here:
https://mail.gnu.org/archive/html/bug-gnu-emacs/2021-11/msg00606.html
https://bugzilla.opensuse.org/show_bug.cgi?id=1192951

gcc/jit/ChangeLog:

	* jit-playback.c (function): Initialize m_blocks vector.
2021-11-24 11:29:15 +01:00
Tobias Burnus be60f80247 Update GMP/MPFR/MPC/ISL version in contrib/download_prerequisites
contrib/
	* download_prerequisites: Update to gmp-6.2.1, mpfr-4.1.0,
	mpc-1.2.1 and isl-0.24.
	* prerequisites.md5: Update hash.
	* prerequisites.sha512: Likewise.
2021-11-24 11:10:06 +01:00
Richard Biener d9ca2ca381 middle-end/103193 - avoid canonicalizing <= and >= to == for floats
This avoids doing aforementioned canoncalization when -ftrapping-math
is in effect and we honor NaNs.

2021-11-15  Richard Biener  <rguenther@suse.de>

	PR middle-end/103193
	* match.pd: Avoid canonicalizing (le/ge @0 @0) to (eq @0 @0)
	with NaNs and -ftrapping-math.
2021-11-24 11:02:13 +01:00
Jakub Jelinek 5bca26742c openmp: Fix up handling of kind(host) and kind(nohost) in ACCEL_COMPILERs [PR103384]
As the testcase shows, we weren't handling kind(host) and kind(nohost) properly
in the ACCEL_COMPILERs, the code written in there is valid for the host
compiler only, where if we are maybe offloaded, we defer resolution after IPA,
otherwise return 0 for kind(nohost) and accept it for kind(host).  Note,
omp_maybe_offloaded is false after IPA.  If ACCEL_COMPILER is defined, it is
the other way around, but also we know we are after IPA.

2021-11-24  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/103384
gcc/
	* omp-general.c (omp_context_selector_matches): For ACCEL_COMPILER,
	return 0 for kind(host) and continue for kind(nohost).
libgomp/
	* testsuite/libgomp.c/declare-variant-2.c: New test.
2021-11-24 10:30:32 +01:00
Jakub Jelinek 709716b9f4 attribs: Fix ICEs on attributes starting with _ [PR103365]
As the patch shows, we have quite a few asserts that we don't call
lookup_attribute etc. with attr_name that starts with an underscore,
to make sure nobody is trying to call it with non-canonicalized
attribute name like "__cold__" instead of "cold".
We canonicalize only attributes that start with 2 underscores and end
with 2 underscores though.
Before Marek's patch, that wasn't an issue, we had no attributes like
"_foo" or "__bar_" etc., so lookup_scoped_attribute_spec would
always return NULL for those and we wouldn't try to register them,
look them up etc., just with -Wattributes would warn about them.
But now, as the new testcases show, users can actually request such
attributes to be ignored, and we ICE for those during
register_scoped_attribute and when that is fixed, ICE later on when
somebody uses those attributes because they will be looked up
to find out that they should be ignored.

So, the following patch instead of or in addition to, depending on
how performance sensitive a particular spot is, checking that
attribute doesn't start with underscore allows attribute
names that start with underscore as long as it doesn't canonicalize
(i.e. doesn't start and end with 2 underscores).
In addition to that, I've noticed lookup_attribute_by_prefix
was calling get_attribute_name twice unnecessarily, and 2 tests
were running in c++98 mode with -std=c++98 -std=c++11 which IMHO
isn't useful because -std=c++11 testing is done too when testing
all language versions.

2021-11-24  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/103365
	* attribs.h (lookup_attribute): Allow attr_name to start with
	underscore, as long as canonicalize_attr_name returns false.
	(lookup_attribute_by_prefix): Don't call get_attribute_name twice.
	* attribs.c (extract_attribute_substring): Reimplement using
	canonicalize_attr_name.
	(register_scoped_attribute): Change gcc_assert into
	gcc_checking_assert, verify !canonicalize_attr_name rather than
	that str.str doesn't start with '_'.

	* c-c++-common/Wno-attributes-1.c: Require effective target
	c || c++11 and drop dg-additional-options.
	* c-c++-common/Wno-attributes-2.c: Likewise.
	* c-c++-common/Wno-attributes-4.c: New test.
	* c-c++-common/Wno-attributes-5.c: New test.
2021-11-24 10:08:35 +01:00
Jakub Jelinek 04eccbbe3d bswap: Fix up symbolic merging for xor and plus [PR103376]
On Mon, Nov 22, 2021 at 08:39:42AM -0000, Roger Sayle wrote:
> This patch implements PR tree-optimization/103345 to merge adjacent
> loads when combined with addition or bitwise xor.  The current code
> in gimple-ssa-store-merging.c's find_bswap_or_nop alreay handles ior,
> so that all that's required is to treat PLUS_EXPR and BIT_XOR_EXPR in
> the same way at BIT_IOR_EXPR.

Unfortunately they aren't exactly the same.  They work the same if always
at least one operand (or corresponding byte in it) is known to be 0,
0 | 0 = 0 ^ 0 = 0 + 0 = 0.  But for | also x | x = x for any other x,
so perform_symbolic_merge has been accepting either that at least one
of the bytes is 0 or that both are the same, but that is wrong for ^
and +.

The following patch fixes that by passing through the code of binary
operation and allowing non-zero masked1 == masked2 through only
for BIT_IOR_EXPR.

Thinking more about it, perhaps we could do more for BIT_XOR_EXPR.
We could allow masked1 == masked2 case for it, but would need to
do something different than the
  n->n = n1->n | n2->n;
we do on all the bytes together.
In particular, for masked1 == masked2 if masked1 != 0 (well, for 0
both variants are the same) and masked1 != 0xff we would need to
clear corresponding n->n byte instead of setting it to the input
as x ^ x = 0 (but if we don't know what x and y are, the result is
also don't know).  Now, for plus it is much harder, because not only
for non-zero operands we don't know what the result is, but it can
modify upper bytes as well.  So perhaps only if current's byte
masked1 && masked2 set the resulting byte to 0xff (unknown) iff
the byte above it is 0 and 0, and set that resulting byte to 0xff too.
Also, even for | we could instead of return NULL just set the resulting
byte to 0xff if it is different, perhaps it will be masked off later on.

2021-11-24  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/103376
	* gimple-ssa-store-merging.c (perform_symbolic_merge): Add CODE
	argument.  If CODE is not BIT_IOR_EXPR, ensure that one of masked1
	or masked2 is 0.
	(find_bswap_or_nop_1, find_bswap_or_nop,
	imm_store_chain_info::try_coalesce_bswap): Adjust
	perform_symbolic_merge callers.

	* gcc.c-torture/execute/pr103376.c: New test.
2021-11-24 09:54:44 +01:00
Richard Biener 52554dde7b Avoid redundant get_loop_body calls in IVOPTs
This removes redundant get_loop_body calls in IVOPTs by passing
around the body we're gathering early.

2021-11-23  Richard Biener  <rguenther@suse.de>

	* tree-ssa-loop-ivopts.c (find_givs): Take loop body as
	argument instead of re-computing it.
	(find_interesting_uses): Likewise.
	(find_induction_variables): Pass through loop body.
	(tree_ssa_iv_optimize_loop): Pass down loop body.
2021-11-24 09:03:05 +01:00
Tamar Christina 755c2e7d71 middle-end: Fix failures with bitclear patterns on signed values
During testing after rebasing to commit I noticed a failing testcase with the
bitmask compare patch.

Consider the following C++ testcase:

#include <compare>

#define A __attribute__((noipa))
A bool f5 (double i, double j) { auto c = i <=> j; return c >= 0; }

This turns into a comparison against chars, on systems where chars are signed
the pattern inserts an unsigned convert such that it's able to do the
transformation.

i.e.:

  # RANGE [-1, 2]
  # c$_M_value_22 = PHI <-1(3), 0(2), 2(5), 1(4)>
  # RANGE ~[3, 254]
  _11 = (unsigned char) c$_M_value_22;
  _19 = _11 <= 1;
  # .MEM_24 = VDEF <.MEM_6(D)>
  D.10434 ={v} {CLOBBER};
  # .MEM_14 = VDEF <.MEM_24>
  D.10407 ={v} {CLOBBER};
  # VUSE <.MEM_14>
  return _19;

instead of:

  # RANGE [-1, 2]
  # c$_M_value_5 = PHI <-1(3), 0(2), 2(5), 1(4)>
  # RANGE [-2, 2]
  _3 = c$_M_value_5 & -2;
  _19 = _3 == 0;
  # .MEM_24 = VDEF <.MEM_6(D)>
  D.10440 ={v} {CLOBBER};
  # .MEM_14 = VDEF <.MEM_24>
  D.10413 ={v} {CLOBBER};
  # VUSE <.MEM_14>
  return _19;

This causes much worse codegen under -ffast-math due to phiops no longer
recognizing the pattern.  It turns out that phiopts spaceship_replacement is
looking for the exact form that was just changed.

The comments seems to suggest this code only checks for (res & ~1) == 0 but the
implementation seems to suggest it's broader.

As such I added a case to check to see if the value comparison we found is a
type cast.  and strips away the type cast and continues.

In match.pd the typecasts are only added for signed comparisons to == 0 and != 0
which are then rewritten into comparisons with 1.

As such I only check for 1 and LE and GT, which is what match.pd would have
rewritten it to.

This fixes the regression but this is not code I 100% understand, since I don't
really know the semantics of the spaceship operator so would appreciate an extra
look.

gcc/ChangeLog:

	* tree-ssa-phiopt.c (spaceship_replacement): Handle new canonical
	codegen.
2021-11-24 06:39:05 +00:00
Tamar Christina 0888d6bbe9 middle-end: Convert bitclear <imm> + cmp<cc> #0 into cm<cc2> <imm2>
This optimizes the case where a mask Y which fulfills ~Y + 1 == pow2 is used to
clear a some bits and then compared against 0 into one without the masking and
a compare against a different bit immediate.

We can do this for all unsigned compares and for signed we can do it for
comparisons of EQ and NE:

(x & (~255)) == 0 becomes x <= 255. Which for leaves it to the target to
optimally deal with the comparison.

This transformation has to be done in the mid-end because in RTL you don't have
the signs of the comparison operands and if the target needs an immediate this
should be floated outside of the loop.

The RTL loop invariant hoisting is done before split1.

i.e.

void fun1(int32_t *x, int n)
{
    for (int i = 0; i < (n & -16); i++)
      x[i] = (x[i]&(~255)) == 0;
}

now generates:

.L3:
        ldr     q0, [x0]
        cmhs    v0.4s, v2.4s, v0.4s
        and     v0.16b, v1.16b, v0.16b
        str     q0, [x0], 16
        cmp     x0, x1
        bne     .L3

and floats the immediate out of the loop.

instead of:

.L3:
        ldr     q0, [x0]
        bic     v0.4s, #255
        cmeq    v0.4s, v0.4s, #0
        and     v0.16b, v1.16b, v0.16b
        str     q0, [x0], 16
        cmp     x0, x1
        bne     .L3

In order to not break IVopts and CSE I have added a
requirement for the scalar version to be single use.

gcc/ChangeLog:

	* tree.c (bitmask_inv_cst_vector_p): New.
	* tree.h (bitmask_inv_cst_vector_p): New.
	* match.pd: Use it in new bitmask compare pattern.

gcc/testsuite/ChangeLog:

	* gcc.dg/bic-bitmask-10.c: New test.
	* gcc.dg/bic-bitmask-11.c: New test.
	* gcc.dg/bic-bitmask-12.c: New test.
	* gcc.dg/bic-bitmask-13.c: New test.
	* gcc.dg/bic-bitmask-14.c: New test.
	* gcc.dg/bic-bitmask-15.c: New test.
	* gcc.dg/bic-bitmask-16.c: New test.
	* gcc.dg/bic-bitmask-17.c: New test.
	* gcc.dg/bic-bitmask-18.c: New test.
	* gcc.dg/bic-bitmask-19.c: New test.
	* gcc.dg/bic-bitmask-2.c: New test.
	* gcc.dg/bic-bitmask-20.c: New test.
	* gcc.dg/bic-bitmask-21.c: New test.
	* gcc.dg/bic-bitmask-22.c: New test.
	* gcc.dg/bic-bitmask-23.c: New test.
	* gcc.dg/bic-bitmask-3.c: New test.
	* gcc.dg/bic-bitmask-4.c: New test.
	* gcc.dg/bic-bitmask-5.c: New test.
	* gcc.dg/bic-bitmask-6.c: New test.
	* gcc.dg/bic-bitmask-7.c: New test.
	* gcc.dg/bic-bitmask-8.c: New test.
	* gcc.dg/bic-bitmask-9.c: New test.
	* gcc.dg/bic-bitmask.h: New test.
	* gcc.target/aarch64/bic-bitmask-1.c: New test.
2021-11-24 06:38:18 +00:00
Marek Polacek d71d019f63 c++: Fix missing NSDMI diagnostic in C++98 [PR103347]
Here the problem is that we aren't detecting a NSDMI in C++98:

struct A {
  void *x = NULL;
};

because maybe_warn_cpp0x uses input_location and that happens to point
to NULL which comes from a system header.  Jakub suggested changing the
location to the '=', thereby avoiding the system header problem.  To
that end, I've added a new location_t member into cp_declarator.  This
member is used when this declarator is part of an init-declarator.  The
rest of the changes is obvious.  I've also taken the liberty of adding
loc_or_input_loc, since I want to avoid checking for UNKNOWN_LOCATION.

	PR c++/103347

gcc/cp/ChangeLog:

	* cp-tree.h (struct cp_declarator): Add a location_t member.
	(maybe_warn_cpp0x): Add a location_t parameter with a default argument.
	(loc_or_input_loc): New.
	* decl.c (grokdeclarator): Use loc_or_input_loc.  Pass init_loc down
	to maybe_warn_cpp0x.
	* error.c (maybe_warn_cpp0x): Add a location_t parameter.  Use it.
	* parser.c (make_declarator): Initialize init_loc.
	(cp_parser_member_declaration): Set init_loc.
	(cp_parser_condition): Likewise.
	(cp_parser_init_declarator): Likewise.
	(cp_parser_parameter_declaration): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/nsdmi-warn1.C: New test.
	* g++.dg/cpp0x/nsdmi-warn1.h: New file.
2021-11-24 00:22:10 -05:00
Jason Merrill 9bf69a8558 timevar: Add auto_cond_timevar class
The auto_timevar sentinel class for starting and stopping timevars was added
in 2014, but doesn't work for the many uses of timevar_cond_start/stop in
the C++ front end.  So let's add one that does.

This allows us to remove a lot of wrapper functions that were just used to
call timevar_cond_stop on all exits from the function.

gcc/ChangeLog:

	* timevar.h (class auto_cond_timevar): New.

gcc/cp/ChangeLog:

	* call.c
	* decl.c
	* name-lookup.c:
	Use auto_cond_timevar instead of timevar_cond_start/stop.
	Remove wrapper functions.
2021-11-23 20:25:47 -05:00
liuhongt 7df89377a7 Enhance optimize_atomic_bit_test_and to handle truncation.
r12-5102-gfb161782545224f5 improves integer bit test on
__atomic_fetch_[or|and]_* returns only for nop_convert, .i.e.

transfrom

  mask_5 = 1 << bit_4(D);
  mask.0_1 = (unsigned int) mask_5;
  _2 = __atomic_fetch_or_4 (a_7(D), mask.0_1, 0);
  t1_9 = (int) _2;
  t2_10 = mask_5 & t1_9;

to

  mask_5 = 1 << n_4(D);
  mask.1_1 = (unsigned int) mask_5;
  _11 = .ATOMIC_BIT_TEST_AND_SET (&pscc_a_1_4, n_4(D), 0);
  _8 = (int) _11;

And this patch extend the original patch to handle truncation.
.i.e.

transform

  long int mask;
  mask_8 = 1 << n_7(D);
  mask.0_1 = (long unsigned int) mask_8;
  _2 = __sync_fetch_and_or_8 (&pscc_a_2_3, mask.0_1);
  _3 = (unsigned int) _2;
  _4 = (unsigned int) mask_8;
  _5 = _3 & _4;
  _6 = (int) _5;

to

  long int mask;
  mask_8 = 1 << n_7(D);
  mask.0_1 = (long unsigned int) mask_8;
  _14 = .ATOMIC_BIT_TEST_AND_SET (&pscc_a_2_3, n_7(D), 0);
  _5 = (unsigned int) _14;
  _6 = (int) _5;

2021-11-17  Hongtao Liu  <hongtao.liu@intel.com>
	    H.J. Lu  <hongjiu.lu@intel.com>

gcc/ChangeLog:

	PR tree-optimization/103194
	* match.pd (gimple_nop_atomic_bit_test_and_p): Extended to
	match truncation.
	* tree-ssa-ccp.c (gimple_nop_convert): Declare.
	(optimize_atomic_bit_test_and): Enhance
	optimize_atomic_bit_test_and to handle truncation.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr103194-2.c: New test.
	* gcc.target/i386/pr103194-3.c: New test.
	* gcc.target/i386/pr103194-4.c: New test.
	* gcc.target/i386/pr103194-5.c: New test.
	* gcc.target/i386/pr103194.c: New test.
2021-11-24 09:00:58 +08:00
GCC Administrator e1d4359264 Daily bump. 2021-11-24 00:16:29 +00:00
Martin Sebor 2dd56aed3e Issue -Waddress also for reference members [PR96507].
Resolves:
PR c++/96507 - missing -Waddress for member references

gcc/cp/ChangeLog:

	PR c++/96507
	* typeck.c (warn_for_null_address): Handle reference members.

gcc/testsuite/ChangeLog:

	PR c++/96507
	* g++.dg/warn/Waddress-8.C: New test.
2021-11-23 15:36:03 -07:00
Martin Sebor 30ba058f77 Implement -Winfinite-recursion [PR88232].
Resolves:
PR middle-end/88232 - Please implement -Winfinite-recursion

gcc/ChangeLog:

	PR middle-end/88232
	* Makefile.in (OBJS): Add gimple-warn-recursion.o.
	* common.opt: Add -Winfinite-recursion.
	* doc/invoke.texi (-Winfinite-recursion): Document.
	* passes.def (pass_warn_recursion): Schedule a new pass.
	* tree-pass.h (make_pass_warn_recursion): Declare.
	* gimple-warn-recursion.c: New file.

gcc/c-family/ChangeLog:

	PR middle-end/88232
	* c.opt: Add -Winfinite-recursion.

gcc/testsuite/ChangeLog:

	PR middle-end/88232
	* c-c++-common/attr-used-5.c: Suppress valid warning.
	* c-c++-common/attr-used-6.c: Same.
	* c-c++-common/attr-used-9.c: Same.
	* g++.dg/warn/Winfinite-recursion-2.C: New test.
	* g++.dg/warn/Winfinite-recursion-3.C: New test.
	* g++.dg/warn/Winfinite-recursion.C: New test.
	* gcc.dg/Winfinite-recursion-2.c: New test.
	* gcc.dg/Winfinite-recursion.c: New test.
2021-11-23 15:36:03 -07:00
Jonathan Wakely c59ec55c34 libstdc++: Add another testcase for std::unique_ptr printer [PR103086]
libstdc++-v3/ChangeLog:

	PR libstdc++/103086
	* testsuite/libstdc++-prettyprinters/cxx11.cc: Check unique_ptr
	with non-empty pointer and non-empty deleter.
2021-11-23 21:39:46 +00:00
Jonathan Wakely 39de0e5411 libstdc++: Add effective-target for std::allocator implementation
This allows tests to be skipped if the std::allocator implementation is
not __gnu_cxx::new_allocator.

The 20_util/allocator/overaligned.cc test requires either C++17 or
new_allocator, otherwise we can't guarantee to return overaligned
memory.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/50594.cc: Check effective target.
	* testsuite/20_util/allocator/1.cc: Likewise.
	* testsuite/20_util/allocator/overaligned.cc: Likewise.
	* testsuite/23_containers/unordered_map/96088.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/96088.cc: Likewise.
	* testsuite/23_containers/unordered_multiset/96088.cc: Likewise.
	* testsuite/23_containers/unordered_set/96088.cc: Likewise.
	* testsuite/ext/throw_allocator/check_delete.cc: Likewise.
	* testsuite/ext/throw_allocator/check_new.cc: Likewise.
	* testsuite/lib/libstdc++.exp (check_effective_target_std_allocator_new):
	Define new proc.
2021-11-23 21:23:24 +00:00
Harald Anlauf 16e95050f7 Fortran: do not attempt simplification of [LU]BOUND for pointer/allocatable
gcc/fortran/ChangeLog:

	PR fortran/103392
	* simplify.c (simplify_bound): Do not try to simplify
	LBOUND/UBOUND for arrays with POINTER or ALLOCATABLE attribute.

gcc/testsuite/ChangeLog:

	PR fortran/103392
	* gfortran.dg/bound_simplification_7.f90: New test.
2021-11-23 22:02:40 +01:00
Marek Polacek 4b1d3d8d73 c++: -Wuninitialized for mem-inits and empty classes [PR19808]
This fixes a bogus -Wuninitialized warning: there's nothing to initialize
in empty classes, so don't add them into our uninitialized set.

	PR c++/19808

gcc/cp/ChangeLog:

	* init.c (emit_mem_initializers): Don't add is_really_empty_class
	members into uninitialized.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wuninitialized-28.C: Make a class nonempty.
	* g++.dg/warn/Wuninitialized-29.C: Likewise.
	* g++.dg/warn/Wuninitialized-31.C: New test.
2021-11-23 15:02:08 -05:00
Marek Polacek 7b7318faf7 c++: Add static in g++.dg/warn/Waddress-5.C
While reviewing some other changes I noticed that this test talks
about 'sf' being static, but it wasn't actually marked as such.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Waddress-5.C: Make sf static.
2021-11-23 14:28:48 -05:00
Xi Ruoyao 3363022ed8
fixincludes: don't abort() on access failure [PR103306]
Some distro may ship dangling symlinks in include directories, triggers
the access failure.  Skip it and continue to next header instead of
being to panic.

Restore to old behavior before r12-5234 but without resurrecting the
problematic getcwd() call, by using the environment variable "INPUT"
exported by fixinc.sh.

Tested on x86_64-linux-gnu, with a dangling symlink intentionally
injected into /usr/include.

fixincludes/

	PR bootstrap/103306
	* fixincl.c (process): Don't call abort().
2021-11-24 03:18:38 +08:00
Bill Schmidt d6024c85a1 rs6000: Better error messages for power8/9 vector builtins
2021-11-11  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
	* config/rs6000/rs6000-call.c (rs6000_invalid_new_builtin): Change
	error messages for ENB_P8V and ENB_P9V.
2021-11-23 13:17:02 -06:00
Bill Schmidt c2c534f6fa rs6000: Add [power6-64] stanza to new builtin support
2021-11-23  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
	* config/rs6000/rs6000-builtin-new.def: Add power6-64 stanza.  Move
	CMPB to power6-64 stanza.
	* config/rs6000/rs6000-call.c (rs6000_invalid_new_builtin): Handle
	ENB_P6_64 case.
	(rs6000_new_builtin_is_supported): Likewise.
	(rs6000_expand_new_builtin): Likewise.  Clean up formatting.
	(rs6000_init_builtins): Handle ENB_P6_64 case.
	* config/rs6000/rs6000-gen-builtins.c (bif_stanza): Add	BSTZ_P6_64.
	(stanza_map): Add entry mapping power6-64 to BSTZ_P6_64.
	(enable_string): Add "ENB_P6_64".
	(write_decls): Add ENB_P6_64 to bif_enable enum.
2021-11-23 13:16:58 -06:00
Bill Schmidt e6a6569ce2 rs6000: Fix test_mffsl.c effective target check
Paul Clarke pointed out to me that I had wrongly used a compile-time check
instead of a run-time check in this executable test.  This patch fixes
that.  I also fixed a typo in a string that caught my eye.

2021-11-23  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/testsuite/
	* gcc.target/powerpc/test_mffsl.c: Change effective target to
	a run-time check.  Fix a typo in a debug print statement.
2021-11-23 12:56:57 -06:00
Harald Anlauf 721d8b9e26 Fortran: fix scalarization for intrinsic LEN_TRIM with present KIND argument
gcc/fortran/ChangeLog:

	PR fortran/87711
	PR fortran/87851
	* trans-array.c (arg_evaluated_for_scalarization): Add LEN_TRIM to
	list of intrinsics for which an optional KIND argument needs to be
	removed before scalarization.

gcc/testsuite/ChangeLog:

	PR fortran/87711
	PR fortran/87851
	* gfortran.dg/len_trim.f90: New test.
2021-11-23 17:51:38 +01:00
Christophe Lyon 46d3cfd29d libcpp: Fix ATTR_LIKELY definition PR preprocessor/103355
Fix the definition of ATTR_LIKELY when __has_cpp_attribute is not
defined, as it is the case with old compilers such as gcc-4.8.5.

	libcpp/:
	PR preprocessor/103355
	* system.h (ATTR_LIKELY): Fix definition.
2021-11-23 16:06:42 +00:00
Jan Hubicka 8632f8c65d Remove duplicated param valud in modref tree
Modref tree template stores its own copy of param_moderf_max_bases, *_max_refs
and *_max_accesses values.  This was done before we had per-function limits and
even back then it was bit dubious, so this patch removes it.

gcc/ChangeLog:

	* ipa-modref-tree.h (struct modref_tree): Remove max_bases, max_refs
	and max_accesses.
	(modref_tree::modref_tree): Remove parametr.
	(modref_tree::insert_base): Add max_bases parameter.
	(modref_tree::insert): Add max_bases, max_refs, max_accesses
	parameters.
	(modref_tree::insert): New member function.
	(modref_tree::merge): Add max_bases, max_refs, max_accesses
	parameters.
	(modref_tree::insert): New member function.
	* ipa-modref-tree.c (test_insert_search_collapse): Update.
	(test_merge): Update.
	* ipa-modref.c (dump_records): Don't dump max_refs and max_bases.
	(dump_lto_records): Likewise.
	(modref_summary::finalize): Fix whitespace.
	(get_modref_function_summary): Likewise.
	(modref_access_analysis::record_access): Update.
	(modref_access_analysis::record_access_lto): Update.
	(modref_access_analysis::process_fnspec): Update.
	(analyze_function): Update.
	(modref_summaries::duplicate): Update.
	(modref_summaries_lto::duplicate): Update.
	(write_modref_records): Update.
	(read_modref_records): Update.
	(read_section): Update.
	(propagate_unknown_call): Update.
	(modref_propagate_in_scc): Update.
	(ipa_merge_modref_summary_after_inlining): Update.
2021-11-23 16:36:01 +01:00
Jonathan Wakely 5459fa132a libstdc++: Fix circular dependency for bitmap_allocator [PR103381]
<ext/bitmap_allocator.h> includes <function>, and since C++17 that
includes <unordered_map>. If std::allocator is defined in terms of
__gnu_cxx::bitmap_allocator then you get a circular reference and
bootstrap fails when compiling src/c++17/*.cc.

libstdc++-v3/ChangeLog:

	PR libstdc++/103381
	* include/ext/bitmap_allocator.h: Include <bits/stl_function.h>
	instead of <functional>.
2021-11-23 12:30:57 +00:00
Martin Liska d3f22853d1 docs: Remove 2 more duplicite param descriptions.
gcc/ChangeLog:

	* doc/invoke.texi: Remove 2 more duplicite param descriptions.
2021-11-23 11:27:29 +01:00
Richard Biener 6cd4406700 tree-optimization/103361 - fix unroll-and-jam direction vector handling
This properly uses lambda_int instead of truncating the direction
vector to int which leads to false unexpected negative values.

2021-11-23  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/103361
	* gimple-loop-jam.c (adjust_unroll_factor): Use lambda_int
	for the dependence distance.
	* tree-data-ref.c (print_lambda_vector): Properly print a lambda_int.

	* g++.dg/torture/pr103361.C: New testcase.
2021-11-23 11:04:34 +01:00
Jakub Jelinek 2780484bc3 inliner: Remove unused transform_lang_insert_block hook
This struct copy_body_data's hook is always NULL since merge
of the tuples branch, before that it has been shortly used by the C++
FE during ctor/dtor cloning to chain the remapped blocks, but only
very shortly, before transform_lang_insert_block was a bool and
the call to insert_block was done through a langhook.
I'd say that for something that hasn't been used since 4.4 there is
zero chance we'll want to use it again in the near future.

2021-11-23  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* tree-inline.h (struct copy_body_data): Remove
	transform_lang_insert_block member.
	* tree-inline.c (remap_block): Don't call
	id->transform_lang_insert_block.
	(optimize_inline_calls, copy_gimple_seq_and_replace_locals,
	tree_function_versioning, maybe_inline_call_in_expr,
	copy_fn): Don't initialize id.transform_lang_insert_block.
	* gimplify.c (gimplify_omp_loop): Likewise.
gcc/c/
	* c-typeck.c (c_clone_omp_udr): Don't initialize
	id.transform_lang_insert_block.
gcc/cp/
	* semantics.c (clone_omp_udr): Don't initialize
	id.transform_lang_insert_block.
	* optimize.c (clone_body): Likewise.
2021-11-23 11:03:44 +01:00
Jan Hubicka 6033b27ead Improve bytewise DSE
testcase modref-dse-4.c and modref-dse-5.c fails on some targets because they
depend on store merging.  What really happens is that without store merging
we produce for kill_me combined write that is ao_ref with offset=0, size=32
and max_size=96.  We have size != max_size becaue we do ont track the info that
all 3 writes must happen in a group and conider case only some of them are done.

This disables byte-wise DSE which checks that size == max_size.  This is
completely unnecesary for store being proved to be dead or load being checked
to not read live bytes.  It is only necessary for kill store that is used to
prove that given store is dead.

While looking into this I also noticed that we check that everything is byte
aligned.  This is also unnecessary and with access merging in modref may more
commonly fire on accesses that we could otherwise handle.

This patch fixes both also also changes interface to normalize_ref that I found
confusing since it modifies the ref. Instead of that we have get_byte_range
that is computing range in bytes (since that is what we need to maintain the
bitmap) and has additional parameter specifying if the store in question should
be turned into sub-range or super-range depending whether we compute range
for kill or load.

gcc/ChangeLog:

2021-11-23  Jan Hubicka  <hubicka@ucw.cz>

	PR tree-optimization/103335
	* tree-ssa-dse.c (valid_ao_ref_for_dse): Rename to ...
	(valid_ao_ref_kill_for_dse): ... this; do not check that boundaries
	are divisible by BITS_PER_UNIT.
	(get_byte_aligned_range_containing_ref): New function.
	(get_byte_aligned_range_contained_in_ref): New function.
	(normalize_ref): Rename to ...
	(get_byte_range): ... this one; handle accesses not aligned to byte
	boundary; return range in bytes rater than updating ao_ref.
	(clear_live_bytes_for_ref): Take write ref by reference; simplify using
	get_byte_access.
	(setup_live_bytes_from_ref): Likewise.
	(clear_bytes_written_by): Update.
	(live_bytes_read): Update.
	(dse_classify_store): Simplify tech before live_bytes_read checks.

gcc/testsuite/ChangeLog:

2021-11-23  Jan Hubicka  <hubicka@ucw.cz>

	* gcc.dg/tree-ssa/modref-dse-4.c: Update template.
	* gcc.dg/tree-ssa/modref-dse-5.c: Update template.
2021-11-23 10:57:14 +01:00
Andrew Pinski 911b633803 Canonicalize &MEM[ssa_n, CST] to ssa_n p+ CST in fold_stmt_1
This is a new version of the patch to fix PR 102216.
Instead of doing the canonicalization inside forwprop, Richi
mentioned we should do it inside fold_stmt_1 and that is what
this patch does.

	PR tree-optimization/102216

gcc/ChangeLog:

	* gimple-fold.c (fold_stmt_1): Add canonicalization
	of "&MEM[ssa_n, CST]" to "ssa_n p+ CST", note this
	can only be done if !in_place.

gcc/testsuite/ChangeLog:

	* g++.dg/tree-ssa/pr102216-1.C: New test.
	* g++.dg/tree-ssa/pr102216-2.C: New test.
2021-11-23 09:55:47 +00:00
Jakub Jelinek 5e9b973bd6 openmp: Fix up handling of reduction clauses on the loop construct [PR102431]
We were using unshare_expr and walk_tree_without_duplicate replacement
of the placeholder vars.  The OMP_CLAUSE_REDUCTION_{INIT,MERGE} can contain
other trees that need to be duplicated though, e.g. BLOCKs referenced in
BIND_EXPR(s), or local VAR_DECLs.  This patch uses the inliner code to copy
all of that.  There is a slight complication that those local VAR_DECLs or
placeholders don't have DECL_CONTEXT set, they will get that only when
they are gimplified later on, so this patch sets DECL_CONTEXT for those
temporarily and resets it afterwards.

2021-11-23  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/102431
	* gimplify.c (replace_reduction_placeholders): Remove.
	(note_no_context_vars): New function.
	(gimplify_omp_loop): For OMP_PARALLEL's BIND_EXPR create a new
	BLOCK.  Use copy_tree_body_r with walk_tree instead of unshare_expr
	and replace_reduction_placeholders for duplication of
	OMP_CLAUSE_REDUCTION_{INIT,MERGE} expressions.  Ensure all mentioned
	automatic vars have DECL_CONTEXT set to non-NULL before doing so
	and reset it afterwards for those vars and their corresponding
	vars.

	* c-c++-common/gomp/pr102431.c: New test.
	* g++.dg/gomp/pr102431.C: New test.
	* gfortran.dg/gomp/pr102431.f90: New test.
2021-11-23 10:30:02 +01:00
Haochen Gui f4eae6450e rs6000: Optimize code generation of vec_reve [PR100868]
gcc/
	PR target/100868
	* config/rs6000/altivec.md (altivec_vreve<mode>2 for VEC_K): Use
	xxbrq for v16qi, xxbrq + xxbrh for v8hi and xxbrq + xxbrw for v4si
	or v4sf when p9_vector is set.
	(altivec_vreve<mode>2 for VEC_64): Defined. Implemented by xxswapd.

gcc/testsuite/
	PR target/100868
	* gcc.target/powerpc/vec_reve_1.c: New test.
	* gcc.target/powerpc/vec_reve_2.c: Likewise.
2021-11-23 16:31:59 +08:00
Martin Liska 1ddf11d364 contrib: filter out -Wc++20-extensions
contrib/ChangeLog:

	* filter-clang-warnings.py: Filter -Wc++20-extensions as it does
	not respect proper attribute detection.
2021-11-23 08:36:54 +01:00
Martin Liska cab8f69857 contrib: Support itemx in check-params-in-docs.py.
contrib/ChangeLog:

	* check-params-in-docs.py: Support @itemx in param documentation
	and support multi-line documentation for parameters.
2021-11-23 08:26:51 +01:00
Navid Rahimi df1a0d526e Re: [PATCH] PR tree-optimization/102232 Adding a missing pattern to match.pd
PR tree-optimization/102232

gcc/
	* match.pd (x * (1 + y / x) - y) -> (x - y % x): New optimization.

gcc/testsuite/

	* gcc.dg/tree-ssa/pr102232.c: Testcase for this optimization.
2021-11-22 22:07:35 -05:00
Marek Polacek 630686f93f libcpp: Use [[likely]] conditionally
Let's hide [[likely]] behind a macro, to suppress warnings if the
compiler doesn't support it.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>

	PR preprocessor/103355

libcpp/ChangeLog:

	* lex.c: Use ATTR_LIKELY instead of [[likely]].
	* system.h (ATTR_LIKELY): Define.
2021-11-22 21:43:38 -05:00
Navid Rahimi e888bea238 Re: [PATCH] PR tree-optimization/96779 Adding a missing pattern to match.pd
PR tree-optimization/96779
gcc/
	* match.pd (-x == x) -> (x == 0): New optimization.

gcc/testsuite
	* gcc.dg/tree-ssa/pr96779.c: Testcase for this optimization.
	* gcc.dg/tree-ssa/pr96779-disabled.c: Testcase for this optimization
	when -fwrapv passed.
2021-11-22 19:48:04 -05:00
GCC Administrator 06be28f64a Daily bump. 2021-11-23 00:16:27 +00:00
Jason Merrill 1df539fd19 c++: remember pointer-to-member location
Jakub recently mentioned that a PTRMEM_CST has no location; let's give it a
location wrapper.

gcc/cp/ChangeLog:

	* typeck.c (build_x_unary_op): Set address location.
	(convert_member_func_to_ptr): Handle location wrapper.
	* pt.c (convert_nontype_argument): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/template/crash106.C: Adjust.
	* g++.dg/diagnostic/ptrtomem3.C: New test.
2021-11-22 17:43:10 -05:00
Jason Merrill 5440c88e61 c++: improved return expression location
Stripping the location wrapper from retval meant we didn't have the
necessary location information for any conversion diagnostics.  We only need
the stripping for the named return value optimization, let's use the
unstripped expression for everything else.

gcc/cp/ChangeLog:

	* typeck.c (check_return_expr): Only strip location wrapper during
	NRV handling.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/pr65327.C: Adjust location.
	* g++.dg/cpp23/constexpr-nonlit4.C: Likewise.
	* g++.dg/cpp23/constexpr-nonlit5.C: Likewise.
	* g++.dg/cpp2a/constexpr-init1.C: Likewise.
2021-11-22 17:42:53 -05:00
Jakub Jelinek a6e0d59370 libcpp: Fix _Pragma stringification [PR103165]
As the testcase show, sometimes _Pragma is turned into CPP_PRAGMA
.. CPP_PRAGMA_EOL tokens, even when it might still need to be
stringized later on.  We are then ICEing because we don't handle
stringification of CPP_PRAGMA or CPP_PRAGMA_EOL, but trying to
reconstruct the exact tokens with exact spacing after it has been
lowered is very hard.  So, instead this patch ensures we don't
lower _Pragma during expand_arg calls, but only later when
cpp_get_token_1 is called outside of expand_arg.

2021-11-22  Jakub Jelinek  <jakub@redhat.com>
	    Tobias Burnus  <tobias@codesourcery.com>

	PR preprocessor/103165
libcpp/
	* internal.h (struct lexer_state): Add ignore__Pragma field.
	* macro.c (builtin_macro): Don't interpret _Pragma if
	pfile->state.ignore__Pragma.
	(expand_arg): Temporarily set pfile->state.ignore__Pragma to 1.
gcc/testsuite/
	* c-c++-common/gomp/pragma-3.c: New test.
	* c-c++-common/gomp/pragma-4.c: New test.
	* c-c++-common/gomp/pragma-5.c: New test.

Co-Authored-By: Tobias Burnus <tobias@codesourcery.com>
2021-11-22 22:29:20 +01:00
Roger Sayle a944b5dec3 tree-optimization/103345: Improved load merging.
This patch implements PR tree-optimization/103345 to merge adjacent
loads when combined with addition or bitwise xor.  The current code
in gimple-ssa-store-merging.c's find_bswap_or_nop alreay handles ior,
so that all that's required is to treat PLUS_EXPR and BIT_XOR_EXPR in
the same way at BIT_IOR_EXPR.  Many thanks to Andrew Pinski for
pointing out that this also resolves PR target/98953.

2021-11-22  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	PR tree-optimization/98953
	PR tree-optimization/103345
	* gimple-ssa-store-merging.c (find_bswap_or_nop_1): Handle
	BIT_XOR_EXPR and PLUS_EXPR the same as BIT_IOR_EXPR.
	(pass_optimize_bswap::execute): Likewise.

gcc/testsuite/ChangeLog
	PR tree-optimization/98953
	PR tree-optimization/103345
	* gcc.dg/tree-ssa/pr98953.c: New test case.
	* gcc.dg/tree-ssa/pr103345.c: New test case.
2021-11-22 18:15:36 +00:00
Martin Liska c38c547a70 docs: remove duplicate param documentation
gcc/ChangeLog:

	* doc/invoke.texi: Remove duplicate documentation for 3 params.
2021-11-22 17:37:12 +01:00
Jakub Jelinek 1aedb3920a openacc: Fix up C++ #pragma acc routine handling [PR101731]
The following testcase ICEs because two function declarations are nested in
each other and the acc routine handling code isn't prepared to put the
pragma on both.

The fix is similar to what #pragma omp declare {simd,variant} does,
in particular set the fndecl_seen flag already in cp_parser_late_parsing*
when we encounter it rather than only after we finalize it.

In cp_finalize_oacc_routine I had to move the fndecl_seen diagnostics to
non-FUNCTION_DECL block, because for FUNCTION_DECLs the flag is already
known to be set from cp_parser_late_parsing_oacc_routine, but can't be
removed altogether, because that regresses quality of 2 goacc/routine-5.c
diagnostics - we drop "a single " from the
'#pragma acc routine' not immediately followed by a single function declaration or definition
diagnostic say on
 #pragma acc routine
 int foo (), b;
if we drop it altogether.

2021-11-22  Jakub Jelinek  <jakub@redhat.com>

	PR c++/101731
	* parser.c (cp_parser_late_parsing_oacc_routine): Set
	parser->oacc_routine->fndecl_seen here, rather than ...
	(cp_finalize_oacc_routine): ... here.  Don't error if
	parser->oacc_routine->fndecl_seen is set for FUNCTION_DECLs.

	* c-c++-common/goacc/routine-6.c: New test.
2021-11-22 17:07:19 +01:00
Jonathan Wakely d7376862b6 libstdc++: Fix condition for definition of _GLIBCXX14_DEPRECATED
The check for C++14 was using the wrong date.

libstdc++-v3/ChangeLog:

	* include/bits/c++config (_GLIBCXX14_DEPRECATED): Fix condition
	checking for C++14.
2021-11-22 14:57:17 +00:00
Florian Weimer f58bf16f67 libgcc: Remove dbase member from struct unw_eh_callback_data if NULL
Only bfin, frv, i386 and nios2 need this member at present.

libgcc/ChangeLog

	* unwind-dw2-fde-dip.c (NEED_DBASE_MEMBER): Define.
	(struct unw_eh_callback_data): Make dbase member conditional.
	(unw_eh_callback_data_dbase): New function.
	(base_from_cb_data): Simplify for the non-dbase case.
	(_Unwind_IteratePhdrCallback): Adjust.
	(_Unwind_Find_FDE): Likewise.
2021-11-22 13:31:10 +01:00
Florian Weimer 90986c5f0a libgcc: Remove tbase member from struct unw_eh_callback_data
It is always a null pointer.

libgcc/ChangeLog

	* unwind-dw2-fde-dip.c (struct unw_eh_callback_data): Remove
	tbase member.
	(base_from_cb_data): Adjust.
	(_Unwind_IteratePhdrCallback): Likewise.
	(_Unwind_Find_FDE): Likewise.
2021-11-22 13:30:23 +01:00