Commit graph

196780 commits

Author SHA1 Message Date
Kwok Cheung Yeung
cb0a2b1f28 amdgcn: Fix expansion of GCN_BUILTIN_LDEXPV builtin
2022-11-08  Kwok Cheung Yeung  <kcy@codesourcery.com>

	gcc/
	* config/gcn/gcn.cc (gcn_expand_builtin_1): Expand first argument
	of GCN_BUILTIN_LDEXPV to V64DFmode.
2022-11-08 14:52:12 +00:00
Kwok Cheung Yeung
ee2be8f3a4 amdgcn: Add builtins for vectorized native versions of abs, floorf and floor
2022-11-08  Kwok Cheung Yeung  <kcy@codesourcery.com>

	gcc/
	* config/gcn/gcn-builtins.def (FABSV, FLOORVF, FLOORV): New builtins.
	* config/gcn/gcn.cc (gcn_expand_builtin_1): Expand GCN_BUILTIN_FABSV,
	GCN_BUILTIN_FLOORVF and GCN_BUILTIN_FLOORV.

	gcc/testsuite/
	* gcc.target/gcn/math-builtins-1.c: New test.
2022-11-08 14:52:11 +00:00
Aldy Hernandez
b74dd1bbd2 Use bit-CCP in range-ops.
After Jakub and Richi's suggestion of using the same representation
for tracking known bits as we do in CCP, I took a peek at the code and
realized there's a plethora of bit-tracking code there that we could
be sharing with range-ops.  For example, the multiplication
optimizations are way better than what I had cobbled together.  For
that matter, our maybe nonzero tracking as a whole has a lot of room
for improvement.  Being the lazy ass that I am, I think we should just
use one code base (CCP's).

This patch provides a thin wrapper for converting the irange maybe
nonzero bits to what CCP requires, and uses that to call into
bit_value_binop().  I have so far converted the MULT_EXPR range-op
entry to use it, as the DIV_EXPR entry we have gets a case CCP doesn't
get so I'd like to contribute the enhancement to CCP before converting
over.

I'd like to use this approach with the dozen or so tree_code's that
are handled in CCP, thus saving us from having to implement any of
them :).

Early next season I'd like to change irange's internal representation
to a pair of value / mask, and start tracking all known bits.  This
ties in nicely with our plan for tracking known set bits.

Perhaps if the stars align, we could merge the bit twiddling in CCP
into range-ops and have a central repository for it.  That is, once we
make the switch to wide-ints, and assuming there are no performance
issues.  Note that range-ops is our lowest level abstraction.
i.e. it's just the math, there's no GORI or ranger, or even the
concept of a symbolic or SSA.

gcc/ChangeLog:

	* range-op.cc (irange_to_masked_value): New.
	(update_known_bitmask): New.
	(operator_mult::fold_range): Call update_known_bitmask.
2022-11-08 15:17:14 +01:00
Surya Kumari Jangala
7ca912b46e testsuite: Fix failure in test pr105586.c [PR107171]
The test pr105586.c fails on a big endian system when run in 32bit
mode. The failure occurs as the test case does not guard against
unsupported __int128.

2022-10-13  Surya Kumari Jangala  <jskumari@linux.ibm.com>

gcc/testsuite/
	PR testsuite/107171
	* gcc.target/powerpc/pr105586.c: Guard against unsupported
	__int128.
2022-11-08 06:32:19 -06:00
Jakub Jelinek
970dcd5674 cdce: Fix up get_no_error_domain for new f{16,32,64,128} builtins [PR107547]
I've missed that this function needs to handle all the builtins that
are handled in can_test_argument_range.
The following patch does that.  For many of the builtins (like acos, or
log) it is the same range regardless of the floating point type, but for
some (cosh, sinh, exp{,m1,2}) it is different for each format,
so I had to compute those ranges.

Note, seems the existing ranges were in some cases (e.g. for exp2)
the smallest in absolute value which results infinite result, in others
the largest which still results in finite result (but consistently so
for the IEEE single vs. double).  I've followed that for IEEE half and
quad cases too, just am not sure why it was like that.  I think
get_domain with true, false is open interval rather than closed
and the comments indicate that too, conservatively that is certainly
correct.

OT, with frange, perhaps we could DCE the calls unconditionally if
frange can prove we are in the domain range.

2022-11-08  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/107547
	* tree-call-cdce.cc (get_no_error_domain): Handle CASE_FLT_FN_FLOATN_NX
	of BUILT_IN_{ACOS,ASIN,ACOSH,ATANH,LOG,LOG2,LOG10,LOG1P}.  Handle
	BUILT_IN_{COSH,SINH,EXP,EXPM1,EXP2}F{16,32,64,128}.

	* gcc.dg/pr107547.c: New test.
2022-11-08 13:24:02 +01:00
Jakub Jelinek
fa271afb58 i386: Improve vector [GL]E{,U} comparison against vector constants [PR107546]
For integer vector comparisons without XOP before AVX512{F,VL} we are
constrained by only GT and EQ being supported in HW.
For GTU we play tricks to implement it using GT or unsigned saturating
subtraction, for LT/LTU we swap the operands and thus turn it into
GT/GTU.  For LE/LEU we handle it by using GT/GTU and negating the
result and for GE/GEU by using GT/GTU on swapped operands and negating
the result.
If the second operand is a CONST_VECTOR, we can usually do better though,
we can avoid the negation.  For LE/LEU cst by doing LT/LTU cst+1 (and
then cst+1 GT/GTU x) and for GE/GEU cst by doing GT/GTU cst-1, provided
there is no wrap-around on those cst+1 or cst-1.
GIMPLE canonicalizes x < cst to x <= cst-1 etc. (the rule is smaller
absolute value on constant), but only for scalars or uniform vectors,
so in some cases this undoes that canonicalization in order to avoid
the extra negation, but it handles also non-uniform constants.
E.g. with -mavx2 the testcase assembly difference is:
-       movl    $47, %eax
+       movl    $48, %eax
        vmovdqa %xmm0, %xmm1
        vmovd   %eax, %xmm0
        vpbroadcastb    %xmm0, %xmm0
-       vpminsb %xmm0, %xmm1, %xmm0
-       vpcmpeqb        %xmm1, %xmm0, %xmm0
+       vpcmpgtb        %xmm1, %xmm0, %xmm0
and
-       vmovdqa %xmm0, %xmm1
-       vmovdqa .LC1(%rip), %xmm0
-       vpminsb %xmm1, %xmm0, %xmm1
-       vpcmpeqb        %xmm1, %xmm0, %xmm0
+       vpcmpgtb        .LC1(%rip), %xmm0, %xmm0
while with just SSE2:
-       pcmpgtb .LC0(%rip), %xmm0
-       pxor    %xmm1, %xmm1
-       pcmpeqb %xmm1, %xmm0
+       movdqa  %xmm0, %xmm1
+       movdqa  .LC0(%rip), %xmm0
+       pcmpgtb %xmm1, %xmm0
and
-       movdqa  %xmm0, %xmm1
-       movdqa  .LC1(%rip), %xmm0
-       pcmpgtb %xmm1, %xmm0
-       pxor    %xmm1, %xmm1
-       pcmpeqb %xmm1, %xmm0
+       pcmpgtb .LC1(%rip), %xmm0

2022-11-08  Jakub Jelinek  <jakub@redhat.com>

	PR target/107546
	* config/i386/predicates.md (vector_or_const_vector_operand): New
	predicate.
	* config/i386/sse.md (vec_cmp<mode><sseintvecmodelower>,
	vec_cmpv2div2di, vec_cmpu<mode><sseintvecmodelower>,
	vec_cmpuv2div2di): Use nonimmediate_or_const_vector_operand
	predicate instead of nonimmediate_operand and
	vector_or_const_vector_operand instead of vector_operand.
	* config/i386/i386-expand.cc (ix86_expand_int_sse_cmp): For
	LE/LEU or GE/GEU with CONST_VECTOR cop1 try to transform those
	into LE/LEU or GT/GTU with larger or smaller by one cop1 if
	there is no wrap-around.  Force CONST_VECTOR cop0 or cop1 into
	REG.  Formatting fix.

	* gcc.target/i386/pr107546.c: New test.
2022-11-08 12:21:55 +01:00
Jakub Jelinek
ee86bdd1d3 libstdc++: Uncomment denorm_min test
As r13-3609-g6d9dbdf51f9afe8 has been committed, we can now enable
even the denorm_min test.

2022-11-08  Jakub Jelinek  <jakub@redhat.com>

	* testsuite/20_util/to_chars/float128_c++23.cc (test): Uncomment
	denorm_min test.
2022-11-08 11:19:25 +01:00
Max Filippov
e581490f0c gcc: fix PR rtl-optimization/107482
gcc/
	PR rtl-optimization/107482
	* ira-color.cc (assign_hard_reg): Only call
	update_costs_from_copies when retry_p is false.
2022-11-08 01:29:56 -08:00
Eric Botcazou
b2278f6b14 ada: Fix oversight in implementation of allocators for storage models
When the allocator is of an unconstrained array type and has an initializing
expression, the copy of the initializing expression must be done separately
from that of the bounds.

gcc/ada/

	* gcc-interface/utils2.cc (build_allocator): For unconstrained
	array types with a storage model and an initializing expression,
	copy the initialization expression separately from the bounds. In
	all cases with a storage model, pass the locally computed size for
	the store.
2022-11-08 09:35:03 +01:00
Steve Baird
10f193eb04 ada: Compile-time simplification of 'Image incorrectly ignores Put_Image
In the case of Some_Enumeration_Type'Image (<some static value>),
the compiler will replace this expression in its internal program
representation with a corresponding string literal. This is incorrect
if the Put_Image aspect has been specified (directly or via inheritance)
for the enumeration type.

gcc/ada/

	* sem_attr.adb
	(Eval_Attribute): Don't simplify 'Image call if Put_Image has been
	specified.
2022-11-08 09:35:03 +01:00
Piotr Trojanek
11f892571c ada: Clean up call to check if aspects are present
Code cleanup; semantics is unaffected.

gcc/ada/

	* exp_ch6.adb, exp_put_image.adb, sem_aggr.adb, sem_attr.adb,
	sem_ch5.adb, sem_type.adb, sem_util.adb: Replace
	"Present (Find_Aspect (...))" with "Has_Aspect".
2022-11-08 09:35:03 +01:00
Ronan Desplanques
45656a992e ada: Adjust classwide contract expression preanalysis
Before this patch, a classwide contract expression was preanalyzed
only when its primitive operation's type was frozen. It caused name
resolution to be off in the cases where the freezing took place
after the end of the declaration list the primitive operation was
declared in.

This patch makes it so that if the compiler gets to the end of
the declaration list before the type is frozen, it preanalyzes the
classwide contract expression, so that the names are resolved in the
right context.

gcc/ada/

	* contracts.adb
	(Preanalyze_Class_Conditions): New procedure.
	(Preanalyze_Condition): Moved out from Merge_Class_Conditions in
	order to be spec-visible.
	* contracts.ads
	(Preanalyze_Class_Conditions): New procedure.
	* sem_prag.adb
	(Analyze_Pre_Post_Condition_In_Decl_Part): Call
	Preanalyze_Class_Conditions when necessary.
2022-11-08 09:35:02 +01:00
Johannes Kliemann
48e2e5b4c2 ada: Set Support_Atomic_Primitives for VxWorks 7 runtimes
gcc/ada/

	* libgnat/system-vxworks7-aarch64-rtp-smp.ads: Set
	Support_Atomic_Primitives to True.
	* libgnat/system-vxworks7-aarch64.ads: Set
	Support_Atomic_Primitives to True.
	* libgnat/system-vxworks7-arm-rtp-smp.ads: Set
	Support_Atomic_Primitives to True.
	* libgnat/system-vxworks7-arm.ads: Set Support_Atomic_Primitives
	to True.
	* libgnat/system-vxworks7-ppc-kernel.ads: Set
	Support_Atomic_Primitives to False.
	* libgnat/system-vxworks7-ppc-rtp-smp.ads: Set
	Support_Atomic_Primitives to False.
	* libgnat/system-vxworks7-ppc64-kernel.ads: Set
	Support_Atomic_Primitives to True.
	* libgnat/system-vxworks7-ppc64-rtp-smp.ads: Set
	Support_Atomic_Primitives to True.
	* libgnat/system-vxworks7-x86-kernel.ads: Set
	Support_Atomic_Primitives to True.
	* libgnat/system-vxworks7-x86-rtp-smp.ads: Set
	Support_Atomic_Primitives to True.
	* libgnat/system-vxworks7-x86_64-kernel.ads: Set
	Support_Atomic_Primitives to True.
	* libgnat/system-vxworks7-x86_64-rtp-smp.ads: Set
	Support_Atomic_Primitives to True.
2022-11-08 09:35:02 +01:00
Eric Botcazou
0ed20c72aa ada: Small consistency fix
gcc/ada/

	* fe.h (Get_Warn_On_Questionable_Layout): Add void parameter.
2022-11-08 09:35:02 +01:00
Piotr Trojanek
a645dc3c20 ada: Propagate aspect Ghost when instantiating null formal procedures
When instantiating generic package that includes a formal subprogram
declaration with Ghost aspect and a subprogram_default of null, e.g.:

   generic
     with procedure Proc is null with Ghost;
   package P is ...

the Ghost aspect should be propagated to the internally generated null
subprogram, so this null subprogram can be used in contexts that require
ghost entities.

gcc/ada/

	* sem_ch12.adb (Instantiate_Formal_Subprogram): Copy aspect Ghost
	from formal subprogram declaration to the internally generated
	procedure.
2022-11-08 09:35:02 +01:00
Eric Botcazou
59ad8b684d ada: Implement RM 4.5.7(10/3) name resolution rule
This rule deals with the specific case of a conditional expression that is
the operand of a type conversion and effectively distributes the conversion
to the dependent expressions with the help of the dynamic semantics.

gcc/ada/

	* sem_ch4.adb (Analyze_Case_Expression): Compute the
	interpretations of the expression only at the end of the analysis,
	but skip doing it if it is the operand of a type conversion.
	(Analyze_If_Expression): Likewise.
	* sem_res.adb (Resolve): Deal specially with conditional
	expression that is the operand of a type conversion.
	(Resolve_Dependent_Expression): New procedure.
	(Resolve_Case_Expression): Call Resolve_Dependent_Expression.
	(Resolve_If_Expression): Likewise.
	(Resolve_If_Expression.Apply_Check): Take result type as
	parameter.
	(Resolve_Type_Conversion): Do not warn about a redundant
	conversion when the operand is a conditional expression.
2022-11-08 09:35:01 +01:00
Javier Miranda
f1668c3d35 ada: Enforce matching of extra formals
This patch enforces matching of extra formals in overridden subprograms,
subprogram renamings, and subprograms to which attributes 'Access,
'Unchecked_Access, or 'Unrestricted_Access is applied (for these access
cases the subprogram is checked against its corresponding subprogram
type). This enforcement is an internal consistency check, not an
implementation of some language legality rule.

gcc/ada/

	* debug.adb
	(Debug_Flag_Underscore_XX): Switch -gnatd_X used temporarily to allow
	disabling extra formal checks.
	* exp_attr.adb
	(Expand_N_Attribute_Reference [access types]): Add extra formals
	to the subprogram referenced in the prefix of 'Unchecked_Access,
	'Unrestricted_Access or 'Access; required to check that its extra
	formals match the extra formals of the corresponding subprogram type.
	* exp_ch3.adb
	(Stream_Operation_OK): Declaration moved to the public part of the
	package.
	(Validate_Tagged_Type_Extra_Formals): New subprogram.
	(Expand_Freeze_Record_Type): Improve the code that takes care of
	adding the extra formals of dispatching primitives; extended to
	add also the extra formals to renamings of dispatching primitives.
	* exp_ch3.ads
	(Stream_Operation_OK): Declaration moved from the package body.
	* exp_ch6.adb
	(Check_BIP_Actuals): Complete documentation.
	(Has_BIP_Extra_Formal): Subprogram declaration moved to the public
	part of the package. In addition, a parameter has been added to
	disable an assertion that requires its use with frozen entities.
	(Duplicate_Params_Without_Extra_Actuals): New subprogram.
	(Check_Subprogram_Variant): Emit the call without duplicating the
	extra formals since they will be added when the call is analyzed.
	(Expand_Call_Helper): Ensure that the called subprogram has all its
	extra formals, enforce assertion checking extra formals on thunks,
	and mark calls from thunks as processed-BIP-calls to avoid adding
	their extra formals twice.
	(Is_Build_In_Place_Function): Return False for entities with foreign
	convention.
	(Is_Build_In_Place_Function_Call): Return True also for not BIP functions
	that have BIP formals since the extra actuals are required.
	(Make_Build_In_Place_Call_In_Object_Declaration): Occurrences of
	Is_Return_Object replaced by the local variable Is_OK_Return_Object
	that evaluates to False for scopes with foreign convention.
	(Might_Have_Tasks): Fix check of class-wide limited record types.
	(Needs_BIP_Task_Actuals): Remove assertion to allow calling this
	function in more contexts; in addition it returns False for functions
	returning objects with foreign convention.
	(Needs_BIP_Finalization_Master): Likewise.
	(Needs_BIP_Alloc_Form): Likewise.
	(Validate_Subprogram_Calls): Check that the number of actuals (including
	extra actuals) of calls in the subtree N match their corresponding
	formals.
	* exp_ch6.ads
	(Has_BIP_Extra_Formal): Subprogram declaration moved to the public
	part of the package. In addition, a parameter has been added to
	disable an assertion that requires its use with frozen entities.
	(Is_Build_In_Place_Function_Call): Complete documentation.
	(Validate_Subprogram_Calls): Check that the number of actuals (including
	extra actuals) of calls in the subtree N match their corresponding
	formals.
	* freeze.adb
	(Check_Itype): Add extra formals to anonymous access subprogram itypes.
	(Freeze_Expression): Improve code that disables the addition of extra
	formals to functions with foreign convention.
	(Check_Extra_Formals): Moved to package Sem_Ch6 as Extra_Formals_OK.
	(Freeze_Subprogram): Add extra formals to non-dispatching subprograms.
	* frontend.adb
	(Frontend): Validate all the subprogram calls; it can be disabled using
	switch -gnatd_X
	* sem_ch3.adb
	(Access_Subprogram_Declaration): Defer the addition of extra formals to
	the freezing point so that we know the convention.
	(Check_Anonymous_Access_Component): Likewise.
	(Derive_Subprogram): Fix documentation.
	* sem_ch6.adb
	(Has_Reliable_Extra_Formals): New subprogram.
	(Check_Anonymous_Return): Fix check of access to class-wide limited
	record types.
	(Check_Untagged_Equality): Placed in alphabetical order.
	(Extra_Formals_OK): Subprogram moved from freeze.adb.
	(Extra_Formals_Match_OK): New subprogram.
	(Has_BIP_Formals): New subprogram.
	(Has_Extra_Formals): New subprograms.
	(Needs_Accessibility_Check_Extra): New subprogram.
	(Parent_Subprogram): New subprogram.
	(Add_Extra_Formal): Minor code cleanup.
	(Create_Extra_Formals): Enforce matching extra formals on overridden
	and aliased entities.
	* sem_ch6.ads
	(Extra_Formals_Match_OK): New subprogram.
	(Extra_Formals_OK): Subprogram moved from freeze.adb.
	* sem_eval.adb
	(Compile_Time_Known_Value): Improve predicate to avoid assertion
	failure; found working on this ticket; this change does not
	affect the behavior of the compiler because this subprogram
	has an exception handler that returns False when the assertion
	fails.
	* sem_util.adb
	(Needs_Result_Accessibility_Level): Do not return False for dispatching
	operations compiled with Ada_Version < 2012 since they they may be
	overridden by primitives compiled with Ada_Version >= Ada_2012.
2022-11-08 09:35:01 +01:00
Bob Duff
7a08b9393c ada: Move warnings switches -- initial work
This patch prepares to move warning switches from Opt into Warnsw.

gcc/ada/

	* warnsw.ads, warnsw.adb, fe.h, err_vars.ads, errout.ads: Move
	Warning_Doc_Switch from Err_Vars to Warnsw. Access
	Warn_On_Questionable_Layout on the C side via a function rather
	than a variable, because we plan to turn the variables into
	renamings, and you can't Export renamings.
	* erroutc.adb, switch-c.adb, errout.adb: Likewise.
	* gcc-interface/decl.cc: Use Get_Warn_On_Questionable_Layout
	instead of Warn_On_Questionable_Layout.
	* gcc-interface/Makefile.in (GNATMAKE_OBJS): Add warnsw.o, because
	it is indirectly imported via Errout.
	* gcc-interface/Make-lang.in (GNATBIND_OBJS): Likewise and remove
	restrict.o (not needed).
2022-11-08 09:35:00 +01:00
Ronan Desplanques
c523e3f1ea ada: Align -gnatwc's documentation with its behavior
Shortly after the -gnatwc flag was introduced, its behavior was
tweaked, but its documentation was not updated accordingly.

gcc/ada/

	* doc/gnat_ugn/building_executable_programs_with_gnat.rst
	(-gnatwc): Fix flag documentation.
	* gnat_ugn.texi: Regenerate.
2022-11-08 09:35:00 +01:00
Steve Baird
f2fa41b442 ada: Improve handling of declare expressions in deferred-freezing contexts
In some cases where a declare expression occurs in a deferred-freezing
context (e.g., within the default value for a discriminant or for a formal
parameter, or within the expression of an expression function), the compiler
generates a bugbox.

gcc/ada/

	* sem_ch3.adb
	(Analyze_Object_Declaration): Do not perform expansion actions if
	In_Spec_Expression is true.
2022-11-08 09:35:00 +01:00
Eric Botcazou
270713d3f6 ada: Minor consistency tweaks in Sem_Ch4
This ensures that, during the analysis of the qualified expressions, type
conversions and unchecked type conversions, the determination of the type
of the node and the analysis of its expression are done in the same order.

No functional changes.

gcc/ada/

	* sem_ch4.adb (Analyze_Qualified_Expression): Analyze the
	expression only after setting the type.
	(Analyze_Unchecked_Type_Conversion): Likewise.
	(Analyze_Short_Circuit): Likewise for the operands.
	(Analyze_Type_Conversion): Minor tweaks.
	(Analyze_Unchecked_Expression): Likewise.
2022-11-08 09:35:00 +01:00
Eric Botcazou
786c6ba5a5 ada: Remove redundant line in Analyze_Qualified_Expression
The same statement is present a few lines above.

gcc/ada/

	* sem_ch4.adb (Analyze_Qualified_Expression): Remove redundant
	line.
2022-11-08 09:34:59 +01:00
Ronan Desplanques
788e5f06d4 ada: Preanalyze classwide contracts as spec expressions
Classwide contracts are "spec expressions" as defined in the
documentation in sem.ads. Before this patch, the instances of
classwide contracts that are destined to class conditions merging
were not preanalyzed as spec expressions. That caused preanalysis to
emit spurious errors in some cases.

gcc/ada/

	* contracts.adb (Preanalyze_Condition): Use
	Preanalyze_Spec_Expression.
2022-11-08 09:34:59 +01:00
Piotr Trojanek
c2596d4533 ada: Fix expansion of 'Wide_Image and 'Wide_Wide_Image on composite types
Attributes Wide_Image and Wide_Wide_Image applied to composite types are
now expanded just like attribute Image.

gcc/ada/

	* exp_imgv.adb
	(Expand_Wide_Image_Attribute): Handle just like attribute Image.
	(Expand_Wide_Wide_Image_Attribute): Likewise.
	* exp_put_image.adb
	(Build_Image_Call): Adapt to also work for Wide and Wide_Wide
	attributes.
	* exp_put_image.ads
	(Build_Image_Call): Update comment.
	* rtsfind.ads
	(RE_Id): Support wide variants of Get.
	(RE_Unit_Table): Likewise.
2022-11-08 09:34:59 +01:00
Piotr Trojanek
7857d87329 ada: Fix inconsistent whitespace in Ada.Numerics.Generic_Complex_Arrays
Cleanup only.

gcc/ada/

	* libgnat/a-ngcoar.ads, libgnat/a-ngcoar.adb: Remove extra spaces.
2022-11-08 09:34:59 +01:00
Piotr Trojanek
d96a20bf2e ada: Remove unneeded code in handling formal type defaults
Unneeded code found while experimenting with improved detection of
unreferenced objects.

gcc/ada/

	* sem_ch12.adb (Validate_Formal_Type_Default): Remove call to
	Collect_Interfaces, which had no effect apart from populating a
	list that was not used; fix style.
2022-11-08 09:34:59 +01:00
Piotr Trojanek
5c0722cb40 ada: Cleanup local variable that is only set as an out parameter
Minor improvements; found experimenting with improved detection of
unreferenced objects.

gcc/ada/

	* exp_spark.adb (SPARK_Freeze_Type): Refine type of a local
	object.
	* sem_ch3.adb (Derive_Subprograms): Remove initial value for
	New_Subp, which is in only written as an out parameter and never
	read.
2022-11-08 09:34:58 +01:00
Eric Botcazou
83ebb97db7 ada: Remove obsolete code in Resolve_If_Expression
gcc/ada/

	* sem_res.adb (Resolve_If_Expression): Remove obsolete special
	case.
2022-11-08 09:34:58 +01:00
Piotr Trojanek
79e02673e9 ada: Reject limited objects in array and record delta aggregates
For array delta aggregates the base expression cannot be limited; for
record delta aggregates the base expression can only be limited if it is
a newly constructed object.

gcc/ada/

	* sem_aggr.adb (Resolve_Delta_Aggregate): Implement rules related
	to limited objects appearing as the base expression.
2022-11-08 09:34:58 +01:00
Piotr Trojanek
2ff87e21c2 ada: Allow initialization of limited objects with delta aggregates
Objects of a limited type can be initialized with "aggregates", which is
a collective term for ordinary aggregates (i.e. record aggregates and
array aggregates), extension aggregates and finally for delta
aggregates (introduced by Ada 2022).

gcc/ada/

	* sem_ch3.adb (OK_For_Limited_Init_In_05): Handle delta aggregates
	just like other aggregates.
2022-11-08 09:34:58 +01:00
Piotr Trojanek
4a22fdac0f ada: Reject record delta aggregates with limited expressions
Implement a missing check related to record delta aggregates.

gcc/ada/

	* sem_aggr.adb (Resolve_Delta_Record_Aggregate): Reject
	expressions of a limited types.
2022-11-08 09:34:57 +01:00
Javier Miranda
b9d8ad7175 ada: Missing master of task causing assertion failure
gcc/ada/

	* exp_ch9.adb
	(Build_Master_Entity): Handle missing case: when the context of
	the master is a BIP function whose result type has tasks.
2022-11-08 09:34:57 +01:00
Piotr Trojanek
59dd07ef25 ada: Raise Tag_Error when Ada.Tags operations are called with No_Tag
Implement missing behavior of RM 13.9 (25.1/3): Tag_Error is raised by a
call of Interface_Ancestor_Tags and Is_Descendant_At_Same_Level, if any
tag passed is No_Tag. This change also fixes Descendant_Tag, which
relies on Is_Descendant_At_Same_Level. The remaining operations already
worked properly.

gcc/ada/

	* libgnat/a-tags.adb
	(Interface_Ancestor_Tags): Raise Tag_Error on No_Tag.
	(Is_Descendant_At_Same_Level): Likewise.
2022-11-08 09:34:57 +01:00
Bob Duff
ae5de5a327 ada: Add new -gnatw_q switch to usage message
...along with -gnatw_Q.

gcc/ada/

	* usage.adb: Add -gnatw_q and -gnatw_Q.
2022-11-08 09:34:57 +01:00
Jonathan Wakely
acbfa2bc60 libstdc++: Update my author blurb in the manual
libstdc++-v3/ChangeLog:

	* doc/xml/authors.xml: Update the blurb listing my doc
	contributions.
2022-11-08 03:07:49 +00:00
Jonathan Wakely
4596339d9f libstdc++: Remove empty <author> elements in manual
This fixes a spurious comma before the list of authors in the PDF
version of the libstdc++ manual.

Also fix the commented-out examples which should show <personblurb> not
<authorblurb>.

libstdc++-v3/ChangeLog:

	* doc/xml/authors.xml: Remove empty author element.
	* doc/xml/manual/spine.xml: Likewise.
	* doc/html/manual/index.html: Regenerate.
2022-11-08 03:07:49 +00:00
konglin1
1f7b130050 Revert "i386: Prefer remote atomic insn for atomic_fetch{add, and, or, xor}"
This reverts commit 48fa4131e4.
2022-11-08 11:00:47 +08:00
Haochen Jiang
a14598bf86 Add m_CORE_ATOM for atom cores
gcc/ChangeLog:

	* config/i386/i386-options.cc (m_CORE_ATOM): New.
	* config/i386/x86-tune.def
	(X86_TUNE_SCHEDULE): Initial tune for CORE_ATOM.
	(X86_TUNE_PARTIAL_REG_DEPENDENCY): Ditto.
	(X86_TUNE_SSE_PARTIAL_REG_DEPENDENCY): Ditto.
	(X86_TUNE_SSE_PARTIAL_REG_FP_CONVERTS_DEPENDENCY): Ditto.
	(X86_TUNE_SSE_PARTIAL_REG_CONVERTS_DEPENDENCY): Ditto.
	(X86_TUNE_DEST_FALSE_DEP_FOR_GLC): Ditto.
	(X86_TUNE_MEMORY_MISMATCH_STALL): Ditto.
	(X86_TUNE_USE_LEAVE): Ditto.
	(X86_TUNE_PUSH_MEMORY): Ditto.
	(X86_TUNE_USE_INCDEC): Ditto.
	(X86_TUNE_INTEGER_DFMODE_MOVES): Ditto.
	(X86_TUNE_PREFER_KNOWN_REP_MOVSB_STOSB): Ditto.
	(X86_TUNE_MISALIGNED_MOVE_STRING_PRO_EPILOGUES): Ditto.
	(X86_TUNE_USE_SAHF): Ditto.
	(X86_TUNE_USE_BT): Ditto.
	(X86_TUNE_AVOID_FALSE_DEP_FOR_BMI): Ditto.
	(X86_TUNE_ONE_IF_CONV_INSN): Ditto.
	(X86_TUNE_AVOID_MFENCE): Ditto.
	(X86_TUNE_USE_SIMODE_FIOP): Ditto.
	(X86_TUNE_EXT_80387_CONSTANTS): Ditto.
	(X86_TUNE_SSE_UNALIGNED_LOAD_OPTIMAL): Ditto.
	(X86_TUNE_SSE_UNALIGNED_STORE_OPTIMAL): Ditto.
	(X86_TUNE_SSE_TYPELESS_STORES): Ditto.
	(X86_TUNE_SSE_LOAD0_BY_PXOR): Ditto.
	(X86_TUNE_AVOID_4BYTE_PREFIXES): Ditto.
	(X86_TUNE_USE_GATHER_2PARTS): Ditto.
	(X86_TUNE_USE_GATHER_4PARTS): Ditto.
	(X86_TUNE_USE_GATHER): Ditto.
2022-11-08 10:59:48 +08:00
David Malcolm
3d2d04cda4 analyzer: start adding support for errno
gcc/analyzer/ChangeLog:
	* region-model-impl-calls.cc
	(region_model::impl_call_errno_location): New.
	* region-model-manager.cc
	(region_model_manager::region_model_manager): Initialize
	m_thread_local_region and m_errno_region.
	* region-model-manager.h (region_model_manager::get_errno_region):
	New accessor.
	(region_model_manager::m_thread_local_region): New.
	(region_model_manager::m_errno_region): New.
	* region-model.cc (region_model::on_call_pre): Special-case
	"__errno_location".
	(region_model::set_errno): New.
	* region-model.h (impl_call_errno_location): New decl.
	(region_model::set_errno): New decl.
	* region.cc (thread_local_region::dump_to_pp): New.
	(errno_region::dump_to_pp): New.
	* region.h (enum memory_space): Add MEMSPACE_THREAD_LOCAL.
	(enum region_kind): Add RK_THREAD_LOCAL and RK_ERRNO.
	(class thread_local_region): New.
	(is_a_helper <const thread_local_region *>::test): New.
	(class errno_region): New.
	(is_a_helper <const errno_region *>::test): New.
	* store.cc (binding_cluster::escaped_p): New.
	(store::escaped_p): Treat errno as always having escaped.
	(store::replay_call_summary_cluster): Handle RK_THREAD_LOCAL and
	RK_ERRNO.
	* store.h (binding_cluster::escaped_p): Remove definition.

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/errno-1.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-07 21:52:46 -05:00
David Malcolm
be9fdbda1c analyzer: introduce succeed_or_fail_call_info
This makes some followup code much cleaner.

gcc/analyzer/ChangeLog:
	* call-info.cc (success_call_info::get_desc): Delete.
	(failed_call_info::get_desc): Likewise.
	(succeed_or_fail_call_info::get_desc): New.
	* call-info.h (class succeed_or_fail_call_info): New.
	(class success_call_info): Convert to a subclass of
	succeed_or_fail_call_info.
	(class failed_call_info): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-07 21:52:40 -05:00
David Malcolm
55e042407e analyzer: fix "when 'strchr' returns non-NULL" message
Tweak analyzer handling of strchr, so that we show the
  when 'strchr' returns non-NULL
message for that execution path.

gcc/analyzer/ChangeLog:
	* region-model-impl-calls.cc (region_model::impl_call_strchr):
	Move to on_call_post.  Handle both outcomes using bifurcation,
	rather than just the "not found" case.
	* region-model.cc (region_model::on_call_pre): Move
	BUILT_IN_STRCHR and "strchr" to...
	(region_model::on_call_post): ...here.

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/strchr-1.c (test_literal): Detect writing to a
	string literal.  Verify that we emit the "when '__builtin_strchr'
	returns non-NULL" message.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-07 21:52:30 -05:00
Joseph Myers
8d0326943e libstdc++: Fix syntax error in old-glibc case in floating_from_chars.cc [PR107562]
PR libstdc++/107562
	* src/c++17/floating_from_chars.cc (from_chars_impl): Fix syntax
	error.
2022-11-08 01:41:00 +00:00
Jason Merrill
431be04b8b c++: implement P2468R2, the equality operator you are looking for
This paper is resolving the problem of well-formed C++17 code becoming
ambiguous in C++20 due to asymmetrical operator== being compared with itself
in reverse.  I had previously implemented a tiebreaker such that if the two
candidates were functions with the same parameter types, we would prefer the
non-reversed candidate.  But the committee went with a different approach:
if there's an operator!= with the same parameter types as the operator==,
don't consider the reversed form of the ==.

So this patch implements that, and changes my old tiebreaker to give a
pedwarn if it is used.  I also noticed that we were giving duplicate errors
for some testcases, and fixed the tourney logic to avoid that.

As a result, a lot of tests of the form

  struct A { bool operator==(const A&); };

need to be fixed to add a const function-cv-qualifier, e.g.

  struct A { bool operator==(const A&) const; };

The committee thought such code ought to be fixed, so breaking it was fine.

18_support/comparisons/algorithms/fallback.cc also breaks with this patch,
because of the similarly asymmetrical

  bool operator==(const S&, S&) { return true; }

As a result, some of the asserts need to be reversed.

The H test in spaceship-eq15.C is specified in the standard to be
well-formed because the op!= in the inline namespace is not found by the
search, but that seems wrong to me.  I've implemented that behavior, but
disabled it for now; if we decide that is the way we want to go, we can just
remove the "0 &&" in add_candidates to enable it.

Co-authored-by: Jakub Jelinek <jakub@redhat.com>

gcc/cp/ChangeLog:

	* cp-tree.h (fns_correspond): Declare.
	* decl.cc (fns_correspond): New.
	* call.cc (add_candidates): Look for op!= matching op==.
	(joust): Complain about non-standard reversed tiebreaker.
	(tourney): Fix champ_compared_to_predecessor logic.
	(build_new_op): Don't complain about error_mark_node not having
	'bool' type.
	* pt.cc (tsubst_copy_and_build): Don't try to be permissive
	when seen_error().

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/spaceship-eq15.C: New test.
	* g++.dg/cpp0x/defaulted3.C: Add const.
	* g++.dg/cpp2a/bit-cast7.C: Add const.
	* g++.dg/cpp2a/spaceship-rewrite1.C: Expect error.
	* g++.dg/cpp2a/spaceship-rewrite5.C: Expect error.
	* g++.old-deja/g++.jason/byval2.C: Expect error.
	* g++.old-deja/g++.other/overload13.C: Add const.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/comparisons/algorithms/fallback.cc: Adjust
	asserts.
2022-11-07 14:54:04 -10:00
Andrew MacLeod
c838119946 Add transitive inferred range processing.
Rewalk statements at the end of a block to see if any inferred ranges
affect earlier calculations and register those as inferred ranges.

	gcc/
	PR tree-optimization/104530
	* gimple-range-cache.cc (ranger_cache::register_inferred_value):
	New.  Split from:
	(ranger_cache::apply_inferred_ranges): Move setting cache to
	separate function.
	* gimple-range-cache.h (register_inferred_value): New prototype.
	* gimple-range-infer.cc (infer_range_manager::has_range_p): New.
	* gimple-range-infer.h (has_range_p): New prototype.
	* gimple-range.cc (register_transitive_inferred_ranges): New.
	* gimple-range.h (register_transitive_inferred_ranges): New proto.
	* tree-vrp.cc (rvrp_folder::fold_stmt): Check for transitive inferred
	ranges at the end of the block before folding final stmt.

	gcc/testsuite/
	* gcc.dg/pr104530.c: New.
2022-11-07 19:22:19 -05:00
GCC Administrator
f8d901d00e Daily bump. 2022-11-08 00:17:53 +00:00
Jakub Jelinek
b457b77942 libstdc++: Fix up libstdc++ build against glibc 2.25 or older [PR107562]
On Mon, Nov 07, 2022 at 05:48:42PM +0000, Jonathan Wakely wrote:
> On Mon, 7 Nov 2022 at 16:11, Joseph Myers <joseph@codesourcery.com> wrote:
> >
> > On Wed, 2 Nov 2022, Jakub Jelinek via Gcc-patches wrote:
> >
> > > APIs.  So that one can build gcc against older glibc and then compile
> > > user programs on newer glibc, the patch uses weak references unless
> > > gcc is compiled against glibc 2.26+.  strfromf128 unfortunately can't
> >
> > This support for older glibc doesn't actually seem to be working, on an
> > older system with glibc 2.19 I'm seeing
> >
> > /scratch/jmyers/fsf/gcc-mainline/libstdc++-v3/src/c++17/floating_to_chars.cc:52:3: error: expected initializer before '__asm'
> >    52 |   __asm ("strfromf128");
> >       |   ^~~~~
> >
> > and a series of subsequent errors.
>
> This seems to "fix" it (not sure if it's right though):
>
> #ifndef _GLIBCXX_HAVE_FLOAT128_MATH
> extern "C" _Float128 __strtof128(const char*, char**)
>  __attribute__((__weak__));
> #endif
> extern "C" _Float128 __strtof128(const char*, char**)
>  __asm ("strtof128");

It is, but floating_from_chars.cc has the same problem,
and I think we can avoid the duplication, like this:

2022-11-08  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/107562
	* src/c++17/floating_from_chars.cc (__strtof128): Put __asm before
	__attribute__.
	* src/c++17/floating_to_chars.cc (__strfromf128): Likewise.
2022-11-08 00:35:09 +01:00
David Faust
93ab7d03df bpf: cleanup missed refactor
Commit 068baae186 "bpf: add preserve_field_info builtin" factored out
some repeated code to a new function maybe_make_core_relo (), but missed
using it in one place. Clean that up.

gcc/

	* config/bpf/bpf.cc (handle_attr_preserve): Use maybe_make_core_relo().
2022-11-07 14:37:22 -08:00
Aldy Hernandez
a239a63f86 Improve multiplication by powers of 2 in range-ops.
For unsigned numbers, multiplication by X, where X is a power of 2 is
[0,0][X,+INF].

This patch causes a regression to g++.dg/pr71488.C where
-Wstringop-overflow gets the same IL as before, but better ranges
cause it to issue a bogus warning.  I will create a PR with some
notes.

No discernible changes in performance.

Tested on x86-64 Linux.

	PR tree-optimization/55157

gcc/ChangeLog:

	* range-op.cc (operator_mult::wi_fold): Optimize multiplications
	by powers of 2.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/pr55157.c: New test.
2022-11-07 20:59:21 +01:00
H.J. Lu
03ed4e57e3 Extend optimization for integer bit test on __atomic_fetch_[or|and]_*
Extend optimization for

_1 = __atomic_fetch_or_4 (ptr_6, 0x80000000, _3);
_5 = (signed int) _1;
_4 = _5 >= 0;

to

_1 = __atomic_fetch_or_4 (ptr_6, 0x80000000, _3);
_5 = (signed int) _1;
if (_5 >= 0)

gcc/

	PR middle-end/102566
	* tree-ssa-ccp.cc (optimize_atomic_bit_test_and): Also handle
	if (_5 < 0) and if (_5 >= 0).

gcc/testsuite/

	PR middle-end/102566
	* g++.target/i386/pr102566-7.C
2022-11-07 11:18:21 -08:00
Patrick Palka
2ee0165f72 libstdc++: Implement ranges::as_rvalue_view from P2446R2
libstdc++-v3/ChangeLog:

	* include/std/ranges (as_rvalue_view): Define.
	(enable_borrowed_range<as_rvalue_view>): Define.
	(views::__detail::__can_as_rvalue_view): Define.
	(views::_AsRvalue, views::as_rvalue): Define.
	* testsuite/std/ranges/adaptors/as_rvalue/1.cc: New test.
2022-11-07 13:29:42 -05:00