platform/upstream/gcc.git
3 years agoc++: find_template_parameters and TEMPLATE_DECLs [PR101247]
Patrick Palka [Fri, 9 Jul 2021 14:20:22 +0000 (10:20 -0400)]
c++: find_template_parameters and TEMPLATE_DECLs [PR101247]

r12-1989 fixed the testcase in the PR, but unfortunately the fix is
buggy: it breaks the case where the common template between the
TEMPLATE_DECL t and ctx_parms is the innermost template (as in
concepts-memtmpl5.C below).  This can be fixed by instead passing the
TREE_TYPE of ctmpl to common_enclosing_class when ctmpl is a class
template.

But even after that's fixed, the analogous case where the innermost
template is a partial specialization is still broken (as in
concepts-memtmpl5a.C below), because ctmpl is always a primary template.

So this patch instead takes a diferent approach that doesn't rely on
ctx_parms at all: when looking for the template parameters of a
TEMPLATE_DECL that are shared with the current template context, just
walk its DECL_CONTEXT.  As long as the template is not overly general
(e.g. we didn't pass it through most_general_template), this should give
us exactly what we want, since if a TEMPLATE_DECL can be referred to
from some template context then the template parameters it uses must all
be in-scope and contained in its DECL_CONTEXT.  This effectively makes
us treat TEMPLATE_DECLs more similarly to other _DECLs (whose DECL_CONTEXT
we also walk).

PR c++/101247

gcc/cp/ChangeLog:

* pt.c (any_template_parm_r) <case TEMPLATE_DECL>: Just walk the
DECL_CONTEXT.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-memtmpl4.C: Uncomment the commented out
example, which we now handle correctly.
* g++.dg/cpp2a/concepts-memtmpl5.C: New test.
* g++.dg/cpp2a/concepts-memtmpl5a.C: New test.

3 years agolibstdc++: Only use __gthread_yield if gthreads is available
Matheus Castanho [Fri, 9 Jul 2021 14:13:38 +0000 (15:13 +0100)]
libstdc++: Only use __gthread_yield if gthreads is available

libstdc++-v3/ChangeLog:

* include/std/mutex (__lock_impl): Check
_GLIBCXX_HAS_GTHREADS before using __gthread_yield.

3 years ago[Ada] Fix style in expansion of attribute Put_Image
Piotr Trojanek [Thu, 17 Jun 2021 16:46:21 +0000 (18:46 +0200)]
[Ada] Fix style in expansion of attribute Put_Image

gcc/ada/

* exp_put_image.adb (Make_Put_Image_Name): Fix style.
(Image_Should_Call_Put_Image): Likewise.
(Build_Image_Call): Likewise.

3 years ago[Ada] par-ch6: do not mark subprogram as missing "is" if imported
Ghjuvan Lacambre [Thu, 17 Jun 2021 08:01:33 +0000 (10:01 +0200)]
[Ada] par-ch6: do not mark subprogram as missing "is" if imported

gcc/ada/

* par-ch6.adb (Contains_Import_Aspect): New function.
(P_Subprogram): Acknowledge `Import` aspects.

3 years ago[Ada] Fix crash on type extensions with discriminants
Bob Duff [Tue, 15 Jun 2021 19:36:34 +0000 (15:36 -0400)]
[Ada] Fix crash on type extensions with discriminants

gcc/ada/

* exp_put_image.adb (Make_Component_Attributes): Use
Implementation_Base_Type to get the parent type. Otherwise,
Parent_Type_Decl is actually an internally generated subtype
declaration, so we blow up on
Type_Definition (Parent_Type_Decl).

3 years ago[Ada] Add missed OS constant values
Dmitriy Anisimkov [Sun, 13 Jun 2021 02:42:54 +0000 (08:42 +0600)]
[Ada] Add missed OS constant values

gcc/ada/

* gsocket.h: Include net/if.h to get IF_NAMESIZE constant.
* s-oscons-tmplt.c: Define IPV6_FLOWINFO for Linux.

3 years ago[Ada] Improve performance of Ada.Containers.Doubly_Linked_Lists.Generic_Sorting.Sort
Steve Baird [Wed, 9 Jun 2021 14:29:11 +0000 (07:29 -0700)]
[Ada] Improve performance of Ada.Containers.Doubly_Linked_Lists.Generic_Sorting.Sort

gcc/ada/

* libgnat/a-cdlili.adb: Reimplement
Ada.Containers.Doubly_Linked_Lists.Generic_Sorting.Sort using
Mergesort instead of the previous Quicksort variant.

3 years ago[Ada] Crash on expansion of BIP construct in -gnatf mode
Justin Squirek [Tue, 15 Jun 2021 16:54:12 +0000 (12:54 -0400)]
[Ada] Crash on expansion of BIP construct in -gnatf mode

gcc/ada/

* exp_ch6.adb (Is_Build_In_Place_Function_Call): Add check to
verify the Selector_Name of Exp_Node has been analyzed before
obtaining its entity.

3 years ago[Ada] Typo corrections and minor reformatting
Gary Dismukes [Mon, 14 Jun 2021 19:37:49 +0000 (15:37 -0400)]
[Ada] Typo corrections and minor reformatting

gcc/ada/

* libgnarl/s-osinte__vxworks.ads: Fix typo ("release" =>
"releases") plus comment reformatting.
* libgnat/s-os_lib.ads: In a comment, fix typo ("indended" =>
"intended"), add a hyphen and semicolon, plus reformatting. In
comment for subtype time_t, fix typo ("effect" => "affect"), add
hyphens, plus reformatting.
* libgnat/s-parame.ads, libgnat/s-parame__ae653.ads,
libgnat/s-parame__hpux.ads: Remove period from one-line comment.

3 years ago[Ada] Add -gnatX support for casing on discriminated values
Steve Baird [Thu, 10 Jun 2021 18:20:27 +0000 (11:20 -0700)]
[Ada] Add -gnatX support for casing on discriminated values

gcc/ada/

* exp_ch5.adb (Expand_General_Case_Statement): Add new function
Else_Statements to handle the case of invalid data analogously
to how it is handled when casing on a discrete value.
* sem_case.adb (Has_Static_Discriminant_Constraint): A new
Boolean-valued function.
(Composite_Case_Ops.Scalar_Part_Count): Include discriminants
when traversing components.
(Composite_Case_Ops.Choice_Analysis.Traverse_Discrete_Parts):
Include discriminants when traversing components; the component
range for a constrained discriminant is a single value.
(Composite_Case_Ops.Choice_Analysis.Parse_Choice): Eliminate
Done variable and modify how Next_Part is computed so that it is
always correct (as opposed to being incorrect when Done is
True).  This includes changes in Update_Result (a local
procedure).  Add new local procedure
Update_Result_For_Box_Component and call it not just for box
components but also for "missing" components (components
associated with an inactive variant).
(Check_Choices.Check_Composite_Case_Selector.Check_Component_Subtype):
Instead of disallowing all discriminated component types, allow
those that are unconstrained or statically constrained. Check
discriminant subtypes along with other component subtypes.
* doc/gnat_rm/implementation_defined_pragmas.rst: Update
documentation to reflect current implementation status.
* gnat_rm.texi: Regenerate.

3 years ago[Ada] Crash on inlined separate subprogram
Justin Squirek [Sun, 13 Jun 2021 16:52:18 +0000 (12:52 -0400)]
[Ada] Crash on inlined separate subprogram

gcc/ada/

* sem_ch6.adb (Check_Pragma_Inline): Correctly use
Corresponding_Spec_Of_Stub when dealing subprogram body stubs.

3 years ago[Ada] Declare time_t uniformly based on a system parameter
Doug Rupp [Sat, 5 Jun 2021 19:58:35 +0000 (12:58 -0700)]
[Ada] Declare time_t uniformly based on a system parameter

gcc/ada/

* Makefile.rtl: Add translations for s-parame__posix2008.ads
* libgnarl/s-linux.ads: Import System.Parameters.
(time_t): Declare using System.Parameters.time_t_bits.
* libgnarl/s-linux__alpha.ads: Likewise.
* libgnarl/s-linux__android.ads: Likewise.
* libgnarl/s-linux__hppa.ads: Likewise.
* libgnarl/s-linux__mips.ads: Likewise.
* libgnarl/s-linux__riscv.ads: Likewise.
* libgnarl/s-linux__sparc.ads: Likewise.
* libgnarl/s-linux__x32.ads: Likewise.
* libgnarl/s-qnx.ads: Likewise.
* libgnarl/s-osinte__aix.ads: Likewise.
* libgnarl/s-osinte__android.ads: Likewise.
* libgnarl/s-osinte__darwin.ads: Likewise.
* libgnarl/s-osinte__dragonfly.ads: Likewise.
* libgnarl/s-osinte__freebsd.ads: Likewise.
* libgnarl/s-osinte__gnu.ads: Likewise.
* libgnarl/s-osinte__hpux-dce.ads: Likewise.
* libgnarl/s-osinte__hpux.ads: Likewise.
* libgnarl/s-osinte__kfreebsd-gnu.ads: Likewise.
* libgnarl/s-osinte__lynxos178e.ads: Likewise.
* libgnarl/s-osinte__qnx.ads: Likewise.
* libgnarl/s-osinte__rtems.ads: Likewise.
* libgnarl/s-osinte__solaris.ads: Likewise.
* libgnarl/s-osinte__vxworks.ads: Likewise.
* libgnat/g-sothco.ads: Likewise.
* libgnat/s-osprim__darwin.adb: Likewise.
* libgnat/s-osprim__posix.adb: Likewise.
* libgnat/s-osprim__posix2008.adb: Likewise.
* libgnat/s-osprim__rtems.adb: Likewise.
* libgnat/s-osprim__x32.adb: Likewise.
* libgnarl/s-osinte__linux.ads: use type System.Linux.time_t.
* libgnat/s-os_lib.ads (time_t): Declare as subtype of
Long_Long_Integer.
* libgnat/s-parame.ads (time_t_bits): New constant.
* libgnat/s-parame__ae653.ads (time_t_bits): Likewise.
* libgnat/s-parame__hpux.ads (time_t_bits): Likewise.
* libgnat/s-parame__vxworks.ads (time_t_bits): Likewise.
* libgnat/s-parame__posix2008.ads: New file for 64 bit time_t.

3 years ago[Ada] Add source file name to gnat bug box
Bob Duff [Mon, 14 Jun 2021 13:37:24 +0000 (09:37 -0400)]
[Ada] Add source file name to gnat bug box

gcc/ada/

* comperr.adb (Compiler_Abort): Print source file name.

3 years ago[Ada] Fix layout of contracts
Joffrey Huguet [Thu, 10 Jun 2021 09:39:01 +0000 (11:39 +0200)]
[Ada] Fix layout of contracts

gcc/ada/

* libgnat/a-strunb.ads, libgnat/a-strunb__shared.ads: Fix layout
in contracts.

3 years ago[Ada] Fix invalid JSON for derived variant record with -gnatRj
Eric Botcazou [Fri, 11 Jun 2021 07:11:13 +0000 (09:11 +0200)]
[Ada] Fix invalid JSON for derived variant record with -gnatRj

gcc/ada/

* repinfo.ads (JSON output format): Document adjusted key name.
* repinfo.adb (List_Record_Layout): Use Original_Record_Component
if the normalized position of the component is not known.
(List_Structural_Record_Layout): Rename Outer_Ent parameter into
Ext_End and add Ext_Level parameter. In an extension, if the parent
subtype has static discriminants, call List_Record_Layout on it.
Output "parent_" prefixes before "variant" according to Ext_Level.
Adjust recursive calls throughout the procedure.

3 years ago[Ada] Fix typo in comment related to derived discriminated types
Piotr Trojanek [Fri, 11 Jun 2021 14:01:36 +0000 (16:01 +0200)]
[Ada] Fix typo in comment related to derived discriminated types

gcc/ada/

* exp_util.ads (Map_Types): Fix typo.

3 years ago[Ada] Fix index range violations in krunch
Fedor Rybin [Fri, 4 Jun 2021 18:01:27 +0000 (21:01 +0300)]
[Ada] Fix index range violations in krunch

gcc/ada/

* krunch.adb: Add safeguards against index range violations.

3 years ago[Ada] Code cleanups in a-strfix.adb
Arnaud Charlet [Wed, 9 Jun 2021 15:58:47 +0000 (11:58 -0400)]
[Ada] Code cleanups in a-strfix.adb

gcc/ada/

* libgnat/a-strfix.adb: Take advantage of extended returns.

3 years ago[Ada] Add paragraph about representation changes and Scalar_Storage_Order
Eric Botcazou [Thu, 10 Jun 2021 08:21:46 +0000 (10:21 +0200)]
[Ada] Add paragraph about representation changes and Scalar_Storage_Order

gcc/ada/

* doc/gnat_rm/implementation_defined_attributes.rst
(Scalar_Storage_Order): Add paragraph about representation
changes.
* gnat_rm.texi: Regenerate.

3 years ago[Ada] aarch64-rtems6: use wraplf variant for a-nallfl
Frederic Konrad [Tue, 13 Apr 2021 08:55:52 +0000 (10:55 +0200)]
[Ada] aarch64-rtems6: use wraplf variant for a-nallfl

gcc/ada/

* Makefile.rtl (LIBGNAT_TARGET_PAIRS) <aarch64*-*-rtems*>: Use
the wraplf variant of Aux_Long_Long_Float.

3 years ago[Ada] Initialize local variables related to static expression functions
Piotr Trojanek [Tue, 8 Jun 2021 23:04:35 +0000 (01:04 +0200)]
[Ada] Initialize local variables related to static expression functions

gcc/ada/

* sem_ch6.adb (Analyze_Expression_Function): Initialize Orig_N
and Typ variables.

3 years ago[Ada] Inconsistency between declaration and body of predicate functions
Arnaud Charlet [Mon, 10 May 2021 15:29:08 +0000 (11:29 -0400)]
[Ada] Inconsistency between declaration and body of predicate functions

gcc/ada/

* sem_ch13.adb (Resolve_Aspect_Expressions): Use the same
processing for Predicate, Static_Predicate and
Dynamic_Predicate. Do not build the predicate function spec.
Update comments.
(Resolve_Name): Only reset Entity when necessary to avoid
spurious visibility errors.
(Check_Aspect_At_End_Of_Declarations): Handle consistently all
Predicate aspects.
* sem_ch3.adb (Analyze_Subtype_Declaration): Fix handling of
private types with predicates.

3 years ago[Ada] Incremental patch for restriction No_Dynamic_Accessibility_Checks
Justin Squirek [Thu, 3 Jun 2021 21:15:51 +0000 (17:15 -0400)]
[Ada] Incremental patch for restriction No_Dynamic_Accessibility_Checks

gcc/ada/

* sem_util.ads (Type_Access_Level): Add new optional parameter
Assoc_Ent.
* sem_util.adb (Accessibility_Level): Treat access discriminants
the same as components when the restriction
No_Dynamic_Accessibility_Checks is enabled.
(Deepest_Type_Access_Level): Remove exception for
Debug_Flag_Underscore_B when returning the result of
Type_Access_Level in the case where
No_Dynamic_Accessibility_Checks is active.
(Function_Call_Or_Allocator_Level): Correctly calculate the
level of Expr based on its containing subprogram instead of
using Current_Subprogram.
* sem_res.adb (Valid_Conversion): Add actual for new parameter
Assoc_Ent in call to Type_Access_Level, and add test of
No_Dynamic_Accessibility_Checks_Enabled to ensure that static
accessibility checks are performed for all anonymous access type
conversions.

3 years ago[Ada] Update internal documentation of debugging information
Eric Botcazou [Tue, 8 Jun 2021 11:24:46 +0000 (13:24 +0200)]
[Ada] Update internal documentation of debugging information

gcc/ada/

* exp_dbug.ads: Update documentation of various items.

3 years ago[Ada] Reorder preanalysis of static expression functions
Piotr Trojanek [Fri, 28 May 2021 13:32:16 +0000 (15:32 +0200)]
[Ada] Reorder preanalysis of static expression functions

gcc/ada/

* sem_ch6.adb (Analyze_Expression_Function): Reorder code.

3 years ago[Ada] Decouple analysis of static expression functions from GNATprove
Piotr Trojanek [Fri, 28 May 2021 13:11:03 +0000 (15:11 +0200)]
[Ada] Decouple analysis of static expression functions from GNATprove

gcc/ada/

* sem_ch6.adb (Analyze_Expression_Function): Reorder code.

3 years ago[Ada] Avoid repeated computing of type of expression functions
Piotr Trojanek [Fri, 28 May 2021 13:01:18 +0000 (15:01 +0200)]
[Ada] Avoid repeated computing of type of expression functions

gcc/ada/

* sem_ch6.adb (Analyze_Expression_Function): Add variable to
avoid repeated calls to Etype.

3 years ago[Ada] Fix comment related to analysis of expression functions
Piotr Trojanek [Fri, 28 May 2021 12:56:32 +0000 (14:56 +0200)]
[Ada] Fix comment related to analysis of expression functions

gcc/ada/

* sem_ch6.adb (Analyze_Expression_Function): Fix comment.

3 years ago[Ada] Avoid repeated calls in analysis of expression functions
Piotr Trojanek [Fri, 28 May 2021 12:53:21 +0000 (14:53 +0200)]
[Ada] Avoid repeated calls in analysis of expression functions

gcc/ada/

* sem_ch6.adb (Analyze_Expression_Function): Use Orig_N variable
instead of repeated calls to Original_Node.

3 years ago[Ada] Refine types of local variables in analysis of expression functions
Piotr Trojanek [Fri, 28 May 2021 12:51:43 +0000 (14:51 +0200)]
[Ada] Refine types of local variables in analysis of expression functions

gcc/ada/

* sem_ch6.adb (Analyze_Expression_Function): Change types local
variables from Entity_Id to Node_Id.

3 years ago[Ada] Remove an unnecessary local constant
Piotr Trojanek [Fri, 28 May 2021 10:53:05 +0000 (12:53 +0200)]
[Ada] Remove an unnecessary local constant

gcc/ada/

* sem_ch6.adb (Analyze_Expression_Function): A local Expr
constant was shadowing a global constant with the same name and
the same value.

3 years ago[Ada] Avoid unnecessary call in preanalysis without freezing
Piotr Trojanek [Fri, 28 May 2021 12:54:01 +0000 (14:54 +0200)]
[Ada] Avoid unnecessary call in preanalysis without freezing

gcc/ada/

* sem_res.adb (Preanalyze_And_Resolve): Only call
Set_Must_Not_Freeze when it is necessary to restore the previous
value.

3 years agoFix build failure on Windows with older binutils
Eric Botcazou [Fri, 9 Jul 2021 10:08:52 +0000 (12:08 +0200)]
Fix build failure on Windows with older binutils

This is the build failure on Windows with binutils for which GNU as accepts
the --gdwarf-5 switch but GNU ld generates broken binaries with DWARF 5.

We already have the HAVE_LD_BROKEN_PE_DWARF5 kludge to disable DWARF 5 in
this case but it only tames the DWARF version in the compiler, so the
driver still passes --gdwarf-5 when invoked on an assembly file with -g.

gcc/
PR target/101377
* gcc.c (ASM_DEBUG_DWARF_OPTION): Set again to --gdwarf2 in
the case where HAVE_AS_WORKING_DWARF_N_FLAG is not defined
and HAVE_LD_BROKEN_PE_DWARF5 is defined.

3 years agoi386: Fix *udivmodsi4_pow2_zext_? patterns
Uros Bizjak [Fri, 9 Jul 2021 09:45:54 +0000 (11:45 +0200)]
i386: Fix *udivmodsi4_pow2_zext_? patterns

In addition to the obvious cut-n-pasto where *udivmodsi4_pow2_zext_2
never matches, limit the range of the immediate operand to prevent
out of range immediate operand of AND instruction.

Found by inspection, the patterns rarely match (if at all), since
tree optimizers do the transformation before RTL is generated. But
according to the comment above *udivmod<mode>4_pow2, the constant can
materialize after expansion, so leave these patterns around for now.

2021-07-09  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
* config/i386/i386.md (*udivmodsi4_pow2_zext_1): Limit the
log2 range of operands[3] to [1,31].
(*udivmodsi4_pow2_zext_2): Ditto.  Correct insn RTX pattern.

3 years agodocs: don't split @smallexample in multiple @groups
Sergei Trofimovich [Fri, 9 Jul 2021 07:26:15 +0000 (08:26 +0100)]
docs: don't split @smallexample in multiple @groups

Noticed multiple groups split in HTML documentation where example
was written in two columns:

                                                   ""
                                                   "
  (define_expand "addsi3"                          {
    [(match_operand:SI 0 "register_operand" "")      handle_add (...
     (match_operand:SI 1 "register_operand" "")      DONE;
     (match_operand:SI 2 "register_operand" "")]   }")

The change uses single @group/@endgroup to prevent such break.

gcc/ChangeLog:

* doc/md.texi: Don't split @smallexample in multiple @groups.

3 years agodocs: add missing 'see' word
Sergei Trofimovich [Fri, 9 Jul 2021 07:19:37 +0000 (08:19 +0100)]
docs: add missing 'see' word

gcc/ChangeLog:

* doc/md.texi: Add missing 'see' word.

3 years agoImprove early simplify and match for phiopt
Andrew Pinski [Tue, 6 Jul 2021 03:13:48 +0000 (20:13 -0700)]
Improve early simplify and match for phiopt

Previously the idea was gimple_simplify_phiopt would call
resimplify with a NULL sequence but that sometimes fails
even if there was only one statement produced. The cases
where it fails is when there are two simplifications happen.
In the case of the min/max production, the first simplifcation
produces:
(convert (min @1 @2))
And then the convert is removed by a second one. The Min statement
will be in the sequence while the op will be a SSA name. This was
rejected before as could not produce something in the sequence.
So this patch changes the way resimplify is called to always passing
a pointer to the sequence and then decide based on if op is a
SSA_NAME or not.

OK? Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-phiopt.c (phiopt_early_allow): Change arguments
to take sequence and gimple_match_op.  Accept the case where
op is a SSA_NAME and one statement in the sequence.
Also allow constants.
(gimple_simplify_phiopt): Always pass a sequence to resimplify.
Update call to phiopt_early_allow.  Discard the sequence if not
used.

3 years agotestsuite: mips: use noinline attribute instead of -fno-inline
Xi Ruoyao [Tue, 22 Jun 2021 06:15:45 +0000 (14:15 +0800)]
testsuite: mips: use noinline attribute instead of -fno-inline

mips.exp does not support -fno-inline, causing the tests return "ERROR:
Unrecognised option: -fno-inline for dg-options ... ".

Use noinline attribute like other mips target tests, to workaround it.

gcc/testsuite/

* gcc.target/mips/cfgcleanup-jalr2.c: Remove -fno-inline and add
  __attribute__((noinline)).
* gcc.target/mips/cfgcleanup-jalr3.c: Likewise.

3 years agomips: check MSA support for vector modes [PR100760,PR100761,PR100762]
Xi Ruoyao [Fri, 18 Jun 2021 12:11:42 +0000 (20:11 +0800)]
mips: check MSA support for vector modes [PR100760,PR100761,PR100762]

Check if the vector mode is really supported by MSA in certain cases,
instead of testing ISA_HAS_MSA.  Simply testing ISA_HAS_MSA can cause
ICE when MSA is enabled besides other MIPS SIMD extensions (notably,
Loongson MMI).

gcc/

PR target/100760
PR target/100761
PR target/100762
* config/mips/mips.c (mips_const_insns): Use MSA_SUPPORTED_MODE_P
instead of ISA_HAS_MSA.
(mips_expand_vec_unpack): Likewise.
(mips_expand_vector_init): Likewise.

gcc/testsuite/

PR target/100760
PR target/100761
PR target/100762
* gcc.target/mips/pr100760.c: New test.
* gcc.target/mips/pr100761.c: New test.
* gcc.target/mips/pr100762.c: New test.

3 years agors6000: Support [u]mod<mode>3 for vector modulo insns
Kewen Lin [Fri, 9 Jul 2021 03:00:24 +0000 (22:00 -0500)]
rs6000: Support [u]mod<mode>3 for vector modulo insns

This patch is to make Power10 newly introduced vector
modulo instructions exploited in vectorized loops, it
just simply renames existing define_insns as standard
pattern names.

gcc/ChangeLog:

* config/rs6000/vsx.md (mods_<mode>): Rename to...
(mod<mode>3): ... this.
(modu_<mode>): Rename to...
(umod<mode>3): ... this.
* config/rs6000/rs6000-builtin.def (MODS_V2DI, MODS_V4SI, MODU_V2DI,
MODU_V4SI): Adjust.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/mod-vectorize.c: New test.

3 years agotest/rs6000: Add case to cover vector division
Kewen Lin [Fri, 9 Jul 2021 03:00:18 +0000 (22:00 -0500)]
test/rs6000: Add case to cover vector division

This patch is to add one test case to check if vectorizer
can exploit vector division instrutions newly introduced
by Power10.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/div-vectorize-1.c: New test.

3 years agotest/rs6000: Add cases to cover vector multiply
Kewen Lin [Fri, 9 Jul 2021 02:59:50 +0000 (21:59 -0500)]
test/rs6000: Add cases to cover vector multiply

This patch is to add test cases to check if vectorizer
can exploit vector multiply instrutions on Power, some
of them are supported since Power8, the others are newly
introduced by Power10.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/mul-vectorize-1.c: New test.
* gcc.target/powerpc/mul-vectorize-2.c: New test.

3 years agoDaily bump.
GCC Administrator [Fri, 9 Jul 2021 00:16:27 +0000 (00:16 +0000)]
Daily bump.

3 years agoMove warning suppression to the ultimate callee.
Martin Sebor [Thu, 8 Jul 2021 22:36:15 +0000 (16:36 -0600)]
Move warning suppression to the ultimate callee.

Resolves:
PR bootstrap/101372 - -Warray-bounds in gcc/cp/module.cc causing bootstrap failure

gcc/cp/ChangeLog:

PR bootstrap/101372
* module.cc (identifier): Suppress warning.
(module_state::read_macro_maps): Remove warning suppression.
(module_state::install_macros): Ditto.

3 years agotestsuite: Remove an xfail.
Martin Sebor [Thu, 8 Jul 2021 22:22:25 +0000 (16:22 -0600)]
testsuite: Remove an xfail.

gcc/testsuite/ChangeLog:

* gcc.dg/Wstringop-overflow-43.c: Remove an xfail.

3 years agoAdjust expected output for LP32 [PR100451].
Martin Sebor [Thu, 8 Jul 2021 22:08:20 +0000 (16:08 -0600)]
Adjust expected output for LP32 [PR100451].

gcc/testsuite/ChangeLog:

PR testsuite/100451
* g++.dg/warn/Warray-bounds-20.C: Adjust expected output for LP32.

3 years agoAvoid including <new> to make cross-compiler testing easy.
Martin Sebor [Thu, 8 Jul 2021 22:02:01 +0000 (16:02 -0600)]
Avoid including <new> to make cross-compiler testing easy.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Warray-bounds-11.C: Avoid including <new>.
* g++.dg/warn/Warray-bounds-13.C: Same.

3 years agoc++: Fix noexcept with unevaluated operand [PR101087]
Marek Polacek [Thu, 8 Jul 2021 00:02:18 +0000 (20:02 -0400)]
c++: Fix noexcept with unevaluated operand [PR101087]

It sounds plausible that this assert

  int f();
  static_assert(noexcept(sizeof(f())));

should pass: sizeof produces a std::size_t and its operand is not
evaluated, so it can't throw.  noexcept should only evaluate to
false for potentially evaluated operands.  Therefore I think that
check_noexcept_r shouldn't walk into operands of sizeof/decltype/
alignof/typeof.

PR c++/101087

gcc/cp/ChangeLog:

* cp-tree.h (unevaluated_p): New.
* except.c (check_noexcept_r): Use it.  Don't walk into
unevaluated operands.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/noexcept70.C: New test.

3 years agoFurther improvements to H8 variable shift patterns
Jeff Law [Thu, 8 Jul 2021 21:09:36 +0000 (17:09 -0400)]
Further improvements to H8 variable shift patterns

gcc/

* config/h8300/shiftrotate.md (variable shifts): Expose condition
code handling for the test before the loop.

3 years agoipa-sra: Fix thinko when overriding safe_to_import_accesses (PR 101066)
Martin Jambor [Thu, 8 Jul 2021 17:44:41 +0000 (19:44 +0200)]
ipa-sra: Fix thinko when overriding safe_to_import_accesses (PR 101066)

The "new" IPA-SRA has a more difficult job than the previous
not-truly-IPA version when identifying situations in which a parameter
passed by reference can be passed into a third function and only thee
converted to one passed by value (and possibly "split" at the same
time).

In order to allow this, two conditions must be fulfilled.  First the
call to the third function must happen before any modifications of
memory, because it could change the value passed by reference.
Second, in order to make sure we do not introduce new (invalid)
dereferences, the call must postdominate the entry BB.

The second condition is actually not necessary if the caller function
is also certain to dereference the pointer but the first one must
still hold.  Unfortunately, the code making this overriding decision
also happen to trigger when the first condition is not fulfilled.
This is fixed in the following patch.

gcc/ChangeLog:

2021-06-16  Martin Jambor  <mjambor@suse.cz>

PR ipa/101066
* ipa-sra.c (class isra_call_summary): New member
m_before_any_store, initialize it in the constructor.
(isra_call_summary::dump): Dump the new field.
(ipa_sra_call_summaries::duplicate): Copy it.
(process_scan_results): Set it.
(isra_write_edge_summary): Stream it.
(isra_read_edge_summary): Likewise.
(param_splitting_across_edge): Only override
safe_to_import_accesses if m_before_any_store is set.

gcc/testsuite/ChangeLog:

2021-06-16  Martin Jambor  <mjambor@suse.cz>

PR ipa/101066
* gcc.dg/ipa/pr101066.c: New test.

3 years agoUse Object Size Type zero for -Warray-bounds [PR101374].
Martin Sebor [Thu, 8 Jul 2021 17:34:27 +0000 (11:34 -0600)]
Use Object Size Type zero for -Warray-bounds [PR101374].

Resolves:
PR bootstrap/101374 - -Warray-bounds accessing a member subobject as derived

gcc/cp/ChangeLog:
PR bootstrap/101374
* module.cc (module_state::read_macro_maps): Temporarily disable
-Warray-bounds.
(module_state::install_macros): Same.

gcc/ChangeLog:
PR bootstrap/101374
* gimple-array-bounds.cc (array_bounds_checker::check_mem_ref):
Use Object Size Type 0 instead of 1.

gcc/testsuite/ChangeLog:
PR bootstrap/101374
* c-c++-common/Warray-bounds-3.c: Xfail assertion.
* c-c++-common/Warray-bounds-4.c: Same.

3 years agotestsuite: Add arm_arch_v7a_ok effective-target to pr57351.c
Christophe Lyon [Wed, 30 Jun 2021 13:47:07 +0000 (13:47 +0000)]
testsuite: Add arm_arch_v7a_ok effective-target to pr57351.c

I've noticed that overriding cpu/arch flags when running the testsuite
can cause this test to fail rather than being skipped because of
incompatible flags combination.

Since the test forces -march=armv7-a, make sure it is accepted in
combination with the current runtestflags.

2021-07-08  Christophe Lyon  <christophe.lyon@foss.st.om>

gcc/testsuite/
* gcc.dg/debug/pr57351.c: Require arm_arch_v7a_ok
effective-target.

3 years ago[Ada] Tune detection of illegal occurrences of target_name
Piotr Trojanek [Mon, 7 Jun 2021 08:18:29 +0000 (10:18 +0200)]
[Ada] Tune detection of illegal occurrences of target_name

gcc/ada/

* sem_ch5.adb (Analyze_Assignment): Clear Current_Assignment at
exit.
(Analyze_Target_Name): Prevent AST climbing from going too far.

3 years ago[Ada] Diagnose properly illegal uses of Target_Name
Ed Schonberg [Sun, 6 Jun 2021 00:05:31 +0000 (20:05 -0400)]
[Ada] Diagnose properly illegal uses of Target_Name

gcc/ada/

* sem_ch5.adb (Analyze_Target_Name): Properly reject a
Target_Name when it appears outside of an assignment statement,
or within the left-hand side of one.

3 years ago[Ada] Remove Unknown_ functions
Bob Duff [Fri, 4 Jun 2021 12:13:23 +0000 (08:13 -0400)]
[Ada] Remove Unknown_ functions

gcc/ada/

* einfo-utils.ads, einfo-utils.adb (Unknown_Alignment,
Unknown_Component_Bit_Offset, Unknown_Component_Size,
Unknown_Esize, Unknown_Normalized_First_Bit,
Unknown_Normalized_Position, Unknown_Normalized_Position_Max,
Unknown_RM_Size): Remove these functions.
* exp_pakd.adb, exp_util.adb, fe.h, freeze.adb, layout.adb,
repinfo.adb, sem_ch13.adb, sem_ch3.adb, sem_util.adb: Remove
calls to these functions; do "not Known_..." instead.
* gcc-interface/decl.c, gcc-interface/trans.c
(Unknown_Alignment, Unknown_Component_Size, Unknown_Esize,
Unknown_RM_Size): Remove calls to these functions; do
"!Known_..." instead.

3 years ago[Ada] Use encoded names only with -fgnat-encodings=all
Eric Botcazou [Fri, 4 Jun 2021 16:08:49 +0000 (18:08 +0200)]
[Ada] Use encoded names only with -fgnat-encodings=all

gcc/ada/

* exp_dbug.adb (Get_Encoded_Name): Do not encode names of discrete
types with custom bounds, except with -fgnat-encodings=all.
* exp_pakd.adb (Create_Packed_Array_Impl_Type): Adjust comment.

3 years ago[Ada] Transient scope cleanup
Bob Duff [Thu, 3 Jun 2021 16:10:30 +0000 (12:10 -0400)]
[Ada] Transient scope cleanup

gcc/ada/

* comperr.adb (Compiler_Abort): Call Sinput.Unlock, because if
this is called late, then Source_Dump would crash otherwise.
* debug.adb: Correct documentation of the -gnatd.9 switch.
* exp_ch4.adb (Expand_Allocator_Expression): Add a comment.
* exp_ch6.adb: Minor comment fixes.  Add assertion.
* exp_ch6.ads (Is_Build_In_Place_Result_Type): Correct comment.
* exp_ch7.adb, checks.ads: Minor comment fixes.

3 years ago[Ada] Rename sigtramp-vxworks-target.inc to sigtramp-vxworks-target.h
Doug Rupp [Thu, 3 Jun 2021 16:21:23 +0000 (09:21 -0700)]
[Ada] Rename sigtramp-vxworks-target.inc to sigtramp-vxworks-target.h

gcc/ada/

* sigtramp-vxworks-target.inc: Rename to...
* sigtramp-vxworks-target.h: ... this.
* sigtramp-vxworks.c, Makefile.rtl: Likewise.

3 years ago[Ada] Duplicated D lines in ali files
Ghjuvan Lacambre [Thu, 27 May 2021 12:54:14 +0000 (14:54 +0200)]
[Ada] Duplicated D lines in ali files

gcc/ada/

* lib-writ.ads: Mention SCOs dependency as reason for duplicates.
* lib.ads (Units): Update documentation to mention duplicated
units.

3 years ago[Ada] Spurious style message on missing overriding indicator
Ed Schonberg [Sat, 29 May 2021 14:14:46 +0000 (10:14 -0400)]
[Ada] Spurious style message on missing overriding indicator

gcc/ada/

* style.adb (Missing_Overriding): Do not emit message when
parent of subprogram is a full type declaration.

3 years ago[Ada] AI12-0156 Use subtype indication in generalized iterators
Arnaud Charlet [Mon, 31 May 2021 08:59:01 +0000 (04:59 -0400)]
[Ada] AI12-0156 Use subtype indication in generalized iterators

gcc/ada/

* par-ch5.adb (P_Iterator_Specification): Add support for access
definition in loop parameter.
* sem_ch5.adb (Check_Subtype_Indication): Renamed...
(Check_Subtype_Definition): ... into this and check for conformance
on access definitions, and improve error messages.
(Analyze_Iterator_Specification): Add support for access definition
in loop parameter.

3 years ago[Ada] Spurious warning in generic instance
Arnaud Charlet [Fri, 28 May 2021 14:25:39 +0000 (10:25 -0400)]
[Ada] Spurious warning in generic instance

gcc/ada/

* sem_util.ads, sem_util.adb
(Apply_Compile_Time_Constraint_Error): New parameter
Emit_Message.
* sem_ch4.adb (Analyze_Selected_Component): Disable warning
within an instance.

3 years ago[Ada] Fix violation of No_Implicit_Loops restriction for enumeration type
Eric Botcazou [Mon, 31 May 2021 14:32:14 +0000 (16:32 +0200)]
[Ada] Fix violation of No_Implicit_Loops restriction for enumeration type

gcc/ada/

* exp_imgv.adb: Add with and use clause for Restrict and Rident.
(Build_Enumeration_Image_Tables): Do not generate the hash function
if the No_Implicit_Loops restriction is active.

3 years ago[Ada] Simplify redundant checks for non-empty lists
Piotr Trojanek [Thu, 27 May 2021 15:16:34 +0000 (17:16 +0200)]
[Ada] Simplify redundant checks for non-empty lists

gcc/ada/

* sem_ch12.adb, sem_ch6.adb, sem_ch9.adb, sprint.adb: Simplify
checks for non-empty lists.

3 years ago[Ada] Remove redundant condition for listing compilation units
Piotr Trojanek [Tue, 25 May 2021 18:41:55 +0000 (20:41 +0200)]
[Ada] Remove redundant condition for listing compilation units

gcc/ada/

* par-ch10.adb (Unit_Display): Remove redundant condition; fix
whitespace.

3 years ago[Ada] Restore context on failure in loading of renamed child unit
Piotr Trojanek [Tue, 25 May 2021 15:39:26 +0000 (17:39 +0200)]
[Ada] Restore context on failure in loading of renamed child unit

gcc/ada/

* lib-load.adb (Load): Replace early return with goto to properly
restore context on failure.

3 years ago[Ada] Replace low-level condition with a high-level call
Piotr Trojanek [Tue, 25 May 2021 15:40:38 +0000 (17:40 +0200)]
[Ada] Replace low-level condition with a high-level call

gcc/ada/

* lib-writ.adb (Ensure_System_Dependency): Simplify condition.

3 years ago[Ada] Fix style in comments and code related to compilation units
Piotr Trojanek [Wed, 26 May 2021 13:27:02 +0000 (15:27 +0200)]
[Ada] Fix style in comments and code related to compilation units

gcc/ada/

* lib-load.adb (Load_Unit): Fix style in comment.
* par-load.adb (Load): Likewise.
* scng.adb (Initialize_Scanner): Fix whitespace.

3 years ago[Ada] Prevent infinite recursion when there is no expected unit
Piotr Trojanek [Wed, 26 May 2021 13:05:28 +0000 (15:05 +0200)]
[Ada] Prevent infinite recursion when there is no expected unit

gcc/ada/

* par-load.adb (Load): Don't remove unit, but flag it as
erroneous and return.

3 years ago[Ada] Fix use of single question mark in error message
Ghjuvan Lacambre [Wed, 26 May 2021 16:02:34 +0000 (18:02 +0200)]
[Ada] Fix use of single question mark in error message

gcc/ada/

* exp_prag.adb (Expand_Pragma_Inspection_Point): Fix error
message.

3 years ago[Ada] Skip types in error for test to compute array size
Yannick Moy [Wed, 26 May 2021 12:54:02 +0000 (14:54 +0200)]
[Ada] Skip types in error for test to compute array size

gcc/ada/

* layout.adb (Layout_Type): Do not call Number_Dimensions if the
type does not have First_Index set.

3 years ago[Ada] Prevent crash on inspection point for unfrozen entity
Ghjuvan Lacambre [Tue, 25 May 2021 12:12:37 +0000 (14:12 +0200)]
[Ada] Prevent crash on inspection point for unfrozen entity

gcc/ada/

* exp_prag.adb (Expand_Pragma_Inspection_Point): After expansion
of the Inspection_Point pragma, check if referenced entities
that have a freeze node are already frozen. If they aren't, emit
a warning and turn the pragma into a no-op.

3 years ago[Ada] Fix on computation of packed array size in case of error
Yannick Moy [Wed, 26 May 2021 08:49:14 +0000 (10:49 +0200)]
[Ada] Fix on computation of packed array size in case of error

gcc/ada/

* layout.adb (Layout_Type): Add guard before calling Expr_Value.

3 years ago[Ada] Compute sizes when possible for packed array with Component_Size
Yannick Moy [Wed, 19 May 2021 13:50:02 +0000 (15:50 +0200)]
[Ada] Compute sizes when possible for packed array with Component_Size

gcc/ada/

* layout.adb (Layout_Type): Special case when RM_Size and Esize
can be computed for packed arrays.

3 years ago[Ada] Unsynchronized concurrent access to a Boolean variable
Steve Baird [Mon, 24 May 2021 21:38:07 +0000 (14:38 -0700)]
[Ada] Unsynchronized concurrent access to a Boolean variable

gcc/ada/

* rtsfind.ads, rtsfind.adb: Add support for finding the packages
System.Atomic_Operations and
System.Atomic_Operations.Test_And_Set and the declarations
within that latter package of the type Test_And_Set_Flag and the
function Atomic_Test_And_Set.
* exp_ch11.adb (Expand_N_Exception_Declaration): If an exception
is declared other than at library level, then we need to call
Register_Exception the first time (and only the first time) the
declaration is elaborated.  In order to decide whether to
perform this call for a given elaboration of the declaration, we
used to unconditionally use a (library-level) Boolean variable.
Now we instead use a variable of type
System.Atomic_Operations.Test_And_Set.Test_And_Set_Flag unless
either that type is unavailable or a No_Tasking restriction is
in effect (in which case we use a Boolean variable as before).

3 years ago[Ada] Add No_Tasking restriction is system.ads for bootstrap
Arnaud Charlet [Fri, 21 May 2021 08:04:55 +0000 (04:04 -0400)]
[Ada] Add No_Tasking restriction is system.ads for bootstrap

gcc/ada/

* gcc-interface/system.ads: Add No_Tasking restriction.

3 years ago[Ada] Incorrect iteration over hashed containers after multiple Inserts
Ed Schonberg [Fri, 21 May 2021 19:51:13 +0000 (15:51 -0400)]
[Ada] Incorrect iteration over hashed containers after multiple Inserts

gcc/ada/

* libgnat/a-cohama.ads: Introduce an equality operator over
cursors.
* libgnat/a-cohase.ads: Ditto.
* libgnat/a-cohama.adb: Add body for "=" over cursors.
(Insert): Do not set the Position component of the cursor that
denotes the inserted element.
* libgnat/a-cohase.adb: Ditto.

3 years ago[Ada] Make runtime code compatible with No_Dynamic_Accessibility_Checks
Arnaud Charlet [Tue, 25 May 2021 08:18:21 +0000 (04:18 -0400)]
[Ada] Make runtime code compatible with No_Dynamic_Accessibility_Checks

gcc/ada/

* libgnat/a-cbdlli.adb, libgnat/a-cbhama.adb,
libgnat/a-cbhase.adb, libgnat/a-cbmutr.adb,
libgnat/a-cborma.adb, libgnat/a-cborse.adb,
libgnat/a-cobove.adb, libgnat/a-textio.adb,
libgnat/a-witeio.adb, libgnat/a-ztexio.adb: Make code compatible
with No_Dynamic_Accessibility_Checks restriction.

3 years ago[Ada] Revert meaning of -gnatd_b
Arnaud Charlet [Mon, 24 May 2021 12:38:20 +0000 (08:38 -0400)]
[Ada] Revert meaning of -gnatd_b

gcc/ada/

* debug.adb, sem_util.adb: Revert meaning of -gnatd_b.
* sem_res.adb: Minor reformatting.

3 years ago[Ada] Make tools compatible with No_Dynamic_Accessibility_Checks
Arnaud Charlet [Mon, 24 May 2021 11:07:49 +0000 (07:07 -0400)]
[Ada] Make tools compatible with No_Dynamic_Accessibility_Checks

gcc/ada/

* make.adb, osint.adb: Make code compatible with
No_Dynamic_Accessibility_Checks restriction.

3 years ago[Ada] Avoid linear search when ensuring dependency on System
Piotr Trojanek [Mon, 24 May 2021 14:14:40 +0000 (16:14 +0200)]
[Ada] Avoid linear search when ensuring dependency on System

gcc/ada/

* lib-writ.adb (Ensure_System_Dependency): Replace search in
Lib.Units with a search in Lib.Unit_Names.

3 years ago[Ada] Simplify string manipulation related to preprocessing
Piotr Trojanek [Mon, 24 May 2021 13:27:28 +0000 (15:27 +0200)]
[Ada] Simplify string manipulation related to preprocessing

gcc/ada/

* sinput-l.adb (Load_File): Simplify foreword manipulation with
concatenation; similar for filename with preprocessed output.

3 years agovect: Remove always-true condition
Richard Sandiford [Thu, 8 Jul 2021 11:58:13 +0000 (12:58 +0100)]
vect: Remove always-true condition

vectorizable_reduction had code guarded by:

  if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def
      || STMT_VINFO_DEF_TYPE (stmt_info) == vect_double_reduction_def)

But that's always true after:

  if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_reduction_def
      && STMT_VINFO_DEF_TYPE (stmt_info) != vect_double_reduction_def
      && STMT_VINFO_DEF_TYPE (stmt_info) != vect_nested_cycle)
    return false;

  if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_nested_cycle)
    {
      …
      return true;
    }

(I wasn't sure at first how the empty “else” for the first “if” above
was supposed to work.)

gcc/
* tree-vect-loop.c (vectorizable_reduction): Remove always-true
if condition.

3 years agomatch.pd: Relax rule to include POLY_INT_CSTs
Richard Sandiford [Thu, 8 Jul 2021 11:49:44 +0000 (12:49 +0100)]
match.pd: Relax rule to include POLY_INT_CSTs

match.pd has a rule to simplify an extension, operation and truncation
back to the original type:

 (simplify
   (convert (op:s@0 (convert1?@3 @1) (convert2?@4 @2)))

Currently it handles cases in which @2 is an INTEGER_CST, but it
also works for POLY_INT_CSTs.[*]

For INTEGER_CST it doesn't matter whether we test @2 or @4,
but for POLY_INT_CST it is possible to have unfolded (convert …)s.

Originally I saw this leading to some bad ivopts decisions, because
we weren't folding away redundancies from candidate iv expressions.
It's also possible to test the fold directly using the SVE ACLE.

[*] Not all INTEGER_CST rules work for POLY_INT_CSTs, since extensions
    don't necessarily distribute over the internals of the POLY_INT_CST.
    But in this case that isn't an issue.

gcc/
* match.pd: Simplify an extend-operate-truncate sequence involving
a POLY_INT_CST.

gcc/testsuite/
* gcc.target/aarch64/sve/acle/general/cntb_1.c: New test.

3 years agoPR tree-optimization/40210: Fold (bswap(X)>>C1)&C2 to (X>>C3)&C2 in match.pd
Roger Sayle [Thu, 8 Jul 2021 10:46:14 +0000 (11:46 +0100)]
PR tree-optimization/40210: Fold (bswap(X)>>C1)&C2 to (X>>C3)&C2 in match.pd

All of the optimizations/transformations mentioned in bugzilla for
PR tree-optimization/40210 are already implemented in mainline GCC,
with one exception.  In comment #5, there's a suggestion that
(bswap64(x)>>56)&0xff can be implemented without the bswap as
(unsigned char)x, or equivalently x&0xff.

This patch implements the above optimization, and closely related
variants.  For any single bit, (bswap(X)>>C1)&1 can be simplified
to (X>>C2)&1, where bit position C2 is the appropriate permutation
of C1.  Similarly, the bswap can eliminated if the desired set of
bits all lie within the same byte, hence (bswap(x)>>8)&255 can
always be optimized, as can (bswap(x)>>8)&123.

Previously,
int foo(long long x) {
  return (__builtin_bswap64(x) >> 56) & 0xff;
}

compiled with -O2 to
foo: movq    %rdi, %rax
        bswap   %rax
        shrq    $56, %rax
        ret

with this patch, it now compiles to
foo: movzbl  %dil, %eax
        ret

2021-07-08  Roger Sayle  <roger@nextmovesoftware.com>
    Richard Biener  <rguenther@suse.de>

gcc/ChangeLog
PR tree-optimization/40210
* match.pd (bswap optimizations): Simplify (bswap(x)>>C1)&C2 as
(x>>C3)&C2 when possible.  Simplify bswap(x)>>C1 as ((T)x)>>C2
when possible.  Simplify bswap(x)&C1 as (x>>C2)&C1 when 0<=C1<=255.

gcc/testsuite/ChangeLog
PR tree-optimization/40210
* gcc.dg/builtin-bswap-13.c: New test.
* gcc.dg/builtin-bswap-14.c: New test.

3 years agoi386: Add pack/unpack patterns for 32bit vectors [PR100637]
Uros Bizjak [Thu, 8 Jul 2021 10:19:54 +0000 (12:19 +0200)]
i386: Add pack/unpack patterns for 32bit vectors [PR100637]

V1SI mode shift is needed to shift 32bit operands and consequently we
need to implement V1SI moves and pushes.

2021-07-08  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
PR target/100637
* config/i386/i386-expand.c (ix86_expand_sse_unpack):
Handle V4QI mode.
* config/i386/mmx.md (V_32): New mode iterator.
(mov<V_32:mode>): Use V_32 mode iterator.
(*mov<V_32:mode>_internal): Ditto.
(*push<V_32:mode>2_rex64): Ditto.
(*push<V_32:mode>2): Ditto.
(movmisalign<V_32:mode>): Ditto.
(mmx_<any_shiftrt:insn>v1si3): New insn pattern.
(sse4_1_<any_extend:code>v2qiv2hi2): Ditto.
(vec_unpacks_lo_v4qi): New expander.
(vec_unpacks_hi_v4qi): Ditto.
(vec_unpacku_lo_v4qi): Ditto.
(vec_unpacku_hi_v4qi): Ditto.
* config/i386/i386.h (VALID_SSE2_REG_MODE): Add V1SImode.
(VALID_INT_MODE_P): Ditto.

3 years agoGenerate 128-bit int divide/modulus on power10.
Michael Meissner [Thu, 8 Jul 2021 01:55:38 +0000 (21:55 -0400)]
Generate 128-bit int divide/modulus on power10.

This patch adds support for the VDIVSQ, VDIVUQ, VMODSQ, and VMODUQ
instructions to do 128-bit arithmetic.

2021-07-07  Michael Meissner  <meissner@linux.ibm.com>

gcc/
PR target/100809
* config/rs6000/rs6000.md (udivti3): New insn.
(divti3): New insn.
(umodti3): New insn.
(modti3): New insn.

gcc/testsuite/
PR target/100809
* gcc.target/powerpc/p10-vdivq-vmodq.c: New test.

3 years agoDaily bump.
GCC Administrator [Thu, 8 Jul 2021 00:16:27 +0000 (00:16 +0000)]
Daily bump.

3 years agoanalyzer: remove add_any_constraints_from_ssa_def_stmt
David Malcolm [Wed, 7 Jul 2021 23:29:30 +0000 (19:29 -0400)]
analyzer: remove add_any_constraints_from_ssa_def_stmt

I'm working on reimplementing -Wanalyzer-use-of-uninitialized-value, but
I ran into issues with
region_model::add_any_constraints_from_ssa_def_stmt.
This function is from the initial commit of the analyzer and walks the
SSA names finding conditions that were missed due to the GCC 10 era
region_model not retaining useful information on how values were
created; as of GCC 11 the symbolic values contain this information,
and so the conditions can be reconstructed from them instead.

region_model::add_any_constraints_from_ssa_def_stmt is a liability
when tracking uninitialized values as it requires looking up SSA
values when those values may have been purged, thus greatly complicating
detection of uses of uninitialized values.

It's simplest to eliminate it and reimplement the condition-finding
via the makeup of the svalues, which this patch does.  Doing so requires
supporting add_condition on svalues rather than just on trees, which
requires some changes to ana::state_machine and its subclasses.

gcc/analyzer/ChangeLog:
* diagnostic-manager.cc (null_assignment_sm_context::get_state):
New overload.
(null_assignment_sm_context::set_next_state): New overload.
(null_assignment_sm_context::get_diagnostic_tree): New.
* engine.cc (impl_sm_context::get_state): New overload.
(impl_sm_context::set_next_state): New overload.
(impl_sm_context::get_diagnostic_tree): New overload.
(impl_region_model_context::on_condition): Convert params from
tree to const svalue *.
* exploded-graph.h (impl_region_model_context::on_condition):
Likewise.
* region-model.cc (region_model::on_call_pre): Move handling of
internal calls to before checking for get_fndecl_for_call.
(region_model::add_constraints_from_binop): New.
(region_model::add_constraint): Split out into a new overload
working on const svalue * rather than tree.  Call
add_constraints_from_binop.  Drop call to
add_any_constraints_from_ssa_def_stmt.
(region_model::add_any_constraints_from_ssa_def_stmt): Delete.
(region_model::add_any_constraints_from_gassign): Delete.
(region_model::add_any_constraints_from_gcall): Delete.
* region-model.h
(region_model::add_any_constraints_from_ssa_def_stmt): Delete.
(region_model::add_any_constraints_from_gassign): Delete.
(region_model::add_any_constraints_from_gcall): Delete.
(region_model::add_constraint): Add overload decl.
(region_model::add_constraints_from_binop): New decl.
(region_model_context::on_condition): Convert params from tree to
const svalue *.
(noop_region_model_context::on_condition): Likewise.
* sm-file.cc (fileptr_state_machine::condition): Likewise.
* sm-malloc.cc (malloc_state_machine::on_condition): Likewise.
* sm-pattern-test.cc: Include tristate.h, selftest.h,
analyzer/call-string.h, analyzer/program-point.h,
analyzer/store.h, and analyzer/region-model.h.
(pattern_test_state_machine::on_condition): Convert params from tree to
const svalue *.
* sm-sensitive.cc (sensitive_state_machine::on_condition): Delete.
* sm-signal.cc (signal_state_machine::on_condition): Delete.
* sm-taint.cc (taint_state_machine::on_condition): Convert params
from tree to const svalue *.
* sm.cc: Include tristate.h, selftest.h, analyzer/call-string.h,
analyzer/program-point.h, analyzer/store.h, and
analyzer/region-model.h.
(any_pointer_p): Add overload taking const svalue *sval.
* sm.h (any_pointer_p): Add overload taking const svalue *sval.
(state_machine::on_condition): Convert params from tree to
const svalue *.  Provide no-op default implementation.
(sm_context::get_state): Add overload taking const svalue *sval.
(sm_context::set_next_state): Likewise.
(sm_context::on_transition): Likewise.
(sm_context::get_diagnostic_tree): Likewise.
* svalue.cc (svalue::all_zeroes_p): New.
(constant_svalue::all_zeroes_p): New.
(repeated_svalue::all_zeroes_p): Convert to vfunc.
* svalue.h (svalue::all_zeroes_p): New decl.
(constant_svalue::all_zeroes_p): New decl.
(repeated_svalue::all_zeroes_p): Convert decl to vfunc.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/pattern-test-2.c: Update expected results.
* gcc.dg/plugin/analyzer_gil_plugin.c
(gil_state_machine::on_condition): Remove.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
3 years agoCorrect handling of variable offset minus constant in -Warray-bounds [PR100137]
Martin Sebor [Wed, 7 Jul 2021 20:05:25 +0000 (14:05 -0600)]
Correct handling of variable offset minus constant in -Warray-bounds [PR100137]

Resolves:
PR tree-optimization/100137 - -Warray-bounds false positive on varying offset plus negative
PR tree-optimization/99121 - ICE in -Warray-bounds on a multidimensional
PR tree-optimization/97027 - missing warning on buffer overflow storing a larger scalar into a smaller array

gcc/ChangeLog:

PR tree-optimization/100137
PR tree-optimization/99121
PR tree-optimization/97027
* builtins.c (access_ref::access_ref): Also set offmax.
(access_ref::offset_in_range): Define new function.
(access_ref::add_offset): Set offmax.
(access_ref::inform_access): Handle access_none.
(handle_mem_ref): Clear ostype.
(compute_objsize_r): Handle ASSERT_EXPR.
* builtins.h (struct access_ref): Add offmax member.
* gimple-array-bounds.cc (array_bounds_checker::check_mem_ref): Use
compute_objsize() and simplify.

gcc/testsuite/ChangeLog:

PR tree-optimization/100137
PR tree-optimization/99121
PR tree-optimization/97027
* c-c++-common/Warray-bounds-3.c: Remove xfail
* c-c++-common/Warray-bounds-4.c: Add an expected warning.
* c-c++-common/Warray-bounds-9.c: New test.
* c-c++-common/Warray-bounds-10.c: New test.
* g++.dg/asan/asan_test.C: Suppress expected warnings.
* g++.dg/pr95768.C: Same.
* g++.dg/warn/Warray-bounds-10.C: Adjust text of expected messages.
* g++.dg/warn/Warray-bounds-11.C: Same.
* g++.dg/warn/Warray-bounds-12.C: Same.
* g++.dg/warn/Warray-bounds-13.C: Same.
* g++.dg/warn/Warray-bounds-17.C: Same.
* g++.dg/warn/Warray-bounds-20.C: Same.
* gcc.dg/Warray-bounds-29.c: Same.
* gcc.dg/Warray-bounds-30.c: Add xfail.
* gcc.dg/Warray-bounds-31.c: Adjust text of expected messages.
* gcc.dg/Warray-bounds-32.c: Same.
* gcc.dg/Warray-bounds-52.c: Same.
* gcc.dg/Warray-bounds-53.c: Same.
* gcc.dg/Warray-bounds-58.c: Remove xfail.
* gcc.dg/Warray-bounds-63.c: Adjust text of expected messages.
* gcc.dg/Warray-bounds-66.c: Same.
* gcc.dg/Warray-bounds-69.c: Same.
* gcc.dg/Wstringop-overflow-34.c: Same.
* gcc.dg/Wstringop-overflow-47.c: Same.
* gcc.dg/Wstringop-overflow-61.c: Same.
* gcc.dg/Warray-bounds-77.c: New test.
* gcc.dg/Warray-bounds-78.c: New test.
* gcc.dg/Warray-bounds-79.c: New test.

3 years agors6000: Harden mma_init_builtins
Peter Bergner [Wed, 7 Jul 2021 16:39:34 +0000 (11:39 -0500)]
rs6000: Harden mma_init_builtins

The previous MMA patch added some fragile code to initialize its new
built-ins.  This patch hardens the initialization.

2021-07-07  Peter Bergner  <bergner@linux.ibm.com>

gcc/
* config/rs6000/rs6000-call.c (mma_init_builtins): Use VSX_BUILTIN_LXVP
and VSX_BUILTIN_STXVP.

3 years ago[Ada] Remove unused define
Dmitriy Anisimkov [Thu, 20 May 2021 16:58:31 +0000 (22:58 +0600)]
[Ada] Remove unused define

gcc/ada/

* s-oscons-tmplt.c (MSG_WAITALL): Remove wrong #ifdef
__MINWGW32__.

3 years ago[Ada] Assertion errors on concurrent types with -gnatc and extensions enabled
Gary Dismukes [Fri, 21 May 2021 17:59:30 +0000 (13:59 -0400)]
[Ada] Assertion errors on concurrent types with -gnatc and extensions enabled

gcc/ada/

* einfo-utils.adb (Primitive_Operations): Default to returning
Direct_Primitive_Operations in the case of concurrent types
(when Corresponding_Record_Type not present).
* sem_ch9.adb (Analyze_Protected_Type_Declaration): Initialize
Direct_Primitive_Operations to an empty element list.
(Analyze_Task_Type_Declaration): Initialize
Direct_Primitive_Operations to an empty element list.

3 years ago[Ada] Stronger assertion about flag for checking static expressions
Piotr Trojanek [Fri, 21 May 2021 09:47:45 +0000 (11:47 +0200)]
[Ada] Stronger assertion about flag for checking static expressions

gcc/ada/

* sem_eval.adb (Set_Checking_Potentially_Static_Expression):
Stronger assertion.

3 years ago[Ada] Front-end inlining and instantiations of UC
Arnaud Charlet [Thu, 20 May 2021 10:40:48 +0000 (06:40 -0400)]
[Ada] Front-end inlining and instantiations of UC

gcc/ada/

* sem_ch12.adb (Analyze_Subprogram_Instantiation): Mark Anon_Id
intrinsic before calling Analyze_Instance_And_Renamings because
this flag may be propagated to other nodes.

3 years ago[Ada] Keepalive control on Windows
Dmitriy Anisimkov [Thu, 20 May 2021 13:55:02 +0000 (19:55 +0600)]
[Ada] Keepalive control on Windows

gcc/ada/

* s-oscons-tmplt.c (TCP_KEEPCNT TCP_KEEPIDLE, TCP_KEEPINTVL):
Hardcode on Windows if undefined.

3 years ago[Ada] Optimize away certain elaboration checks
Bob Duff [Wed, 19 May 2021 18:24:13 +0000 (14:24 -0400)]
[Ada] Optimize away certain elaboration checks

gcc/ada/

* checks.adb (Install_Primitive_Elaboration_Check): Do not
generate elaboration checks for primitives if pragma Pure or
Preelaborate is present.  Misc comment fixes, including
referring to the correct kind of check (elaboration, not
accessibility).
* checks.ads, restrict.adb, sem_cat.ads, sinfo.ads: Minor
reformatting and comment fixes.

3 years ago[Ada] Simplify code by reusing Remove on list of primitive operations
Piotr Trojanek [Wed, 19 May 2021 12:05:01 +0000 (14:05 +0200)]
[Ada] Simplify code by reusing Remove on list of primitive operations

gcc/ada/

* sem_prag.adb (Analyze_Pragma): Simplify processing of pragma
CPP_Constructor.

3 years ago[Ada] Minor code cleanup
Arnaud Charlet [Thu, 20 May 2021 08:21:39 +0000 (04:21 -0400)]
[Ada] Minor code cleanup

gcc/ada/

* libgnat/g-debpoo.adb (Code_Address_For_Allocate_End): Default
Initialize.

3 years ago[Ada] Code cleanups in System.Atomic_Counters
Arnaud Charlet [Wed, 12 May 2021 09:28:29 +0000 (05:28 -0400)]
[Ada] Code cleanups in System.Atomic_Counters

gcc/ada/

* libgnat/s-atocou.ads, libgnat/s-atocou__builtin.adb: Code
cleanups.