Commit Graph

182999 Commits

Author SHA1 Message Date
Maciej W. Rozycki 070a1fb5f5 MAINTAINERS: Update my e-mail address
* MAINTAINERS (Write After Approval): Update my e-mail address.
2021-01-22 00:18:14 +00:00
GCC Administrator 7559d465fd Daily bump. 2021-01-22 00:16:22 +00:00
David Edelsohn 9929d04ee2 testsuite: Adjust cpp2a/lambda-uneval regrex
Both lambda-uneval1.C and lambda-uneval5.C test that a symbol is not
declared global by looking for "globl" assembler directive.  The testcases
generate the "lglobl" directive in AIX XCOFF, which is a false positive.
This patch restricts the regex to ignore a prepended "l".  The patch
also tightens the regex to specifically look for space, tab or period
between the "globl" and the symbol.

Tested on powerpc-ibm-aix7.2.3.0 and powerpc64le-linux-gnu.

	* g++.dg/cpp2a/lambda-uneval1.C: Ignore preceding "l" and
	intervening period.
	* g++.dg/cpp2a/lambda-uneval5.C: Ignore preceding "l" and
	explicitly check for intervening space, tab or period.
2021-01-21 18:49:33 -05:00
Vladimir N. Makarov 68ba1039c7 [PR98777] LRA: Use preliminary created pseudo for in LRA elimination subpass
LRA did not extend ira_reg_equiv after generation of a pseudo in
eliminate_regs_in_insn which might results in LRA crash.  It is better not
to extend ira_reg_equiv but to use preliminary generated pseudo.  The
patch implements it.

gcc/ChangeLog:

	PR rtl-optimization/98777
	* lra-int.h (lra_pmode_pseudo): New extern.
	* lra.c (lra_pmode_pseudo): New global.
	(lra): Set it up.
	* lra-eliminations.c (eliminate_regs_in_insn): Use it.

gcc/testsuite/ChangeLog:

	PR rtl-optimization/98777
	* gcc.target/riscv/pr98777.c: New.
2021-01-21 18:06:49 -05:00
Ilya Leoshkevich efb6bc55a9 fwprop: Allow (subreg (mem)) simplifications
Suppose we have:

    (set (reg/v:TF 63) (mem/c:TF (reg/v:DI 62)))
    (set (reg:FPRX2 66) (subreg:FPRX2 (reg/v:TF 63) 0))

It is clearly profitable to propagate the first insn into the second
one and get:

    (set (reg:FPRX2 66) (mem/c:FPRX2 (reg/v:DI 62)))

fwprop actually manages to perform this, but doesn't think the result is
worth it, which results in unnecessary store/load sequences on s390.
Improve the situation by classifying SUBREG -> MEM changes as
profitable.

gcc/ChangeLog:

2021-01-15  Ilya Leoshkevich  <iii@linux.ibm.com>

	* fwprop.c (fwprop_propagation::classify_result): Allow
	(subreg (mem)) simplifications.
2021-01-21 22:48:47 +01:00
Patrick Palka f645da0e4a c++: Fix excessive instantiation inside decltype [PR71879]
Here after resolving the address of a template-id inside decltype, we
end up instantiating the chosen specialization (from the call to
mark_used in resolve_nondeduced_context), even though only its type is
needed.

This patch sets cp_unevaluated_operand throughout finish_decltype_type,
so that in particular it's set during the call to
resolve_nondeduced_context within.

gcc/cp/ChangeLog:

	PR c++/71879
	* semantics.c (finish_decltype_type): Set up a cp_unevaluated
	sentinel at the start of the function.  Remove a now-redundant
	manual adjustment of cp_unevaluated_operand.

gcc/testsuite/ChangeLog:

	PR c++/71879
	* g++.dg/cpp0x/decltype-71879.C: New test.
2021-01-21 14:04:55 -05:00
Nathan Sidwell 7944753fad c++: Fix null this pointer [PR 98624]
One may not use a null this pointer to invoke a static member
function.  This fixes the remaining ubsan errors found with an
ubsan bootstrap.

	PR c++/98624
	gcc/cp/
	* module.cc (depset:#️⃣:find_dependencies): Add
	module arg.
	(trees_out::core_vals): Check state before calling
	write_location.
	(sort_cluster, module_state::write): Adjust
	find_dependencies call.
2021-01-21 10:41:35 -08:00
Jakub Jelinek 0fb7aa205a c++: Fix up potential_constant_expression_1 FOR/WHILE_STMT handling [PR98672]
The following testcase is rejected even when it is valid.
The problem is that potential_constant_expression_1 doesn't have the
accurate *jump_target tracking cxx_eval_* has, and when the loop has
a condition that isn't guaranteed to be always true, the body isn't walked
at all.  That is mostly a correct conservative behavior, except that it
doesn't detect if there are any return statements in the body, which means
the loop might return instead of falling through to the next statement.
We already have code for return stmt discovery in code snippets we don't
try to evaluate for switches, so this patch reuses that for FOR_STMT
and WHILE_STMT bodies.

Note, I haven't touched FOR_EXPR, with statement expressions it could
have return stmts in it too, or it could have break or continue statements
that wouldn't bind to the current loop but to something outer.  That
case is clearly mishandled by potential_constant_expression_1 even
when the condition is missing or is always true, and it wouldn't surprise me
if cxx_eval_* didn't handle it right either, so I'm deferring that to
separate PR for later.  We'd need proper test coverage for all of that.

> Hmm, IF_STMT probably also needs to check the else clause, if the condition
> isn't a known constant.

You're right, I thought it was ok because it recurses with tf_none, but
if the then branch is potentially constant and only else returns, continues
or breaks, then as the enhanced testcase shows we were mishandling it too.

2021-01-21  Jakub Jelinek  <jakub@redhat.com>

	PR c++/98672
	* constexpr.c (check_for_return_continue_data): Add break_stmt member.
	(check_for_return_continue): Also look for BREAK_STMT.  Handle
	SWITCH_STMT by ignoring break_stmt from its body.
	(potential_constant_expression_1) <case FOR_STMT>,
	<case WHILE_STMT>: If the condition isn't constant true, check if
	the loop body can contain a return stmt.
	<case SWITCH_STMT>: Adjust check_for_return_continue_data initializer.
	<case IF_STMT>: If recursion with tf_none is successful,
	merge *jump_target from the branches - returns with highest priority,
	breaks or continues lower.  If then branch is potentially constant and
	doesn't return, check the else branch if it could return, break or
	continue.

	* g++.dg/cpp1y/constexpr-98672.C: New test.
2021-01-21 17:22:45 +01:00
Kyrylo Tkachov 43705f3fa3 aarch64: Use canonical RTL for sqdmlal patterns
The aarch64_sqdml<SBINQOPS:as>l patterns are of the form:
  [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
        (SBINQOPS:<VWIDE>
	  (match_operand:<VWIDE> 1 "register_operand" "0")
	  (ss_ashift:<VWIDE>
	      (mult:<VWIDE>
		(sign_extend:<VWIDE>
		      (match_operand:VSD_HSI 2 "register_operand" "w"))
		(sign_extend:<VWIDE>
		      (match_operand:VSD_HSI 3 "register_operand" "w")))
	      (const_int 1))))]

where SBINQOPS is ss_plus and ss_minus. The problem is that for the
ss_plus case the RTL
is not canonical: the (match_oprand 1) should be the second arm of the
PLUS.
I've seen this manifest in combine missing some legitimate
simplifications because it generates
the canonical ss_plus form and fails to match the pattern.

This patch splits the patterns into the ss_plus and ss_minus forms with
the canonical form for each.
I've seen this improve my testcase (which I can't include as it's too
large and not easy to test reliably).

gcc/ChangeLog:

	* config/aarch64/aarch64-simd.md (aarch64_sqdml<SBINQOPS:as>l<mode>):
	Split into...
	(aarch64_sqdmlal<mode>): ... This...
	(aarch64_sqdmlsl<mode>): ... And this.
	(aarch64_sqdml<SBINQOPS:as>l_lane<mode>): Split into...
	(aarch64_sqdmlal_lane<mode>): ... This...
	(aarch64_sqdmlsl_lane<mode>): ... And this.
	(aarch64_sqdml<SBINQOPS:as>l_laneq<mode>): Split into...
	(aarch64_sqdmlsl_laneq<mode>): ... This...
	(aarch64_sqdmlal_laneq<mode>):  ... And this.
	(aarch64_sqdml<SBINQOPS:as>l_n<mode>): Split into...
	(aarch64_sqdmlsl_n<mode>): ... This...
	(aarch64_sqdmlal_n<mode>): ... And this.
	(aarch64_sqdml<SBINQOPS:as>l2<mode>_internal): Split into...
	(aarch64_sqdmlal2<mode>_internal): ... This...
	(aarch64_sqdmlsl2<mode>_internal): ... And this.
2021-01-21 14:08:29 +00:00
Iain Buclaw 279d3a89b7 d: Enable private member access for __traits
The following traits can now access non-public members:
 - hasMember
 - getMember
 - getOverloads
 - getVirtualMethods
 - getVirtualFuntions

This fixes a long-standing issue in D where the allMembers trait would
correctly return non-public members but those non-public members would
be inaccessible to other traits.

Reviewed-on: https://github.com/dlang/dmd/pull/12135

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 3a7ebef73.
2021-01-21 14:54:48 +01:00
Christophe Lyon e154009f35 Fix typo in arm_mve.h __arm_vcmpneq_s8 return type
Like all vcmp intrinsics, __arm_vcmpneq_s8 should return a mve_pred16_t.

2021-01-21  Christophe Lyon  <christophe.lyon@linaro.org>

	gcc/
	* config/arm/arm_mve.h (__arm_vcmpneq_s8): Fix return type.
2021-01-21 13:50:01 +00:00
Andrea Corallo 0568f801ef arm: [testuiste] Fix ivopts.c target test [PR96372]
gcc/
2021-01-15  Andrea Corallo  <andrea.corallo@arm.com>
	PR target/96372
	* doc/sourcebuild.texi (arm_thumb2_no_arm_v8_1_lob): Document.

gcc/testsuite/
2021-01-15  Andrea Corallo  <andrea.corallo@arm.com>
	PR target/96372
	* lib/target-supports.exp
	(check_effective_target_arm_thumb2_no_arm_v8_1_lob): Define proc.
	* gcc.target/arm/ivopts.c: Use target
	'arm_thumb2_no_arm_v8_1_lob'.
2021-01-21 14:35:19 +01:00
Jorge D'Elia 9be0a89c95 gcc/fortran/intrinsic.texi: Fix typo
gcc/fortran/ChangeLog:

	* intrinsic.texi (CO_MAX): Fix typo.
2021-01-21 14:24:27 +01:00
Nathan Sidwell 3c1cf7350b c++: Stat-hack for members [PR 98530]
This was a header file that deployed the stat-hack inside a class
(both a member-class and a [non-static data] member had the same
name).  Due to the way that's represented in name lookup we missed the
class.  Sadly just changing the representation globally has
detrimental effects elsewhere, and this is a rare case, so just
creating a new overload on the fly shouldn't be a problem.

	PR c++/98530
	gcc/cp/
	* name-lookup.c (lookup_class_binding): Rearrange a stat-hack.
	gcc/testsuite/
	* g++.dg/modules/stat-mem-1.h: New.
	* g++.dg/modules/stat-mem-1_a.H: New.
	* g++.dg/modules/stat-mem-1_b.C: New.
2021-01-21 04:54:43 -08:00
Jonathan Wakely a1a967ce1f libstdc++: Regenerate Makefile.in
This removes a trivial whitespace difference between the currently
committed file and the one regenerated by autotools.

libstdc++-v3/ChangeLog:

	* src/c++17/Makefile.in: Regenerate.
2021-01-21 11:56:07 +00:00
Paul Thomas eaf883710c Fortran: This patch fixes comments 23 and 24 of PR96320.
2021-01-21  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/96320
	* decl.c (gfc_match_modproc): It is not an error to find a
	module procedure declaration within a contains block.
	* expr.c (gfc_check_vardef_context): Pure procedure result is
	assignable. Change 'own_scope' accordingly.
	* resolve.c (resolve_typebound_procedure): A procedure that
	has the module procedure attribute is almost certainly a
	module procedure, whatever its interface.

gcc/testsuite/
	PR fortran/96320
	* gfortran.dg/module_procedure_5.f90 : New test.
	* gfortran.dg/module_procedure_6.f90 : New test.
2021-01-21 10:00:49 +00:00
Richard Biener f46a40112c testsuite/97299 - more gcc.dg/vect/slp-reduc-3.c massaging
This adds more guards to the VEC_PERM_EXPR scan, namely that
we also could end up with load-lanes and of course no vectorization
at all.  Need dependent scans (scan-if-scan-X PASSed ...).

2021-01-21  Richard Biener  <rguenther@suse.de>

	PR testsuite/97299
	* gcc.dg/vect/slp-reduc-3.c: Amend target selectors.
2021-01-21 10:57:18 +01:00
Richard Biener 8afef308b4 testsuite/98241 - remove ilp32 XFAIL of gcc.dg/pr78973.c
XPASSes as reported.

2021-01-21  Richard Biener  <rguenther@suse.de>

	PR testsuite/98241
	* gcc.dg/pr78973.c: Remove ilp32 XFAIL.
2021-01-21 10:35:11 +01:00
Richard Biener fa9d1ad2ff testsuite/98224 - un-XFAIL Walloca-2.c on ilp32
As reported this now XPASSes with ranger.

2021-01-21  Richard Biener  <rguenther@suse.de>

	* gcc.dg/Walloca-2.c: Un-XFAIL.
2021-01-21 10:30:56 +01:00
liuhongt e711b67a90 Fix incorrect optimization by cprop_hardreg.
If SRC had been assigned a mode narrower than the copy, we can't
always link DEST into the chain even they have same
hard_regno_nregs(i.e. HImode/SImode in i386 backend).

i.e
        kmovw   %k0, %edi
        vmovd   %edi, %xmm2
	vpshuflw        $0, %xmm2, %xmm0
        kmovw   %k0, %r8d
        kmovd   %k0, %r9d
...
-	 movl %r9d, %r11d
+	 vmovd %xmm2, %r11d

gcc/ChangeLog:

	PR rtl-optimization/98694
	* regcprop.c (copy_value): If SRC had been assigned a mode
	narrower than the copy, we can't link DEST into the chain even
	they have same hard_regno_nregs(i.e. HImode/SImode in i386
	backend).

gcc/testsuite/ChangeLog:

	PR rtl-optimization/98694
	* gcc.target/i386/pr98694.c: New test.
2021-01-21 13:28:59 +08:00
GCC Administrator b93d0e36c0 Daily bump. 2021-01-21 00:16:36 +00:00
David Edelsohn fb39c4fe44 aix: make ctype_inline.h thread-safe and avoid _OBJ_DATA char subscript.
g++.dg/warn/Wstringop-overflow-6.C tests for a bogus overflow warning in
system headers.  This testcase was generating a -Wchar-subscript warning
on AIX because ctype_inline.h was subscripting AIX _OBJ_DATA using a char.
The _M_table case cast the subscript to unsigned char, but the _OBJ_DATA
case did not.

The investigation also exposed that AIX has added a thread-safe variant
of access to __lc_type that had not been applied to the libstdc++
implementation.

This patch casts the subscript to unsigned char and adds the THREAD_SAFE
variant.  libstdc++ always is compiled with pthreads, but it is good
to make the situation explicit and to document the appropriate usage.

Bootstrapped on powerpc-ibm-aix7.2.3.0.

libstdc++-v3/ChangeLog:

	* config/os/aix/ctype_inline.h (bool ctype<char>:: is): Cast
	_OBJ_DATA subscript to unsigned char. Add _THREAD_SAFE access to
	__lc_type.
	(const char* ctype<char>:: is): Same.
2021-01-20 17:42:02 -05:00
Andrew MacLeod 842afc4e28 Re: trapv question
Adjust testcase to so the ADD that is expected to overflow cannot
be optimized.

	gcc/testsuite
	* gcc.dg/torture/ftrapv-2.c: Make overflow instruction unremovable.
2021-01-20 16:30:48 -05:00
Jakub Jelinek 0bb27b81a7 libgomp: Fix up GOMP_task on s390x
On Wed, Jan 20, 2021 at 05:04:39PM +0100, Florian Weimer wrote:
> Sorry, this appears to cause OpenMP task state corruption in RPM.  We
> have only seen this on s390x.

Haven't actually verified it, but my suspection is that this is a caller
stack corruption.

We play with fire with the GOMP_task API/ABI extensions, the GOMP_task
function used to be:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags);
and later:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags,
           void **depend);
and later:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags,
           void **depend, int priority);
and now:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags,
           void **depend, int priority, void *detach)
and which of those depend, priority and detach argument is present depends
on the bits in flags.
I'm afraid the compiler just decided to spill the detach = NULL store in
  if ((flags & GOMP_TASK_FLAG_DETACH) == 0)
    detach = NULL;
on s390x into the argument stack slot.  Not a problem if the caller passes
all those 10 arguments, but if not, can clobber random stack location.

This hack should fix it up.  Priority doesn't need changing, but I've
changed it anyway just to be safe.  With the patch none of the 3 arguments
are ever modified, so I'd hope gcc doesn't decide to spill something
unrelated there.

2021-01-20  Jakub Jelinek  <jakub@redhat.com>

	* task.c (GOMP_task): Rename priority argument to priority_arg,
	add priority automatic variable and modify that variable.  Instead of
	clearing detach argument when GOMP_TASK_FLAG_DETACH bit is not set,
	check flags for that bit.
2021-01-20 22:10:20 +01:00
Nathan Sidwell 911f797a9b c++: Avoid UB in signed shift [PR 98625]
I'd forgotten that left shifting a negative value is UB until C++20.
Insert some casts to do unsigned shifts.

	PT c++/98625
	gcc/cp/
	* module.cc (bytes_in::i, bytes_in::wi): Avoid left shift of
	signed type.
2021-01-20 11:41:51 -08:00
Kyrylo Tkachov e140f5fd3e aarch64: Split vec_selects of bottom elements into simple move
In certain intrinsics use cases GCC leaves SETs of a bottom-element vec
select lying around:
        (vec_select:DI (reg:V2DI 34 v2 [orig:128 __o ] [128])
            (parallel [
                    (const_int 0 [0])
                ])))

This can be treated as a simple move in aarch64 when done between SIMD
registers for all normal widths.
These go through the aarch64_get_lane pattern.
This patch adds a splitter there to simplify these extracts to a move
that can, perhaps, be optimised a way.
Another benefit is if the destination is memory we can use a simpler STR
instruction rather than ST1-lane.

gcc/

	* config/aarch64/aarch64-simd.md (aarch64_get_lane<mode>):
	Convert to define_insn_and_split.  Split into simple move when moving
	bottom element.

gcc/testsuite/

	* gcc.target/aarch64/vdup_lane_2.c: Scan for fmov rather than
	dup.
2021-01-20 19:29:42 +00:00
Segher Boessenkool f8c6777766 rs6000: Fix rs6000_emit_le_vsx_store (PR98549)
One of the advantages of LRA is that you can create new pseudos from it
just fine.  The code in rs6000_emit_le_vsx_store was not aware of this.
This patch changes that, in the process fixing PR98549 (where it is
shown that we do call rs6000_emit_le_vsx_store during LRA, which we
used to assert can not happen).

2021-01-20  Segher Boessenkool  <segher@kernel.crashing.org>

	* config/rs6000/rs6000.c (rs6000_emit_le_vsx_store): Change assert.
	Adjust comment.  Simplify code.
2021-01-20 19:00:22 +00:00
Jakub Jelinek 27c792895b debug: Fix up DWARF 5 -g -flto -ffat-lto-objects [PR98765]
As mentioned in the PR, with -gdwarf-5 (or -g now) -flto -ffat-lto-objects,
users can't strip the LTO sections with
strip -p -R .gnu.lto_* -R .gnu.debuglto_* -N __gnu_lto_v1
anymore when GCC is configured against recent binutils.

The problem is that in that case .gnu.debuglto_.debug_line_str section is
then used, which is fine for references to strings in .gnu.debuglto_.*
sections, but not when those references are in .debug_info section too;
those should really reference separate strings in .debug_line_str section.

For .gnu.debuglto_.debug_str vs. .debug_str we handle it right, we
reset_indirect_string the strings and thus force creation of new labels for
the second time.
But for DW_FORM_line_strp as the patch shows, there were multiple problems.
First one was that reset_indirect_string, even when called through traverse
on debug_line_str_hash, didn't do anything at all (fixed by first hunk).
The second bug was that the DW_FORM_line_strp strings, which were supposed
to be only visible through debug_line_str_hash, leaked into debug_str_hash
(second hunk).
And the third thing is that when we reset debug_line_str_hash, we should
still make those strings DW_FORM_line_strp if they are accessed.
One could do it by reinstantiating DW_FORM_line_strp right away in
reset_indirect_string and not clear debug_line_str_hash, but that has the
disadvantage that we then force emitting .debug_line_str strings that aren't
really needed - we need those from the CU DIEs' DW_AT_name and
DW_AT_comp_dir attributes, but when emitting .debug_line section through
assembler, we don't need to emit the strings we only needed for
.gnu.debuglto_.debug_line which is always emitted by the compiler.

2021-01-20  Jakub Jelinek  <jakub@redhat.com>

	PR debug/98765
	* dwarf2out.c (reset_indirect_string): Also reset indirect strings
	with DW_FORM_line_strp form.
	(prune_unused_types_update_strings): Don't add into debug_str_hash
	indirect strings with DW_FORM_line_strp form.
	(adjust_name_comp_dir): New function.
	(dwarf2out_finish): Call it on CU DIEs after resetting
	debug_line_str_hash.
2021-01-20 18:51:04 +01:00
Vladimir N. Makarov 4334b52427 [PR98722] LRA: Check that target has no 3-op add insn to transform 2 plus expression.
Patch cf2ac1c30a for solving PR97969 was
assumed for targets with absent 3-op add insn.  But the original patch did
not check this.  This patch adds the check.

gcc/ChangeLog:

	PR rtl-optimization/98722
	* lra-eliminations.c (eliminate_regs_in_insn): Check that target
	has no 3-op add insn to transform insns containing two pluses.

gcc/testsuite/ChangeLog:

	PR rtl-optimization/98722
	* g++.target/s390/pr98722.C: New.
2021-01-20 11:44:04 -05:00
Richard Biener 261cdd2319 Handle overflow in dependence analysis lambda ops gracefully
The following tries to handle overflow in the integer computations
done by lambda ops of dependence analysis by failing instead of
silently continuing with overflowed values.

It also avoids treating large unsigned CHREC_RIGHT as negative
unless the chrec is of pointer type and avoids the most negative
integer value to avoid excessive overflow checking (with this
the fix for PR98758 can be partly simplified as seen).

I've added add_hwi and mul_hwi functions computing HOST_WIDE_INT
signed sum and product with indicating overflow, they hopefully
get matched to the appropriate internal functions.

I don't have any testcases triggering overflow in any of the
guarded computations.

2021-01-20  Richard Biener  <rguenther@suse.de>

	* hwint.h (add_hwi): New function.
	(mul_hwi): Likewise.
	* tree-data-ref.c (initialize_matrix_A): Properly translate
	tree constants and avoid HOST_WIDE_INT_MIN.
	(lambda_matrix_row_add): Avoid undefined integer overflow
	and return true on such overflow.
	(lambda_matrix_right_hermite): Handle overflow from
	lambda_matrix_row_add gracefully.  Simplify previous fix.
	(analyze_subscript_affine_affine): Likewise.
2021-01-20 16:32:11 +01:00
Eugene Rozenfeld 49e8c14ef6 Optimize combination of comparisons to dec+compare
This patch adds patterns for optimizing
x < y || y == XXX_MIN to x <= y-1
x >= y && y != XXX_MIN to x > y-1
if y is an integer with TYPE_OVERFLOW_WRAPS.

This fixes pr96674.

Tested on x86_64-pc-linux-gnu.

For this function

bool f(unsigned a, unsigned b)
{
    return (b == 0) | (a < b);
}

the code without the patch is

test   esi,esi
sete   al
cmp    esi,edi
seta   dl
or     eax,edx
ret

the code with the patch is

sub    esi,0x1
cmp    esi,edi
setae  al
ret

	PR tree-optimization/96674
gcc/
	* match.pd: New patterns: x < y || y == XXX_MIN --> x <= y - 1
	x >= y && y != XXX_MIN --> x > y - 1

gcc/testsuite
	* gcc.dg/pr96674.c: New tests.
2021-01-20 16:31:46 +01:00
Patrick Palka cafcfcb584 c++: Fix tsubsting CLASS_PLACEHOLDER_TEMPLATE [PR95434]
Here, during partial instantiation of the generic lambda, we do
tsubst_copy on the CLASS_PLACEHOLDER_TEMPLATE for U{0} which yields a
(level-lowered) TEMPLATE_TEMPLATE_PARM rather than the corresponding
TEMPLATE_DECL.  This later confuses do_class_deduction which expects
that a CLASS_PLACEHOLDER_TEMPLATE is always a TEMPLATE_DECL.

gcc/cp/ChangeLog:

	PR c++/95434
	* pt.c (tsubst) <case TEMPLATE_TYPE_PARM>: If tsubsting
	CLASS_PLACEHOLDER_TEMPLATE yields a TEMPLATE_TEMPLATE_PARM,
	adjust to its TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL.

gcc/testsuite/ChangeLog:

	PR c++/95434
	* g++.dg/cpp2a/lambda-generic9.C: New test.
2021-01-20 09:44:33 -05:00
Patrick Palka 79e1251b64 c++: Defer access checking when processing bases [PR82613]
When parsing the base-clause of a class declaration, we need to defer
access checking until the entire base-clause has been seen, so that
access can be properly checked relative to the scope of the class with
all its bases attached.  This allows us to accept the declaration of
struct D from Example 2 of [class.access.general] (access12.C below).

Similarly when substituting into the base-clause of a class template,
which is the subject of PR82613.

gcc/cp/ChangeLog:

	PR c++/82613
	* parser.c (cp_parser_class_head): Defer access checking when
	parsing the base-clause until all bases are seen and attached
	to the class type.
	* pt.c (instantiate_class_template): Likewise when substituting
	into dependent bases.

gcc/testsuite/ChangeLog:

	PR c++/82613
	* g++.dg/parse/access12.C: New test.
	* g++.dg/template/access35.C: New test.
2021-01-20 09:43:48 -05:00
Richard Sandiford ea74a3f548 vect: Fix VLA SLP invariant optimisation [PR98535]
duplicate_and_interleave is the main fallback way of loading
a repeating sequence of elements into variable-length vectors.
The code handles cases in which the number of elements in the
sequence is potentially several times greater than the number
of elements in a vector.

Let:

- NE be the (compile-time) number of elements in the sequence
- NR be the (compile-time) number of vector results and
- VE be the (run-time) number of elements in each vector

The basic approach is to duplicate each element into a
separate vector, giving NE vectors in total, then use
log2(NE) rows of NE permutes to generate NE results.

In the worst case — when VE has no known compile-time factor
and NR >= NE — all of these permutes are necessary.  However,
if VE is known to be a multiple of 2**F, then each of the
first F permute rows produces duplicate results; specifically,
the high permute for a given pair is the same as the low permute.
The code dealt with this by reusing the low result for the
high result.  This part was OK.

However, having duplicate results from one row meant that the
next row did duplicate work.  The redundancies would be optimised
away by later passes, but the code tried to avoid generating them
in the first place.  This is the part that went wrong.

Specifically, NR is typically less than NE when some permutes are
redundant, so the code tried to use NR to reduce the amount of work
performed.  The problem was that, although it correctly calculated
a conservative bound on how many results were needed in each row,
it chose the wrong results for anything other than the final row.

This doesn't usually matter for fully-packed SVE vectors.  We first
try to coalesce smaller elements into larger ones, so normally
VE ends up being 2**VQ (where VQ is the number of 128-bit blocks
in an SVE vector).  In that situation we'd only apply the faulty
optimisation to the final row, i.e. the case it handled correctly.
E.g. for things like:

  void
  f (long *x)
  {
    for (int i = 0; i < 100; i += 8)
      {
        x[i] += 1;
        x[i + 1] += 2;
        x[i + 2] += 3;
        x[i + 3] += 4;
        x[i + 4] += 5;
        x[i + 5] += 6;
        x[i + 6] += 7;
        x[i + 7] += 8;
      }
  }

(already tested by the testsuite), we'd have 3 rows of permutes
producing 4 vector results.  The schemne produced:

1st row: 8 results from 4 permutes, highs duplicates of lows
2nd row: 8 results from 8 permutes (half of which are actually redundant)
3rd row: 4 results from 4 permutes

However, coalescing elements is trickier for unpacked vectors,
and at the moment we don't try to do it (see the GET_MODE_SIZE
check in can_duplicate_and_interleave_p).  Unpacked vectors
therefore stress the code in ways that packed vectors didn't.

The patch fixes this by removing the redundancies from each row,
rather than trying to work around them later.  This also removes
the redundant work in the second row of the example above.

gcc/
	PR tree-optimization/98535
	* tree-vect-slp.c (duplicate_and_interleave): Use quick_grow_cleared.
	If the high and low permutes are the same, remove the high permutes
	from the working set and only continue with the low ones.
2021-01-20 13:16:30 +00:00
Tobias Burnus a95538b6c5 Fix gfortran.dg/gomp/task-detach-1.f90 for non 64bit pointers
gcc/testsuite/ChangeLog:

	PR fortran/98763
	* gfortran.dg/gomp/task-detach-1.f90: Use integer(1) to avoid
	missing diagnostic issues with c_intptr_t == default integer kind.
2021-01-20 11:27:26 +01:00
Jakub Jelinek 4d2ecd960a builtins: Fix up two bugs in access_ref::inform_access [PR98721]
The following patch fixes two bugs in the access_ref::inform_access function
(plus some formatting nits).

The first problem is that ref can be various things, e.g. *_DECL, or
SSA_NAME, or IDENTIFIER_NODE.  And allocfn is non-NULL only if ref is
(at least originally) an SSA_NAME initialized to the result of some
allocator function (but not e.g. __builtin_alloca_with_align which is
handled differently).

A few lines above the last hunk of this patch in builtins.c, the code uses
  if (mode == access_read_write || mode == access_write_only)
    {
      if (allocfn == NULL_TREE)
        {
          if (*offstr)
            inform (loc, "at offset %s into destination object %qE of size %s",
                    offstr, ref, sizestr);
          else
            inform (loc, "destination object %qE of size %s", ref, sizestr);
          return;
        }

      if (*offstr)
        inform (loc,
                "at offset %s into destination object of size %s "
                "allocated by %qE", offstr, sizestr, allocfn);
      else
        inform (loc, "destination object of size %s allocated by %qE",
                sizestr, allocfn);
      return;
    }
so if allocfn is NULL, it prints whatever ref is, if it is non-NULL,
it prints instead the allocation function.  But strangely the hunk
a few lines below wasn't consistent with that and instead printed the
first form only if DECL_P (ref) and would ICE if ref wasn't a decl but
still allocfn was NULL.  Fixed by making it consistent what the code does
earlier.

Another bug is that the code earlier contains an ugly hack for VLAs and was
assuming that SSA_NAME_IDENTIFIER must be non-NULL on the lhs of
__builtin_alloca_with_align.  While that is likely true for the cases where
the compiler emits this builtin for VLAs (and it will also be true that
the name of the VLA in that case can be taken from that identifier up to the
first .), the builtin is user accessible as the testcase shows, so one can
have any other SSA_NAME in there.  I think it would be better to add some
more reliable way how to identify VLA names corresponding to
__builtin_alloca_with_align allocations, perhaps internal fn or whatever,
but that is beyond the scope of this patch.

2021-01-20  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/98721
	* builtins.c (access_ref::inform_access): Don't assume
	SSA_NAME_IDENTIFIER must be non-NULL.  Print messages about
	object whenever allocfn is NULL, rather than only when DECL_P
	is true.  Use %qE instead of %qD for that.  Formatting fixes.

	* gcc.dg/pr98721-1.c: New test.
	* gcc.dg/pr98721-2.c: New test.
2021-01-20 09:49:24 +01:00
Richard Biener 34599780d0 tree-optimization/98758 - fix integer arithmetic in data-ref analysis
This fixes some int arithmetic issues and a bogus truncation.

2021-01-20  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98758
	* tree-data-ref.c (int_divides_p): Use lambda_int arguments.
	(lambda_matrix_right_hermite): Avoid undefinedness with
	signed integer abs and multiplication.
	(analyze_subscript_affine_affine): Use lambda_int.

	* gcc.dg/torture/pr98758.c: New testcase.
2021-01-20 09:38:22 +01:00
Jakub Jelinek 7ab1abf3b8 openmp: Don't ICE on detach clause with erroneous decl [PR98742]
Similarly to how we handle erroneous operands to e.g. allocate clause,
this change just removes those clauses instead of accessing TYPE_MAIN_VARIANT
of its type, which doesn't work on error_mark_node.  Also, just for good
measure, bails out if TYPE_NAME is NULL.

2021-01-20  Jakub Jelinek  <jakub@redhat.com>

	PR c++/98742
	* semantics.c (finish_omp_clauses) <case OMP_CLAUSE_DETACH>: If
	error_operand_p, remove clause without further checking.  Check
	for non-NULL TYPE_NAME.

	* c-c++-common/gomp/task-detach-2.c: New test.
2021-01-20 08:38:46 +01:00
Tobias Burnus c05cdfb3f6 OpenMP/Fortran: Fix gfortran.dg/gomp/is_device_ptr-2.f90
gcc/testsuite/ChangeLog:

	PR fortran/98757
	PR fortran/98476
	* gfortran.dg/gomp/is_device_ptr-2.f90: Fix dg-error.
2021-01-20 08:35:18 +01:00
David Malcolm b83604c75f dwarf2out: reset generation count in toplev::finalize [PR98751]
PR debug/98751 reports an issue in which most of libgccjit's tests
fails in DWARF 5 handling with
  `.Ldebug_loc2' is already defined"
asm errors.

The bogus label is being emitted at the 3rd in-process iteration, at:
  31673	      ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);
which on the initial iteration emits:

 145   │ .Ldebug_loc0:

on the 2nd iteration:
 145   │ .Ldebug_loc1:

and on the 3rd iteration:
 145   │ .Ldebug_loc2:

which is a duplicate of a label emitted earlier:
 138   │     .section    .debug_loclists,"",@progbits
 139   │     .long   .Ldebug_loc3-.Ldebug_loc2
 140   │ .Ldebug_loc2:
 141   │     .value  0x5
 142   │     .byte   0x8
 143   │     .byte   0
 144   │     .long   0
 145   │ .Ldebug_loc2:

The issue seems to be that init_sections_and_labels creates the label
  ASM_GENERATE_INTERNAL_LABEL (loc_section_label, DEBUG_LOC_SECTION_LABEL,
			       generation);

where "generation" is a static local to init_sections_and_labels that
increments, and thus eventually hits the duplicate value.

It appears that this value is intended to be either 0 or 1, but in
the libgccjit case the compilation code can be invoked an arbitrary
number of times in-process, and hence can eventually lead to a
label name collision.

This patch adds code to dwarf2out_c_finalize (called by
toplev::finalize in libgccjit) to reset the generation counts,
fixing the issue.

gcc/ChangeLog:
	PR debug/98751
	* dwarf2out.c (output_line_info): Rename static variable
	"generation", moving it out of the function to...
	(output_line_info_generation): New.
	(init_sections_and_labels): Likewise, renaming the variable to...
	(init_sections_and_labels_generation): New.
	(dwarf2out_c_finalize): Reset the new variables.
2021-01-19 19:58:23 -05:00
GCC Administrator f35a4f9637 Daily bump. 2021-01-20 00:16:46 +00:00
David Edelsohn 6bc6094fa3 testsuite: aix testsuite adjustments
This patch re-enables the DWARF5 tests that seem to be functioning again.
It adds a comment to pr41445-7.c that any changes in lines need to be
reflected in the expected output.

The patch also allows for additional failures in ucs.c and reflects that
builtin-sprintf-warn-20.c requires 4 byte wide char support.

gcc/testsuite/ChangeLog:

	* gcc.dg/cpp/ucs.c: Expect Invalid warning for 2byte wchar.
	* gcc.dg/debug/dwarf2/inline6.c: Remove skip AIX.
	* gcc.dg/debug/dwarf2/lang-c11.c: Remove skip AIX.
	* gcc.dg/debug/dwarf2/pr41445-7.c: Remove skip AIX.
	* gcc.dg/debug/dwarf2/pr41445-8.c: Remove skip AIX.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-20.c: Require 4byte wchar.
2021-01-19 18:50:29 -05:00
Joseph Myers a311dfaf92 Update gcc de.po.
* de.po: Update.
2021-01-19 23:29:33 +00:00
Marek Polacek 2b27f37f90 c++: Crash when deducing template arguments [PR98659]
maybe_instantiate_noexcept doesn't expect to see error_mark_node, but
the new callsite I introduced in r11-6476 can pass error_mark_node to
it.  So cope.

gcc/cp/ChangeLog:

	PR c++/98659
	* pt.c (maybe_instantiate_noexcept): Return false if FN is
	error_mark_node.

gcc/testsuite/ChangeLog:

	PR c++/98659
	* g++.dg/template/deduce8.C: New test.
2021-01-19 17:41:20 -05:00
Ian Lance Taylor eed40bca6f compiler: initialize variables with go:embed directives
This completes the compiler work for go:embed.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/281536
2021-01-19 14:29:18 -08:00
Marek Polacek d89b00c095 c++: ICE with USING_DECL redeclaration [PR98687]
My recent patch that introduced push_using_decl_bindings didn't
handle USING_DECL redeclaration, therefore things broke.  This patch
amends that by breaking out a part of finish_nonmember_using_decl
out to a separate function, push_using_decl_bindings, and calling it.
It needs an overload, because name_lookup is only available inside
of name-lookup.c.

gcc/cp/ChangeLog:

	PR c++/98687
	* name-lookup.c (push_using_decl_bindings): New, broken out of...
	(finish_nonmember_using_decl): ...here.
	* name-lookup.h (push_using_decl_bindings): Update declaration.
	* pt.c (tsubst_expr): Update the call to push_using_decl_bindings.

gcc/testsuite/ChangeLog:

	PR c++/98687
	* g++.dg/lookup/using64.C: New test.
	* g++.dg/lookup/using65.C: New test.
2021-01-19 17:13:00 -05:00
Martin Sebor 9693e255ee PR middle-end/98664 - inconsistent -Wfree-nonheap-object for inlined calls to system headers
gcc/ChangeLog:

	PR middle-end/98664
	* tree-ssa-live.c (remove_unused_scope_block_p): Keep scopes for
	all functions, even if they're not declared artificial or inline.
	* tree.c (tree_inlined_location): Use macro expansion location
	only if scope traversal fails to expose one.

gcc/testsuite/ChangeLog:

	PR middle-end/98664
	* gcc.dg/Wvla-larger-than-4.c: Adjust expected output.
	* gcc.dg/plugin/diagnostic-test-inlining-3.c: Same.
	* g++.dg/warn/Wfree-nonheap-object-5.C: New test.
	* gcc.dg/Wfree-nonheap-object-4.c: New test.
2021-01-19 15:10:30 -07:00
Patrick Palka 29853c6532 c++: Always check access during late-parsing of members [PR58993]
This patch removes a vestigial use of dk_no_check from
cp_parser_late_parsing_for_member, which ideally should have been
removed as part of the PR41437 patch that improved access checking
inside templates.  This allows us to correctly reject f1 and f2 in
the testcase access34.C below (whereas before we'd only reject f3).

Additional testing revealed a new access issue when late-parsing a hidden
friend within a class template.  In the testcase friend68.C below, we're
tripping over the checking assert from friend_accessible_p(f, S::j, S, S)
during lookup of j in x.j (for which type_dependent_object_expression_p
returns false, which is why we're doing the lookup at parse time).  The
reason for the assert failure is that DECL_FRIENDLIST(S) contains f but
DECL_BEFRIENDING_CLASSES(f) is empty, and so friend_accessible_p (which
looks at DECL_BEFRIENDING_CLASSES) wants to return false, but is_friend
(which looks at DECL_FRIENDLIST) returns true.

For sake of symmetry one would expect that DECL_BEFRIENDING_CLASSES(f)
contains S, but add_friend avoids updating DECL_BEFRIENDING_CLASSES when
the class type (S in this case) is dependent, for some reason.

This patch works around this issue by making friend_accessible_p
consider the DECL_FRIEND_CONTEXT of the access scope.  Thus we sidestep
the DECL_BEFRIENDING_CLASSES / DECL_FRIENDLIST asymmetry issue while
correctly validating the x.j access at parse time.

A earlier version of this patch checked friend_accessible_p instead of
protected_accessible_p in the DECL_FRIEND_CONTEXT hunk below, but this
had the side effect of making us accept the ill-formed testcase friend69.C
below (ill-formed because the hidden friend g is not actually a member
of A, so g doesn't have access to B's members despite B befriending A).

gcc/cp/ChangeLog:

	PR c++/41437
	PR c++/58993
	* search.c (friend_accessible_p): If scope is a hidden friend
	defined inside a dependent class, consider access from the
	class.
	* parser.c (cp_parser_late_parsing_for_member): Don't push a
	dk_no_check access state.

gcc/testsuite/ChangeLog:

	PR c++/41437
	PR c++/58993
	* g++.dg/opt/pr87974.C: Adjust.
	* g++.dg/template/access34.C: New test.
	* g++.dg/template/friend68.C: New test.
	* g++.dg/template/friend69.C: New test.
2021-01-19 16:20:00 -05:00
Marek Polacek c37f1d4081 c++: ICE when late parsing noexcept/NSDMI [PR98333]
Since certain members of a class are a complete-class context
[class.mem.general]p7, we delay their parsing untile the whole class has
been parsed.  For instance, NSDMIs and noexcept-specifiers.  The order
in which we perform this delayed parsing matters; we were first parsing
NSDMIs and only they did we parse noexcept-specifiers.   That turns out
to be wrong: since NSDMIs may use noexcept-specifiers, we must process
noexcept-specifiers first.  Otherwise we'll ICE in code that doesn't
expect to see DEFERRED_PARSE.

This doesn't just shift the problem, noexcept-specifiers can use members
with a NSDMI just fine, and I've also tested a similar test with this
member function:

  bool f() { return __has_nothrow_constructor (S<true>); }

and that compiled fine too.

gcc/cp/ChangeLog:

	PR c++/98333
	* parser.c (cp_parser_class_specifier_1): Perform late-parsing
	of NSDMIs before late-parsing of noexcept-specifiers.

gcc/testsuite/ChangeLog:

	PR c++/98333
	* g++.dg/cpp0x/noexcept62.C: New test.
2021-01-19 15:38:12 -05:00
Nathan Sidwell 7266ff2a24 c++: Remove unused fn
I had two overloads of a function, but only one was needed.  Let's keep
the constant one.

	gcc/cp/
	* module.cc (identifier): Merge overloads.
2021-01-19 11:37:42 -08:00