Commit graph

205846 commits

Author SHA1 Message Date
Juzhe-Zhong
9f3f0b829b RISC-V: Disallow poly (1,1) VLA SLP interleave vectorization
This patch fixes all following ICE in zve64d:

FAIL: gcc.dg/vect/pr71259.c -flto -ffat-lto-objects (internal compiler error: in SET_TYPE_VECTOR_SUBPARTS, at tree.h:4248)
FAIL: gcc.dg/vect/pr71259.c -flto -ffat-lto-objects (test for excess errors)
FAIL: gcc.dg/vect/vect-alias-check-14.c (internal compiler error: in SET_TYPE_VECTOR_SUBPARTS, at tree.h:4248)
FAIL: gcc.dg/vect/vect-alias-check-14.c (test for excess errors)
FAIL: gcc.dg/vect/vect-alias-check-14.c -flto -ffat-lto-objects (internal compiler error: in SET_TYPE_VECTOR_SUBPARTS, at tree.h:4248)
FAIL: gcc.dg/vect/vect-alias-check-14.c -flto -ffat-lto-objects (test for excess errors)
FAIL: gcc.dg/vect/vect-alias-check-9.c (internal compiler error: in SET_TYPE_VECTOR_SUBPARTS, at tree.h:4248)
FAIL: gcc.dg/vect/vect-alias-check-9.c (test for excess errors)
FAIL: gcc.dg/vect/vect-alias-check-9.c -flto -ffat-lto-objects (internal compiler error: in SET_TYPE_VECTOR_SUBPARTS, at tree.h:4248)
FAIL: gcc.dg/vect/vect-alias-check-9.c -flto -ffat-lto-objects (test for excess errors)
FAIL: gcc.dg/vect/vect-cond-arith-6.c (internal compiler error: in SET_TYPE_VECTOR_SUBPARTS, at tree.h:4248)
FAIL: gcc.dg/vect/vect-cond-arith-6.c (test for excess errors)
FAIL: gcc.dg/vect/vect-cond-arith-6.c -flto -ffat-lto-objects (internal compiler error: in SET_TYPE_VECTOR_SUBPARTS, at tree.h:4248)
FAIL: gcc.dg/vect/vect-cond-arith-6.c -flto -ffat-lto-objects (test for excess errors)
FAIL: gcc.dg/vect/vect-gather-5.c (internal compiler error: in SET_TYPE_VECTOR_SUBPARTS, at tree.h:4248)
FAIL: gcc.dg/vect/vect-gather-5.c (test for excess errors)
FAIL: gcc.dg/vect/vect-gather-5.c -flto -ffat-lto-objects (internal compiler error: in SET_TYPE_VECTOR_SUBPARTS, at tree.h:4248)
FAIL: gcc.dg/vect/vect-gather-5.c -flto -ffat-lto-objects (test for excess errors)

poly size (1, 1) vectors can not be allowed to interleave VLA SLP since interleave VLA SLP suppose VF at least hold 2 elements,
whereas, poly size (1,1) may possible only have 1 element.

	PR target/112694

gcc/ChangeLog:

	* config/riscv/riscv-v.cc (expand_vec_perm_const): Disallow poly size (1, 1) VLA SLP.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/pr112694-2.c: New test.
	* gcc.target/riscv/rvv/autovec/pr112694-3.c: New test.
2023-11-28 19:23:25 +08:00
Eric Botcazou
7eaf95689b ada: Fix wrong size value output with -gnatR -gnatc
This happens when a parameter is involved in the computation.

gcc/ada/

	* gcc-interface/decl.cc (annotate_value): Apply the same processing
	for parameters as for variables.
2023-11-28 10:35:48 +01:00
Marc Poulhiès
60123b134b ada: Add comment for assertion
Add possible cause for a failed assertion.

gcc/ada/

	* gcc-interface/utils2.cc (build_simple_component_ref): Add
	comment on assertion.
2023-11-28 10:35:48 +01:00
Steve Baird
348cb1c015 ada: Error compiling reduction expression with overloaded reducer subprogram
In some cases involving a reduction expression with an overloaded reducer
subprogram, the accumulator type is not determined correctly. This can lead
to spurious compile-time errors.

gcc/ada/

	* exp_attr.adb (Expand_N_Attribute_Reference): In the case of a
	Reduce attribute reference, fix bugs in initializing Accum_Typ.
	The previous version was incorrect in the case where E1 refers to
	the first of multiple possible overload resolution candidates and
	that candidate does not turn out to be the right one. The previous
	version also had code to compute Accum_Typ via a different method
	if the initial computation turned out to yield a universal numeric
	type. Delete that initial computation and use the second method in
	all cases.
2023-11-28 10:35:48 +01:00
Gary Dismukes
1a2f4e332c ada: Errors on instance of Multiway_Trees with discriminated type
The compiler may report various type conflicts on an instantiation
of the generic package Ada.Containers.Multiway_Trees with an actual
for Element_Type that is a nonprivate actual type with discriminants
that has a discriminant-dependent component of a private type (such
as a Bounded_Vector type). The type errors occur on an aggregate
of the implementation type Tree_Node_Type within the body of
Multiway_Trees, where the aggregate has a box-defaulted association
for the Element component. (Such type errors could of course arise
in other cases of generic instantiations that follow a similar type
model.)

In the case where the discriminant-dependent component type has a
default-initialization procedure (init proc), the compiler was handling
box associations for such components by expanding the topmost box
association into subaggregates that themselves have box associations,
and didn't properly account for discriminant-dependent subcomponents of
private types. This could be fixed internally in Propagate_Discriminants,
but it seems that the entire machinery for dealing with such subcomponent
associations is unnecessary, and the topmost component association can
be handled directly as a default-initialized box association.

gcc/ada/

	* sem_aggr.adb (Add_Discriminant_Values): Remove this procedure.
	(Propagate_Discriminants): Remove this procedure.
	(Resolve_Record_Aggregate): Remove code (the Capture_Discriminants
	block statement) related to propagating discriminants and
	generating initializations for subcomponents of a
	discriminant-dependent box-defaulted subcomponent of a nonprivate
	record type with discriminants, and handle all top-level
	components that have a non-null base init proc directly, by
	calling Add_Association with "Is_Box_Present => True". Also,
	combine that elsif clause with the immediately preceding elsif
	clause, since they now both contain the same statement (calls to
	Add_Association with the same actuals).
2023-11-28 10:35:48 +01:00
Bob Duff
ecdcb83025 ada: False alarms from -gnatw.t with generic functions
Disable the warnings generated by -gnatw.t on instances.
Otherwise, we get false positives.

gcc/ada/

	* sem_util.adb (Check_Result_And_Post_State): Disable this when
	we're in an instance. Misc cleanup.
2023-11-28 10:35:48 +01:00
Eric Botcazou
39cb85867d ada: Further cleanup in finalization machinery
When transient scopes are being materialized, they can give rise to a block
created around the construct being wrapped or not, depending on the kind of
construct.  In both cases finalization actions for the transient objects of
the scope are generated the same way, with normal finalization done manually
immediately after the construct and exceptional finalization deferred to the
enclosing scope by means of a hooking mechanism.

Now when the block is generated, it becomes this enclosing scope, so the
normal finalization that comes with it would also be done immediately after
the construct, even without normal finalization generated manually.

Therefore this change gets rid of the manual finalization as well as of the
hooking in the cases where the block is generated, leading to a significant
streamlining of the expanded code in these cases.  This requires fixing a
small inaccuracy of the Within_Case_Or_If_Expression predicate, which must
only be concerned with the dependent expressions, since those are the only
ones to be treated specially by the finalization machinery.

It also contains a small cleanup for the description of the transient scope
management present at the beginning of the exp_ch7.adb file.

gcc/ada/

	* exp_ch7.ads (Expand_Cleanup_Actions): Move declaration to the
	Finalization Management section.
	* exp_ch7.adb (Transient Scope Management): Move description down to
	after that of the general finalization and make a few changes.
	(Insert_Actions_In_Scope_Around): Call Process_Transients_In_Scope
	only if cleanups are being handled.
	(Process_Transients_In_Scope): Remove redundant test on Clean.
	* exp_util.ads (Within_Case_Or_If_Expression): Adjust description.
	* exp_util.adb (Within_Case_Or_If_Expression): Only return true if
	within the dependent expressions of the conditional expressions.
2023-11-28 10:35:48 +01:00
Eric Botcazou
1954686718 ada: Fix incorrect quoting in documentation
gcc/ada/

	* doc/gnat_rm/the_implementation_of_standard_i_o.rst: Fix a couple
	occurrences of incorrect quoting.
	* gnat_rm.texi: Regenerate.
2023-11-28 10:35:48 +01:00
Eric Botcazou
f6bbf84ec7 ada: Fix premature finalization for nested return within extended one
The return object is incorrectly finalized when the nested return is taken,
because the special flag attached to the return object is not updated.

gcc/ada/

	* exp_ch6.adb (Build_Flag_For_Function): New function made up of the
	code building the special flag for return object present...
	(Expand_N_Extended_Return_Statement): ...in there.  Replace the code
	with a call to Build_Flag_For_Function.  Add assertion for the flag.
	(Expand_Non_Function_Return): For a nested return, if the return
	object needs finalization actions, update the special flag.
2023-11-28 10:35:47 +01:00
Sebastian Poeplau
d2f2b9e6f9 ada: Add new predicate Is_Address_Compatible_Type
When emitting code for architectures with tagged pointers, it is useful
to be able to recognize values representing addresses because they
require special handling. This commits adds the predicate
Is_Address_Compatible_Type, which differs from the node attribute
Is_Descendant_Of_Address by also taking Standard_Address into account.

gcc/ada/

	* einfo-utils.ads, einfo-utils.adb (Is_Address_Compatible_Type):
	New function.
2023-11-28 10:35:47 +01:00
Gary Dismukes
8ba9430bc4 ada: Type error on container aggregate with loop_parameter_specification
The compiler incorrectly reported a type error on a container aggregate
for a Vector type with a loop_parameter_specification specifying a
nonstatic upper bound, complaining that it expected the Vector index
type, but instead found type Count_Type. The expansion of the aggregate
was incorrectly passing a size temporary of type Count_Type to the
function associated with the New_Indexed part of the container type's
Aggregate aspect (New_Vector in the case of Vectors), which has two
formals of the container index type. The fix is to convert the size
temporary to the expected index type.

gcc/ada/

	* exp_aggr.adb (Expand_Container_Aggregate): Apply a conversion to the
	size temp object passed as the second actual parameter on the call to
	the New_Indexed_Subp function, to convert it to the index type of the
	container type (taken from the first formal parameter of the function).
2023-11-28 10:35:47 +01:00
Eric Botcazou
e95a42ec9a ada: Fix internal error on declare expression in expression function
When the expression function is not a completion, its (return) expression
does not cause freezing so analyzing the declare expression in this context
must not freeze the type of the object.

The change also contains another fix, which makes it so that the compiler
does not evaluate a nonstatic representation attribute of a scalar subtype
in the same context if the subtype is not already frozen.

gcc/ada/

	* sem_attr.adb (Eval_Attribute): Do not proceed in a spec expression
	for nonstatic representation attributes of a scalar subtype when the
	subtype is not frozen.
	* sem_ch3.adb (Analyze_Object_Declaration): Do not freeze the type
	of the object in a spec expression.
2023-11-28 10:35:47 +01:00
Richard Kenner
89ed545585 ada: Handle unchecked conversion in bound
Look through both unchecked and normal conversions when seeing if any
part of a bound is uplevel.

gcc/ada/

	* exp_unst.adb (Note_Uplevel_Bound): Treat
	N_Unchecked_Type_Conversion like N_Type_Conversion.
2023-11-28 10:35:47 +01:00
Yannick Moy
73ecd592c9 ada: Remove dependency on System.Val_Bool in System.Img_Bool
In order to facilitate the certification of System.Img_Bool, remove
its dependency on unit System.Val_Bool. Modify the definition of
ghost function Is_Boolean_Image_Ghost to take the expected boolean
value and move it to System.Val_Spec.

gcc/ada/

	* libgnat/s-imgboo.adb: Remove with_clause now in spec file.
	* libgnat/s-imgboo.ads: Remove dependency on System.Val_Bool.
	(Image_Boolean): Replace call to Value_Boolean by passing value V
	to updated ghost function Is_Boolean_Image_Ghost.
	* libgnat/s-valboo.ads (Is_Boolean_Image_Ghost): Move to other
	unit.
	(Value_Boolean.): Update precondition.
	* libgnat/s-valspe.ads (Is_Boolean_Image_Ghost): Move here. Add
	new parameter for expected boolean value.
2023-11-28 10:35:47 +01:00
Tucker Taft
834f297360 ada: Fix predicate failure that occurred in a test case
The CodePeer test case illustrating a problem where a "high"
precondition failure was expected, died in the GNAT FE on
input_reading.adb.  The problem was in Check_SCIL, where
it didn't properly handle a discriminant_specification.

gcc/ada/

	* sem_scil.adb: Handle discriminant specification.
2023-11-28 10:35:47 +01:00
Jakub Jelinek
e6c01334cc testsuite: Fix up pr111754.c test
On Tue, Nov 28, 2023 at 03:56:47PM +0800, juzhe.zhong@rivai.ai wrote:
> Hi, there is a regression in RISC-V caused by this patch:
>
> FAIL: gcc.dg/vect/pr111754.c -flto -ffat-lto-objects  scan-tree-dump optimized "return { 0.0, 9.0e\\+0, 0.0, 0.0 }"
> FAIL: gcc.dg/vect/pr111754.c scan-tree-dump optimized "return { 0.0, 9.0e\\+0, 0.0, 0.0 }"
>
> I have checked the dump is :
> F foo (F a, F b)
> {
>   <bb 2> [local count: 1073741824]:
>   <retval> = { 0.0, 9.0e+0, 0.0, 0.0 };
>   return <retval>;
>
> }
>
> The dump IR seems reasonable to me.
> I wonder whether we should walk around in RISC-V backend to generate the same IR as ARM SVE ?
> Or we should adjust the test ?

Note, the test also FAILs on i686-linux (but not e.g. on x86_64-linux):
/home/jakub/src/gcc/obj67/gcc/xgcc -B/home/jakub/src/gcc/obj67/gcc/ /home/jakub/src/gcc/gcc/testsuite/gcc.dg/vect/pr111754.c -fdiagnostics-plain-output -O2 -fdump-tree-optimized -S
+-o pr111754.s
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/vect/pr111754.c: In function 'foo':
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/vect/pr111754.c:7:1: warning: SSE vector return without SSE enabled changes the ABI [-Wpsabi]
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/vect/pr111754.c:6:3: note: the ABI for passing parameters with 16-byte alignment has changed in GCC 4.6
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/vect/pr111754.c:6:3: warning: SSE vector argument without SSE enabled changes the ABI [-Wpsabi]
FAIL: gcc.dg/vect/pr111754.c (test for excess errors)
Excess errors:
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/vect/pr111754.c:7:1: warning: SSE vector return without SSE enabled changes the ABI [-Wpsabi]
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/vect/pr111754.c:6:3: warning: SSE vector argument without SSE enabled changes the ABI [-Wpsabi]

PASS: gcc.dg/vect/pr111754.c scan-tree-dump-not optimized "VEC_PERM_EXPR"
FAIL: gcc.dg/vect/pr111754.c scan-tree-dump optimized "return { 0.0, 9.0e\\+0, 0.0, 0.0 }"

So, I think it is wrong to specify
/* { dg-options "-O2 -fdump-tree-optimized" } */
in the test, should be dg-additional-options instead, so that it gets
the implied vector compilation options e.g. for i686-linux (-msse2 in that
case at least), question is if -Wno-psabi should be added as well or not,
and certainly the scan-tree-dump needs to be guarded by appropriate
vect_* effective target (but dunno which, one which asserts support for
V4SFmode and returning it).
Alternatively, perhaps don't check optimized dump but some earlier one
before generic vector lowering, then hopefully it could match on all
targets?  Maybe with the <retval> = ... vs. return ... variants.

2023-11-28  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/111754
	* gcc.dg/vect/pr111754.c: Use dg-additional-options rather than
	dg-options, add -Wno-psabi and use -fdump-tree-forwprop1 rather than
	-fdump-tree-optimized.  Scan forwprop1 dump rather than optimized and
	scan for either direct return or setting of <retval> to the vector.
2023-11-28 10:16:47 +01:00
Jakub Jelinek
f1b03fa964 match.pd: Fix parity (X) ^ parity (Y) simplification [PR112719]
When looking around, I've noticed we have a similar simplification
for parity (with ^ rather than +).  Note, unlike the popcount one,
this one doesn't check for INTEGRAL_TYPE_P (type) (which rules out
vector simplification), so I've used the old handling for types_match and
otherwise do it only for scalar argument types and handle different
precision in there.

The testcase ICEs without the previous patch on the first function,
but strangely not on the second which tests parity.  The reason
is that in this case there is no wi::bit_and test like for popcount
and for BITINT_TYPEs build_call_internal actually refuses to create it
and thus the whole simplification fails.  While
.{CLZ,CTZ,CLRSB,FFS,POPCOUNT,PARITY} ifns are direct optab ifns for
normal integer and vector types (and thus it is desirable to punt if
there is no supported optab for them), they have this large/huge _BitInt
extension before bitint lowering, so the patch also adjusts
build_call_internal to allow that case.

2023-11-28  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/112719
	* match.pd (parity(X)^parity(Y) -> parity(X^Y)): Handle case of
	mismatched types.
	* gimple-match-exports.cc (build_call_internal): Add special-case for
	bit query ifns on large/huge BITINT_TYPE before bitint lowering.

	* gcc.dg/bitint-43.c: New test.
2023-11-28 10:15:52 +01:00
Jakub Jelinek
03877e7ecc match.pd: Fix popcount (X) + popcount (Y) simplification [PR112719]
Since my PR112566 r14-5557 changes the following testcase ICEs, because
.POPCOUNT (x) + .POPCOUNT (y) has a simplification attempted even when
x and y have incompatible types (different precisions).
Note, with _BitInt it can ICE already starting with r14-5435 and
I think as a latent problem it exists for years, because IFN_POPCOUNT
calls inherently can have different argument types and return type
is always the same.
The following patch fixes it by using widest_int during the analysis
(which is where it was ICEing) and if it is optimizable, casting to
the wider type so that bit_ior has matching argument types.

2023-11-28  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/112719
	* match.pd (popcount (X) + popcount (Y) -> POPCOUNT (X | Y)): Deal
	with argument types with different precisions.
2023-11-28 10:14:55 +01:00
David Malcolm
594ef1ff70 analyzer: install header files for use by plugins [PR109077]
PLUGIN_ANALYZER_INIT was added in r11-5583-g66dde7bc64b75d, but we
haven't been installing the analyzer's headers files.

Fixed thusly.

gcc/ChangeLog:
	PR analyzer/109077
	* Makefile.in (PLUGIN_HEADERS): Add analyzer headers.
	(install-plugin): Keep the directory structure for files in
	"analyzer".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-11-28 03:20:02 -05:00
Lewis Hyatt
ce52f1f707 libcpp: Fix unsigned promotion for unevaluated divide by zero [PR112701]
When libcpp encounters a divide by zero while processing a constant
expression "x/y", it returns "x" as a fallback. The value of the fallback is
not normally important, since an error will be generated anyway, but if the
expression appears in an unevaluated context, such as "0 ? 0/0u : -1", then
there will be no error, and the fallback value will be meaningful to the
extent that it may cause promotion from signed to unsigned of an operand
encountered later. As the PR notes, libcpp does not do the unsigned
promotion correctly in this case; fix it by making the fallback return value
unsigned as necessary.

libcpp/ChangeLog:

	PR preprocessor/112701
	* expr.cc (num_div_op): Set unsignedp appropriately when returning a
	stub value for divide by 0.

gcc/testsuite/ChangeLog:

	PR preprocessor/112701
	* gcc.dg/cpp/expr.c: Add additional tests to cover divide by 0 in an
	unevaluated context, where the unsignedness still matters.
2023-11-27 21:19:31 -05:00
Juzhe-Zhong
9c16ca9364 RISC-V: Fix VSETVL PASS regression
This patch is regression fix patch, not an optimization patch.
Since trunk GCC generates redundant vsetvl than GCC-13.

This is the case:

bb 2:
  def a2 (vsetvl a2, zero)
bb 3:
  use a2
bb 4:
  use a2 (vle)

before this patch:

bb 2:
vsetvl a2 zero
bb 3:
vsetvl zero, zero ----> should be eliminated.
bb 4:
vle.v

The root cause is we didn't set bb 3 as transparent since the incorrect codes.
bb 3 didn't modify "a2" just use it, the VSETVL status from bb 2 can be available to bb 3 and bb 4:

bb 2 -> bb 3 -> bb4.

Another regression fix is anticipation calculation:

bb 4:
use a5 (sub)
use a5 (vle)

The vle VSETVL status should be considered as anticipated as long as both sub and vle a5 def are coming from same def.

Tested on zvl128b no regression.

I am going to test on zvl256/zvl512/zvl1024

	PR target/112713

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc (pre_vsetvl::compute_lcm_local_properties): Fix regression.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/vsetvl/pr112713-1.c: New test.
	* gcc.target/riscv/rvv/vsetvl/pr112713-2.c: New test.
2023-11-28 10:10:55 +08:00
David Malcolm
5099525bff diagnostics: don't print annotation lines when there's no column info
gcc/ChangeLog:
	* diagnostic-show-locus.cc (layout::maybe_add_location_range):
	Don't print annotation lines for ranges when there's no column
	info.
	(selftest::test_one_liner_no_column): New.
	(selftest::test_diagnostic_show_locus_one_liner): Call it.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-11-27 20:09:35 -05:00
David Malcolm
93096d3ce1 diagnostics: add diagnostic_context::get_location_text
No functional change intended.

gcc/ChangeLog:
	* diagnostic.cc (diagnostic_get_location_text): Convert to...
	(diagnostic_context::get_location_text): ...this, and convert
	return type from char * to label_text.
	(diagnostic_build_prefix): Update for above change.
	(default_diagnostic_start_span_fn): Likewise.
	(selftest::assert_location_text): Likewise.
	* diagnostic.h (diagnostic_context::get_location_text): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-11-27 20:09:35 -05:00
GCC Administrator
ad3e759c17 Daily bump. 2023-11-28 00:17:28 +00:00
Andrew Pinski
d29d27bde5 aarch64: Improve cost of a ? {-,}1 : b
While looking into PR 112454, I found the cost for
`(if_then_else (cmp) (const_int 1) (reg))` was being recorded as 8
(or `COSTS_N_INSNS (2)`) but it should have been 4 (or `COSTS_N_INSNS (1)`).
This improves the cost by not adding the cost of `(const_int 1)` to
the total cost.

It does not does not fully fix PR 112454 as that requires other changes to forwprop
the `(const_int 1)` earlier than combine. Though we do fix the loop case where the
constant was only used once.

Bootstrapped and tested on aarch64-linux-gnu with no regressions.

gcc/ChangeLog:

	* config/aarch64/aarch64.cc (aarch64_if_then_else_costs):
	Handle csinv/csinc case of 1/-1.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/csinc-3.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2023-11-27 23:11:35 +00:00
Andrew Pinski
cd2519a6f8 Fix time-profiler-3.c after r14-5628-g53ba8d669550d3
This testcase started to fail after r14-5628-g53ba8d669550d3 because
IPA-VRP can now start to figure out the functions return a constant
value and there was nothing that profiling needed to profile any more.
This disables IPA-VRP for this testcase to be able to profile again.

Bootrapped/tested on x86_64-linux-gnu with no regressions.

gcc/testsuite/ChangeLog:

	PR testsuite/112689
	* gcc.dg/tree-prof/time-profiler-3.c: Add -fno-ipa-vrp.
2023-11-27 14:59:56 -08:00
Richard Earnshaw
eecdd96c8d arm: libgcc: tweak warning from __sync_synchronize
My previous patch to add an implementation of __sync_syncrhonize with
a warning trips a testsuite failure in fortran (and possibly other
languages as well) as the framework expects no blank lines in the
output, but this warning was generating one.  So remove the newline
from the end of the message and rely on the one added by the linker
instead.

Since we're there, remove the trailing period from the message as
well, since the convention seems to be not to have one.

libgcc/

	* config/arm/lib1funcs.S (__sync_synchronize): Adjust warning message.
2023-11-27 18:00:33 +00:00
Prathamesh Kulkarni
2065438db4 PR111754: Rework encoding of result for VEC_PERM_EXPR with constant input vectors.
gcc/ChangeLog:
	PR middle-end/111754
	* fold-const.cc (fold_vec_perm_cst): Set result's encoding to sel's
	encoding, and set res_nelts_per_pattern to 2 if sel contains stepped
	sequence but input vectors do not.
	(test_nunits_min_2): New test Case 8.
	(test_nunits_min_4): New tests Case 8 and Case 9.

gcc/testsuite/ChangeLog:
	PR middle-end/111754
	* gcc.target/aarch64/sve/slp_3.c: Adjust code-gen.
	* gcc.target/aarch64/sve/slp_4.c: Likewise.
	* gcc.dg/vect/pr111754.c: New test.

Co-authored-by: Richard Sandiford <richard.sandiford@arm.com>
2023-11-27 22:40:49 +05:30
Szabolcs Nagy
c9d691a7da aarch64: Disable branch-protection for pcs tests
The tests manipulate the return address in abitest-2.h and thus not
compatible with -mbranch-protection=pac-ret+leaf or
-mbranch-protection=gcs.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/aapcs64/func-ret-1.c: Disable branch-protection.
	* gcc.target/aarch64/aapcs64/func-ret-2.c: Likewise.
	* gcc.target/aarch64/aapcs64/func-ret-3.c: Likewise.
	* gcc.target/aarch64/aapcs64/func-ret-4.c: Likewise.
	* gcc.target/aarch64/aapcs64/func-ret-64x1_1.c: Likewise.
2023-11-27 15:52:49 +00:00
Szabolcs Nagy
cad7e1e3e0 aarch64: Add eh_return compile tests
gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/eh_return-2.c: New test.
	* gcc.target/aarch64/eh_return-3.c: New test.
2023-11-27 15:52:48 +00:00
Szabolcs Nagy
aa2ad77a9b aarch64: Do not force a stack frame for EH returns
EH returns no longer rely on clobbering the return address on the stack
so forcing a stack frame is not necessary.

This does not actually change the code gen for the unwinder since there
are calls before the EH return.

gcc/ChangeLog:

	* config/aarch64/aarch64.cc (aarch64_needs_frame_chain): Do not
	force frame chain for eh_return.
2023-11-27 15:52:48 +00:00
Szabolcs Nagy
426fddcbda aarch64: Use br instead of ret for eh_return
The expected way to handle eh_return is to pass the stack adjustment
offset and landing pad address via

  EH_RETURN_STACKADJ_RTX
  EH_RETURN_HANDLER_RTX

to the epilogue that is shared between normal return paths and the
eh_return paths.  EH_RETURN_HANDLER_RTX is the stack slot of the
return address that is overwritten with the landing pad in the
eh_return case and EH_RETURN_STACKADJ_RTX is a register added to sp
right before return and it is set to 0 in the normal return case.

The issue with this design is that eh_return and normal return may
require different return sequence but there is no way to distinguish
the two cases in the epilogue (the stack adjustment may be 0 in the
eh_return case too).

The reason eh_return and normal return requires different return
sequence is that control flow integrity hardening may need to treat
eh_return as a forward-edge transfer (it is not returning to the
previous stack frame) and normal return as a backward-edge one.
In case of AArch64 forward-edge is protected by BTI and requires br
instruction and backward-edge is protected by PAUTH or GCS and
requires ret (or authenticated ret) instruction.

This patch resolves the issue by introducing EH_RETURN_TAKEN_RTX that
is a flag set to 1 in the eh_return path and 0 in normal return paths.
Branching on the EH_RETURN_TAKEN_RTX flag, the right return sequence
can be used in the epilogue.

The handler could be passed the old way via clobbering the return
address, but since now the eh_return case can be distinguished, the
handler can be in a different register than x30 and no stack frame
is needed for eh_return.

This patch fixes a return to anywhere gadget in the unwinder with
existing standard branch protection as well as makes EH return
compatible with the Guarded Control Stack (GCS) extension.

Some tests are adjusted because eh_return no longer prevents pac-ret
in the normal return path.

gcc/ChangeLog:

	* config/aarch64/aarch64-protos.h (aarch64_eh_return_handler_rtx):
	Remove.
	* config/aarch64/aarch64.cc (aarch64_return_address_signing_enabled):
	Sign return address even in functions with eh_return.
	(aarch64_expand_epilogue): Conditionally return with br or ret.
	(aarch64_eh_return_handler_rtx): Remove.
	* config/aarch64/aarch64.h (EH_RETURN_TAKEN_RTX): Define.
	(EH_RETURN_STACKADJ_RTX): Change to R5.
	(EH_RETURN_HANDLER_RTX): Change to R6.
	* df-scan.cc: Handle EH_RETURN_TAKEN_RTX.
	* doc/tm.texi: Regenerate.
	* doc/tm.texi.in: Document EH_RETURN_TAKEN_RTX.
	* except.cc (expand_eh_return): Handle EH_RETURN_TAKEN_RTX.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/return_address_sign_1.c: Move func4 to ...
	* gcc.target/aarch64/return_address_sign_2.c: ... here and fix the
	scan asm check.
	* gcc.target/aarch64/return_address_sign_b_1.c: Move func4 to ...
	* gcc.target/aarch64/return_address_sign_b_2.c: ... here and fix the
	scan asm check.
2023-11-27 15:52:48 +00:00
Thomas Schwinge
f723f72061 GCN: Remove 'last_arg' spec function
The LLVM 13.0.1 assembler ('llvm-mc') indeed still does complain in presence of
multiple '-mcpu=[...]' options:

    as: for the --mcpu option: may only occur zero or one times!

However, as of
"GCN: Tag '-march=[...]', '-mtune=[...]' as 'Negative' of themselves [PR112669]",
the GCC-side special handling is no longer necessary.

	gcc/
	* config.gcc <amdgcn-*-amdhsa> (extra_gcc_objs): Don't set.
	* config/gcn/driver-gcn.cc: Remove.
	* config/gcn/gcn-hsa.h (ASM_SPEC, EXTRA_SPEC_FUNCTIONS): Remove
	'last_arg' spec function.
	* config/gcn/t-gcn-hsa (driver-gcn.o): Remove.
2023-11-27 15:54:35 +01:00
Thomas Schwinge
297fe5c166 GCN: Tag '-march=[...]', '-mtune=[...]' as 'Negative' of themselves [PR112669]
Certain other command-line flags are mutually exclusive (random example: GCN
'-march=gfx906', '-march=gfx908').  If they're not appropriately marked up,
this does disturb the multilib selection machinery, for example:

    $ build-gcc-offload-amdgcn-amdhsa/gcc/xgcc -print-multi-directory -march=gfx906
    gfx906
    $ build-gcc-offload-amdgcn-amdhsa/gcc/xgcc -print-multi-directory -march=gfx908
    gfx908
    $ build-gcc-offload-amdgcn-amdhsa/gcc/xgcc -print-multi-directory -march=gfx906 -march=gfx908
    .

In the last invocation, '-march=gfx900 -march=gfx906', for example, in
'gcc/gcc.cc:set_multilib_dir' we see both flags -- which there doesn't exist a
matching multilib for, therefore we "fail" to the default ('.').  Tagges as
'Negative', only the last flag survives, and we, for example, get the expected:

    $ build-gcc-offload-amdgcn-amdhsa/gcc/xgcc -print-multi-directory -march=gfx906 -march=gfx908
    gfx908

I quickly found that the same also applies to GCN's '-mtune=[...]', but I've
not otherwise reviewed the GCN options.

	PR target/112669
	gcc/
	* config/gcn/gcn.opt (march=, mtune=): Tag as 'Negative' of
	themselves.
2023-11-27 15:54:30 +01:00
Samuel Thibault
c768917402 hurd: Ad default-pie and static-pie support
This fixes the Hurd spec in the default-pie case, and adds static-pie
support.

gcc/ChangeLog:

	* config/i386/gnu.h: Use PIE_SPEC, add static-pie case.
	* config/i386/gnu64.h: Use PIE_SPEC, add static-pie case.
2023-11-27 15:44:53 +01:00
Samuel Thibault
5707e9db9c hurd: Add multilib paths for gnu-x86_64
We need the multilib paths in gcc to find e.g. glibc crt files on
Debian.  This is essentially based on t-linux64 version.

gcc/ChangeLog:

	* config/i386/t-gnu64: New file.
	* config.gcc [x86_64-*-gnu*]: Add i386/t-gnu64 to
	tmake_file.
2023-11-27 15:44:53 +01:00
Richard Sandiford
e09007308c aarch64: Remove redundant zeroing/merging in SVE intrinsics [PR106326]
Many predicated SVE intrinsics provide three forms of predication:
zeroing, merging, and any/dont-care.  All three are equivalent when
the predicate is all-true, so this patch drops the zeroing and
merging in that case.

gcc/
	PR target/106326
	* config/aarch64/aarch64-sve-builtins.h (is_ptrue): Declare.
	* config/aarch64/aarch64-sve-builtins.cc (is_ptrue): New function.
	(gimple_folder::redirect_pred_x): Likewise.
	(gimple_folder::fold): Use it.

gcc/testsuite/
	PR target/106326
	* gcc.target/aarch64/sve/acle/general/pr106326_1.c: New test.
2023-11-27 14:44:02 +00:00
Richard Sandiford
31e9074977 aarch64: Move and generalise vect_all_same
The fix for PR106329 needs a way of testing for a ptrue of a particular
element size.  We already had such a function for svlast, so this patch
moves it to common code and generalises it to work with all kinds of
vectors.

gcc/
	* config/aarch64/aarch64-sve-builtins.h (vector_cst_all_same): Declare.
	* config/aarch64/aarch64-sve-builtins.cc (vector_cst_all_same): New
	function, a generalized replacement of...
	* config/aarch64/aarch64-sve-builtins-base.cc
	(svlast_impl::vect_all_same): ...this.
	(svlast_impl::fold): Update accordingly.
2023-11-27 14:44:02 +00:00
Richard Biener
f7884f7673 tree-optimization/112653 - PTA and return
The following separates the escape solution for return stmts not
only during points-to solving but also for later querying.  This
requires adjusting the points-to-global tests to include escapes
through returns.  Technically the patch replaces the existing
post-processing which computes the transitive closure of the
returned value solution by a proper artificial variable with
transitive closure constraints.  Instead of adding the solution
to escaped we track it separately.

	PR tree-optimization/112653
	* gimple-ssa.h (gimple_df): Add escaped_return solution.
	* tree-ssa.cc (init_tree_ssa): Reset it.
	(delete_tree_ssa): Likewise.
	* tree-ssa-structalias.cc (escaped_return_id): New.
	(find_func_aliases): Handle non-IPA return stmts by
	adding to ESCAPED_RETURN.
	(set_uids_in_ptset): Adjust HEAP escaping to also cover
	escapes through return.
	(init_base_vars): Initialize ESCAPED_RETURN.
	(compute_points_to_sets): Replace ESCAPED post-processing
	with recording the ESCAPED_RETURN solution.
	* tree-ssa-alias.cc (ref_may_alias_global_p_1): Check
	the ESCAPED_RETUNR solution.
	(dump_alias_info): Dump it.
	* cfgexpand.cc (update_alias_info_with_stack_vars): Update it.
	* ipa-icf.cc (sem_item_optimizer::fixup_points_to_sets):
	Likewise.
	* tree-inline.cc (expand_call_inline): Reset it.
	* tree-parloops.cc (parallelize_loops): Likewise.
	* tree-sra.cc (maybe_add_sra_candidate): Check it.

	* gcc.dg/tree-ssa/pta-return-1.c: New testcase.
2023-11-27 15:35:12 +01:00
Richard Sandiford
061a82fa2b vect: Avoid duplicate_and_interleave for uniform vectors [PR112661]
can_duplicate_and_interleave_p checks whether we know a way of
building a particular VLA SLP invariant.  g:60034ecf25597bd515f
skipped that test for booleans, to support MASK_LEN_GATHER_LOAD
calls with a dummy all-ones mask.  But there's nothing fundamentally
different about VLA masks vs VLA data vectors.  If we have a VLA mask
that isn't all-ones, we need some way of loading it.  This ultimately
led to the ICE in the PR.

This patch fixes it by applying can_duplicate_and_interleave_p
to masks, while also adding a special path for uniform vectors
(of all kinds) to support the MASK_LEN_GATHER_LOAD usage.  This
also fixes an XFAIL in pr36648.cc for SVE.

The patch is mostly Richard's.  My only changes were to skip
redundant conversions and to use gimple_build_vector_from_val
for all eligible vectors.

2023-11-27  Richard Biener  <rguenther@suse.de>
	    Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	PR tree-optimization/112661
	* tree-vect-slp.cc (vect_get_and_check_slp_defs): Defer duplicate-and-
	interleave test to...
	(vect_build_slp_tree_2): ...here, once we have all the operands.
	Skip the test for uniform vectors.
	(vect_create_constant_vectors): Detect uniform vectors.  Avoid
	redundant conversions in that case.  Use gimple_build_vector_from_val
	to build the vector.

gcc/testsuite/
	* g++.dg/vect/pr36648.cc: Remove XFAIL for VLA load-lanes.
2023-11-27 13:38:16 +00:00
Richard Sandiford
5b33cf3a3a attribs: Use existing traits for excl_hash_traits
excl_hash_traits can be defined more simply by reusing existing traits.

gcc/
	* attribs.cc (excl_hash_traits): Delete.
	(test_attribute_exclusions): Use pair_hash and nofree_string_hash
	instead.
2023-11-27 13:38:16 +00:00
Andrew Stubbs
e7d3414dff amdgcn: Disallow TImode vector permute
We don't support it and it doesn't happen without vector extensions, so
just remove the unhandled case.

Fixes gcc.dg/pr78575.c failure.

gcc/ChangeLog:

	* config/gcn/gcn.cc (gcn_vectorize_vec_perm_const): Disallow TImode.
2023-11-27 13:36:09 +00:00
Stefan Schulze Frielinghaus
965d232799 s390: Add missing builtin type
One builtin type slipped through the cracks of the last commits.

gcc/ChangeLog:

	* config/s390/s390-builtin-types.def (BT_FN_UV8HI_UV8HI_UINT):
	Add missing builtin type.
2023-11-27 13:26:51 +01:00
Stefan Schulze Frielinghaus
d1818e2f16 s390: Fixup builtins vec_rli and verll
Commit 248df13b96 restricted the rotate
count to immediates.  Although the documentation of vec_rli (Vector
Element Rotate Left Immediate) can be read as if it where restricted to
immediates, this is not the case.  Thus, revert this commit.

In order to finally allow register operands, the rotate count must be of
type unsigned char since the expander expects it to be of mode QI.  The
previously used type unsigned integer worked out for immediates since
those are of VOID mode anyway.

gcc/ChangeLog:

	* config/s390/s390-builtin-types.def: Remove types.
	* config/s390/s390-builtins.def (O_U64): Remove 64-bit literal support.
	Don't restrict s390_vec_rli and s390_verll[bhfg] to immediates.
	* config/s390/s390.cc (s390_const_operand_ok): Remove 64-bit
	literal support.
2023-11-27 12:51:39 +01:00
Alex Coplan
06280a906c c-family: Implement __has_feature and __has_extension [PR60512]
This patch implements clang's __has_feature and __has_extension in GCC.
Currently the patch aims to implement all documented features (and some
undocumented ones) following the documentation at
https://clang.llvm.org/docs/LanguageExtensions.html with the exception
of the legacy features for C++ type traits.  These are omitted, since as
the clang documentation notes, __has_builtin is the correct "modern" way
to query for these (which GCC already implements).

gcc/c-family/ChangeLog:

	PR c++/60512
	* c-common.cc (struct hf_feature_info): New.
	(c_common_register_feature): New.
	(init_has_feature): New.
	(has_feature_p): New.
	* c-common.h (c_common_has_feature): New.
	(c_family_register_lang_features): New.
	(c_common_register_feature): New.
	(has_feature_p): New.
	* c-lex.cc (init_c_lex): Plumb through has_feature callback.
	(c_common_has_builtin): Generalize and move common part ...
	(c_common_lex_availability_macro): ... here.
	(c_common_has_feature): New.
	* c-ppoutput.cc (init_pp_output): Plumb through has_feature.

gcc/c/ChangeLog:

	PR c++/60512
	* c-lang.cc (c_family_register_lang_features): New.
	* c-objc-common.cc (struct c_feature_info): New.
	(c_register_features): New.
	* c-objc-common.h (c_register_features): New.

gcc/cp/ChangeLog:

	PR c++/60512
	* cp-lang.cc (c_family_register_lang_features): New.
	* cp-objcp-common.cc (struct cp_feature_selector): New.
	(cp_feature_selector::has_feature): New.
	(struct cp_feature_info): New.
	(cp_register_features): New.
	* cp-objcp-common.h (cp_register_features): New.

gcc/ChangeLog:

	PR c++/60512
	* doc/cpp.texi: Document __has_{feature,extension}.

gcc/objc/ChangeLog:

	PR c++/60512
	* objc-act.cc (struct objc_feature_info): New.
	(objc_nonfragile_abi_p): New.
	(objc_common_register_features): New.
	* objc-act.h (objc_common_register_features): New.
	* objc-lang.cc (c_family_register_lang_features): New.

gcc/objcp/ChangeLog:

	PR c++/60512
	* objcp-lang.cc (c_family_register_lang_features): New.

libcpp/ChangeLog:

	PR c++/60512
	* include/cpplib.h (struct cpp_callbacks): Add has_feature.
	(enum cpp_builtin_type): Add BT_HAS_{FEATURE,EXTENSION}.
	* init.cc: Add __has_{feature,extension}.
	* macro.cc (_cpp_builtin_macro_text): Handle
	BT_HAS_{FEATURE,EXTENSION}.

gcc/testsuite/ChangeLog:

	PR c++/60512
	* c-c++-common/has-feature-common.c: New test.
	* c-c++-common/has-feature-pedantic.c: New test.
	* g++.dg/ext/has-feature.C: New test.
	* gcc.dg/asan/has-feature-asan.c: New test.
	* gcc.dg/has-feature.c: New test.
	* gcc.dg/ubsan/has-feature-ubsan.c: New test.
	* obj-c++.dg/has-feature.mm: New test.
	* objc.dg/has-feature.m: New test.

Co-Authored-By: Iain Sandoe <iain@sandoe.co.uk>
2023-11-27 10:42:55 +00:00
Richard Biener
d9abaa8d58 tree-optimization/112706 - missed simplification of condition
We lack a match.pd pattern recognizing ptr + o ==/!= ptr + o'.
The following extends handling we have for integral types to
pointers.

	PR tree-optimization/112706
	* match.pd (ptr + o ==/!=/- ptr + o'): New patterns.

	* gcc.dg/tree-ssa/pr112706.c: New testcase.
2023-11-27 10:39:59 +01:00
Stefan Schulze Frielinghaus
8e4db85eca s390: Streamline NNPA builtins with their LLVM counterparts
For the opaque NNP-data type prefer unsigned over signed integer types.

gcc/ChangeLog:

	* config/s390/s390-builtin-types.def: Add/remove types.
	* config/s390/s390-builtins.def
	(s390_vclfnhs,s390_vclfnls,s390_vcrnfs,s390_vcfn,s390_vcnf):
	Replace type V8HI with UV8HI.

gcc/testsuite/ChangeLog:

	* gcc.target/s390/zvector/vec-nnpa-fp16-convert.c: Replace V8HI
	types with UV8HI.
	* gcc.target/s390/zvector/vec-nnpa-fp32-convert-1.c: Dito.
	* gcc.target/s390/zvector/vec_convert_from_fp16.c: Dito.
	* gcc.target/s390/zvector/vec_convert_to_fp16.c: Dito.
	* gcc.target/s390/zvector/vec_extend_to_fp32_hi.c: Dito.
	* gcc.target/s390/zvector/vec_extend_to_fp32_lo.c: Dito.
	* gcc.target/s390/zvector/vec_round_from_fp32.c: Dito.
2023-11-27 10:30:54 +01:00
Stefan Schulze Frielinghaus
a4787a926c s390: Fix builtins floating-point convert to/from fixed
Remove flags for non-existing operands 2 and 3.

gcc/ChangeLog:

	* config/s390/s390-builtins.def
	(s390_vcefb,s390_vcdgb,s390_vcelfb,s390_vcdlgb,s390_vcfeb,s390_vcgdb,
	s390_vclfeb,s390_vclgdb): Remove flags for non-existing operands
	2 and 3.
2023-11-27 10:26:05 +01:00
Stefan Schulze Frielinghaus
74a7bb2c50 s390: Fix constraint for insn *cmphi_ccu
Currently for an unsigned 16-bit comparison between memory and an
immediate where the high bit is set, a clc is emitted.  This is because
the constant is created for mode HI and therefore sign extended.  This
means constraint D does not hold anymore.  Since the mode already
restricts the immediate to 16 bit, it is enough to make use of
constraint n and chop of the high bits in the output template.

gcc/ChangeLog:

	* config/s390/s390.md (*cmphi_ccu): For immediate operand 1 make
	use of constraint n instead of D and chop of high bits in the
	output template.
2023-11-27 10:23:17 +01:00
Jakub Jelinek
221166ad15 mips: Fix up mips*-sde-elf* build [PR112300]
As reported in the PR, mipsisa64r2-sde-elf doesn't build because HEAP_TRAMPOLINES_INIT
macro isn't defined anywhere.
It is normally defined by
 # Figure out if we need to enable heap trampolines by default
 case ${target} in
 *-*-darwin2*)
   # Currently, we do this for macOS 11 and above.
   tm_defines="$tm_defines HEAP_TRAMPOLINES_INIT=1"
   ;;
 *)
   tm_defines="$tm_defines HEAP_TRAMPOLINES_INIT=0"
   ;;
 esac
in config.gcc, but mips*-sde-elf* is the only target which overwrites
tm_defines shell variable rather than just appending to it (or in one case
prepending), all other targets append something to it, including other
mips* triplets.
I believe (just from looking at config.gcc) that the difference is that
LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4 HEAP_TRAMPOLINES_INIT=0
isn't defined without the patch and is with the patch.

I think defining those first 4 shouldn't cause any harm and defining the
last one is required for it to actually build at all.

2023-11-27  Jakub Jelinek  <jakub@redhat.com>

	PR target/112300
	* config.gcc (mips*-sde-elf*): Append to tm_defines rather than
	overwriting them.
2023-11-27 09:22:20 +01:00