Tamar Christina [Mon, 14 Nov 2022 15:52:26 +0000 (15:52 +0000)]
AArch64: Add implementation for pow2 bitmask division.
This adds an implementation for the new optab for unsigned pow2 bitmask for
AArch64.
The implementation rewrites:
x = y / (2 ^ (sizeof (y)/2)-1
into e.g. (for bytes)
(x + ((x + 257) >> 8)) >> 8
where it's required that the additions be done in double the precision of x
such that we don't lose any bits during an overflow.
Essentially the sequence decomposes the division into doing two smaller
divisions, one for the top and bottom parts of the number and adding the results
back together.
To account for the fact that shift by 8 would be division by 256 we add 1 to
both parts of x such that when 255 we still get 1 as the answer.
Because the amount we shift are half the original datatype we can use the
halfing instructions the ISA provides to do the operation instead of using
actual shifts.
For AArch64 this means we generate for:
void draw_bitmap1(uint8_t* restrict pixel, uint8_t level, int n)
{
for (int i = 0; i < (n & -16); i+=1)
pixel[i] = (pixel[i] * level) / 0xff;
}
the following:
movi v3.16b, 0x1
umull2 v1.8h, v0.16b, v2.16b
umull v0.8h, v0.8b, v2.8b
addhn v5.8b, v1.8h, v3.8h
addhn v4.8b, v0.8h, v3.8h
uaddw v1.8h, v1.8h, v5.8b
uaddw v0.8h, v0.8h, v4.8b
uzp2 v0.16b, v0.16b, v1.16b
instead of:
umull v2.8h, v1.8b, v5.8b
umull2 v1.8h, v1.16b, v5.16b
umull v0.4s, v2.4h, v3.4h
umull2 v2.4s, v2.8h, v3.8h
umull v4.4s, v1.4h, v3.4h
umull2 v1.4s, v1.8h, v3.8h
uzp2 v0.8h, v0.8h, v2.8h
uzp2 v1.8h, v4.8h, v1.8h
shrn v0.8b, v0.8h, 7
shrn2 v0.16b, v1.8h, 7
Which results in significantly faster code.
Thanks for Wilco for the concept.
gcc/ChangeLog:
* config/aarch64/aarch64-simd.md (@aarch64_bitmask_udiv<mode>3): New.
* config/aarch64/aarch64.cc (aarch64_vectorize_can_special_div_by_constant): New.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/div-by-bitmask.c: New test.
Tamar Christina [Mon, 14 Nov 2022 15:43:48 +0000 (15:43 +0000)]
middle-end: Support not decomposing specific divisions during vectorization.
In plenty of image and video processing code it's common to modify pixel values
by a widening operation and then scale them back into range by dividing by 255.
e.g.:
x = y / (2 ^ (bitsize (y)/2)-1
This patch adds a new target hook can_special_div_by_const, similar to
can_vec_perm which can be called to check if a target will handle a particular
division in a special way in the back-end.
The vectorizer will then vectorize the division using the standard tree code
and at expansion time the hook is called again to generate the code for the
division.
Alot of the changes in the patch are to pass down the tree operands in all paths
that can lead to the divmod expansion so that the target hook always has the
type of the expression you're expanding since the types can change the
expansion.
gcc/ChangeLog:
* expmed.h (expand_divmod): Pass tree operands down in addition to RTX.
* expmed.cc (expand_divmod): Likewise.
* explow.cc (round_push, align_dynamic_address): Likewise.
* expr.cc (force_operand, expand_expr_divmod): Likewise.
* optabs.cc (expand_doubleword_mod, expand_doubleword_divmod):
Likewise.
* target.h: Include tree-core.
* target.def (can_special_div_by_const): New.
* targhooks.cc (default_can_special_div_by_const): New.
* targhooks.h (default_can_special_div_by_const): New.
* tree-vect-generic.cc (expand_vector_operation): Use it.
* doc/tm.texi.in: Document it.
* doc/tm.texi: Regenerate.
* tree-vect-patterns.cc (vect_recog_divmod_pattern): Check for support.
* tree-vect-stmts.cc (vectorizable_operation): Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/vect/vect-div-bitmask-1.c: New test.
* gcc.dg/vect/vect-div-bitmask-2.c: New test.
* gcc.dg/vect/vect-div-bitmask-3.c: New test.
* gcc.dg/vect/vect-div-bitmask.h: New file.
Tamar Christina [Mon, 14 Nov 2022 15:42:42 +0000 (15:42 +0000)]
middle-end: Add optimized float addsub without needing VEC_PERM_EXPR.
For IEEE 754 floating point formats we can replace a sequence of alternative
+/- with fneg of a wider type followed by an fadd. This eliminated the need for
using a permutation. This patch adds a math.pd rule to recognize and do this
rewriting.
For
void f (float *restrict a, float *restrict b, float *res, int n)
{
for (int i = 0; i < (n & -4); i+=2)
{
res[i+0] = a[i+0] + b[i+0];
res[i+1] = a[i+1] - b[i+1];
}
}
we generate:
.L3:
ldr q1, [x1, x3]
ldr q0, [x0, x3]
fneg v1.2d, v1.2d
fadd v0.4s, v0.4s, v1.4s
str q0, [x2, x3]
add x3, x3, 16
cmp x3, x4
bne .L3
now instead of:
.L3:
ldr q1, [x0, x3]
ldr q2, [x1, x3]
fadd v0.4s, v1.4s, v2.4s
fsub v1.4s, v1.4s, v2.4s
tbl v0.16b, {v0.16b - v1.16b}, v3.16b
str q0, [x2, x3]
add x3, x3, 16
cmp x3, x4
bne .L3
Thanks to George Steed for the idea.
gcc/ChangeLog:
* generic-match-head.cc: Include langooks.
* gimple-match-head.cc: Likewise.
* match.pd: Add fneg/fadd rule.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/simd/addsub_1.c: New test.
* gcc.target/aarch64/sve/addsub_1.c: New test.
Jonathan Wakely [Mon, 14 Nov 2022 10:37:58 +0000 (10:37 +0000)]
libstdc++: Fix installation of python files for debug lib
libstdc++-v3/ChangeLog:
* python/Makefile.am (install-data-local): Use mkdirs_p for debug
libdir.
* python/Makefile.in: Regenerate.
Srinath Parvathaneni [Mon, 14 Nov 2022 15:45:59 +0000 (15:45 +0000)]
arm: Add support for Cortex-X1C CPU.
This patch adds the -mcpu support for the Arm Cortex-X1C CPU.
gcc/ChangeLog:
2022-11-09 Srinath Parvathaneni <srinath.parvathaneni@arm.com>
* config/arm/arm-cpus.in (cortex-x1c): Define new CPU.
* config/arm/arm-tables.opt: Regenerate.
* config/arm/arm-tune.md: Likewise.
* doc/invoke.texi: Document Cortex-X1C CPU.
gcc/testsuite/ChangeLog:
2022-11-09 Srinath Parvathaneni <srinath.parvathaneni@arm.com>
* gcc.target/arm/multilib.exp: Add tests for Cortex-X1C.
Srinath Parvathaneni [Mon, 14 Nov 2022 15:18:26 +0000 (15:18 +0000)]
aarch64: Add support for Cortex-X3 CPU.
This patch adds support for Cortex-X3 CPU.
gcc/ChangeLog:
2022-11-09 Srinath Parvathaneni <srinath.parvathaneni@arm.com>
* config/aarch64/aarch64-cores.def (AARCH64_CORE): Add Cortex-X3
CPU.
* config/aarch64/aarch64-tune.md: Regenerate.
* doc/invoke.texi: Document Cortex-X3 CPU.
Andrew Pinski [Mon, 14 Nov 2022 15:21:36 +0000 (15:21 +0000)]
Fix @opindex for m80387
I noticed that the opindex for -m80387
option was wrong. It was just 80387 which
was not consistent with the rest of the options.
This fixes that and uses "@opindex m80387".
Committed as obvious after "make html" and checking
the option index page.
gcc/ChangeLog:
* doc/invoke.texi: Fix @opindex
for m80387 option.
Andrew Pinski [Mon, 14 Nov 2022 15:02:10 +0000 (15:02 +0000)]
Fix some @opindex with - in the front
I noticed this during the conversion of the docs
to sphinx that some options in the option index had a -
in the front of it for the texinfo docs. When the sphinx
conversion was reverted, I thought I would fix the texinfo
documentation for these options.
Committed as obvious after doing "make html" to check
the resulting option index page.
gcc/ChangeLog:
* doc/invoke.texi: Remove the front - from
some @opindex.
Philipp Tomsich [Mon, 7 Nov 2022 13:22:21 +0000 (14:22 +0100)]
aarch64: Add support for Ampere-1A (-mcpu=ampere1a) CPU
This patch adds support for Ampere-1A CPU:
- recognize the name of the core and provide detection for -mcpu=native,
- updated extra_costs,
- adds a new fusion pair for (A+B+1 and A-B-1).
Ampere-1A and Ampere-1 have more timing difference than the extra
costs indicate, but these don't propagate through to the headline
items in our extra costs (e.g. the change in latency for scalar sqrt
doesn't have a corresponding table entry).
gcc/ChangeLog:
* config/aarch64/aarch64-cores.def (AARCH64_CORE): Add ampere1a.
* config/aarch64/aarch64-cost-tables.h: Add ampere1a_extra_costs.
* config/aarch64/aarch64-fusion-pairs.def (AARCH64_FUSION_PAIR):
Define a new fusion pair for A+B+1/A-B-1 (i.e., add/subtract two
registers and then +1/-1).
* config/aarch64/aarch64-tune.md: Regenerate.
* config/aarch64/aarch64.cc (aarch_macro_fusion_pair_p): Implement
idiom-matcher for the new fusion pair.
* doc/invoke.texi: Add ampere1a.
Boris Yakobowski [Wed, 9 Nov 2022 13:02:00 +0000 (14:02 +0100)]
ada: Silence CodePeer false positive
gcc/ada/
* sem_case.adb: silence false positive warning emitted by CodePeer
on predefined equality for type Choice_Range_Info.
Bob Duff [Mon, 7 Nov 2022 14:25:31 +0000 (09:25 -0500)]
ada: Remove incorrect comments about initialization
Cleanup only; no change in behavior.
This patch removes and rewrites some comments regarding initialization.
These initializions are needed, so there's no need to apologize for
initializing these variables.
Note that -gnatVa is not relevant; reads of uninitialized variables
are wrong, whether or not we get caught.
gcc/ada/
* atree.ads: Remove some comments.
* err_vars.ads: Likewise.
* scans.ads: Likewise.
* sinput.ads: Likewise.
* checks.ads: Likewise. Also add a "???" comment indicating an
obsolete comment that is too difficult to correct at this time.
* sem_attr.adb: Minor comment rewrite.
Javier Miranda [Mon, 7 Nov 2022 09:28:56 +0000 (09:28 +0000)]
ada: Flag unsupported dispatching constructor calls
gcc/ada/
* exp_intr.adb
(Expand_Dispatching_Constructor_Call): Improve warning message.
* freeze.adb
(Check_No_Parts_Violations): Improve error message.
Alexandre Oliva [Thu, 6 Oct 2022 05:23:48 +0000 (02:23 -0300)]
ada: hardcfr docs: add optional checkpoints
Previously, control flow redundancy only checked the visited bitmap
against the control flow graph at return points and before mandatory
tail calls, missing various other possibilities of exiting a
subprogram, such as by raising or propagating exceptions, and calling
noreturn functions. The checks inserted before returns also prevented
potential tail-call optimizations.
This incremental change introduces options to control checking at each
of these previously-missed checkpoints. Unless disabled, a cleanup is
introduced to check when an exceptions escapes a subprogram. To avoid
disrupting sibcall optimizations, when they are enabled, checks are
introduced before calls whose results are immediately returned,
whether or not they are ultimately optimized. If enabled, checks are
introduced before noreturn calls and exception raises, or only before
nothrow noreturn calls.
Add examples of code transformations to the GNAT RM.
gcc/ada/
* doc/gnat_rm/security_hardening_features.rst: Document optional
hardcfr checkpoints.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.
Gary Dismukes [Wed, 2 Nov 2022 23:02:34 +0000 (19:02 -0400)]
ada: Crash on applying 'Pos to expression of a type derived from a formal type
The compiler crashes when trying to do a static check for a range violation
in a type conversion of a Pos attribute applied to a prefix of a type derived
from a generic formal discrete type. This optimization was suppressed in the
case of formal types, because the upper bound may not be known, but it also
needs to be suppressed for types derived from formal types.
gcc/ada/
* checks.adb
(Apply_Type_Conversion_Checks): Apply Root_Type to the type of the
prefix of a Pos attribute when checking whether the type is a
formal discrete type.
Ronan Desplanques [Mon, 31 Oct 2022 17:08:37 +0000 (18:08 +0100)]
ada: Fix non-capturing parentheses handling
Before this patch, non-capturingly parenthesized expressions with more
than one branch were processed incorrectly when part of a branch
followed by another branch. This patch fixes this by aligning the
handling of non-capturing parentheses with the handling of regular
parentheses.
gcc/ada/
* libgnat/s-regpat.adb
(Parse): Fix handling of non-capturing parentheses.
Yannick Moy [Mon, 31 Oct 2022 10:33:12 +0000 (11:33 +0100)]
ada: Fix error on SPARK_Mode on library-level separate body
When applying explicitly SPARK_Mode on a separate library-level spec
and body for which a contract needs to be checked, compilation with
-gnata was failing on a spurious error related to SPARK_Mode
placement. Now fixed.
gcc/ada/
* sem_prag.adb (Analyze_Pragma): Add special case for the special
local subprogram created for contracts.
Piotr Trojanek [Fri, 28 Oct 2022 20:15:53 +0000 (22:15 +0200)]
ada: Adjust locations in aspects on generic formal subprograms
When instantiating a generic that has formal subprogram parameter with
contracts, e.g.:
generic
with procedure P with Pre => ..., Post => ...;
...
we create a wrapper that executes Pre/Post contracts before/after
calling the actual subprogram. Errors emitted for these contracts
will now have locations of the instance and not just of the generic.
gcc/ada/
* sem_ch12.adb (Build_Subprogram_Wrappers): Adjust slocs of the
copied aspects, just like we do in Build_Class_Wide_Expression for
inherited class-wide contracts.
Piotr Trojanek [Fri, 28 Oct 2022 20:10:25 +0000 (22:10 +0200)]
ada: Fix style in code for generic formal subprograms with contracts
Code cleanup related to expansion generic formal subprograms with
contracts for GNATprove.
gcc/ada/
* inline.adb (Replace_Formal): Tune whitespace.
* sem_ch12.adb (Check_Overloaded_Formal_Subprogram): Refine type
of a formal parameter and local variable; this routine operates on
nodes and not entities.
* sem_ch12.ads: Tune whitespace.
Piotr Trojanek [Fri, 28 Oct 2022 18:28:45 +0000 (20:28 +0200)]
ada: Expand generic formal subprograms with contracts for GNATprove
In GNATprove mode generic formal subprograms with Pre/Post contracts are
now expanded into wrappers, just like in ordinary compilation.
gcc/ada/
* sem_ch12.adb (Analyze_Associations): Expand wrappers for
GNATprove.
Patrick Bernardi [Fri, 28 Oct 2022 21:11:16 +0000 (17:11 -0400)]
ada: Enable Support_Atomic_Primitives on QNX and RTEMS
QNX and RTEMS support 64-bit atomic primitives.
gcc/ada/
* libgnat/system-qnx-arm.ads: Set Support_Atomic_Primitives to
True.
* libgnat/system-rtems.ads: Add Support_Atomic_Primitives.
Yannick Moy [Thu, 27 Oct 2022 10:54:22 +0000 (12:54 +0200)]
ada: Improve location of error messages in instantiations
When flag -gnatdF is used, source code lines are displayed to point
the location of errors. The code of the instantiation was displayed
in case of errors inside generic instances, which was not precise.
Now the code inside the generic is displayed.
gcc/ada/
* errout.adb (Error_Msg_Internal): Store span for Optr field, and
adapt to new type of Optr.
(Finalize. Output_JSON_Message, Remove_Warning_Messages): Adapt to
new type of Optr.
(Output_Messages): Use Optr instead of Sptr to display code
snippet closer to error.
* erroutc.adb (dmsg): Adapt to new type of Optr.
* erroutc.ads (Error_Msg_Object): Make Optr a span like Sptr.
* errutil.adb (Error_Msg): Likewise.
Arnaud Charlet [Thu, 27 Oct 2022 09:27:52 +0000 (09:27 +0000)]
ada: Remove gnatcheck reference
Since gnatcheck is no longer bundled with gnat
gcc/ada/
* doc/gnat_ugn/gnat_utility_programs.rst: Remove gnatcheck
reference.
Richard Biener [Mon, 14 Nov 2022 13:33:43 +0000 (14:33 +0100)]
remove duplicate match.pd patterns
The following merges match.pd patterns that cause genmatch complaints
about duplicates when in-order isn't enforced (you have to edit
genmatch.cc to do a full duplicate check).
* match.pd: Remove duplicates.
Harald Anlauf [Sun, 13 Nov 2022 20:53:58 +0000 (21:53 +0100)]
Fortran: fix treatment of character, value, optional dummy arguments [PR107444]
gcc/fortran/ChangeLog:
PR fortran/107444
* trans-openmp.cc (gfc_omp_check_optional_argument): Adjust to change
of prefix of internal symbol for presence status to '.'.
Bernhard Reutner-Fischer [Mon, 14 Nov 2022 10:13:47 +0000 (10:13 +0000)]
libstdc++: Fix install-debug makefile target
This target should have been changed by r13-3918-gba7551485bc576 and now
fails.
libstdc++-v3/ChangeLog:
* src/Makefile.am (install-debug): Remove use of $(debugdir).
* src/Makefile.in: Regenerate.
Martin Liska [Mon, 14 Nov 2022 02:20:25 +0000 (03:20 +0100)]
doc: port new documentation from Sphinx
gcc/ChangeLog:
* doc/contrib.texi: Port from Sphinx.
* doc/cpp.texi: Likewise.
* doc/install.texi: Likewise.
* doc/invoke.texi: Likewise.
gcc/fortran/ChangeLog:
* gfortran.texi: Port from Sphinx.
Martin Liska [Sun, 13 Nov 2022 21:03:35 +0000 (22:03 +0100)]
Revert "sphinx: copy files from texi2rst-generated repository"
This reverts commit
c63539ffe4c0e327337a1a51f638d9c8c958cb26.
Martin Liska [Sun, 13 Nov 2022 21:01:20 +0000 (22:01 +0100)]
Partially revert
7e3ce73849fef8b50efb427ec96f317e88c0e6cf
gcc/ChangeLog:
* doc/gcc/gcc-command-options/options-controlling-c++-dialect.rst: Revert.
Martin Liska [Sun, 13 Nov 2022 20:59:59 +0000 (21:59 +0100)]
Revert "sphinx: update baseconf.py file"
This reverts commit
8dc319eb495d6fa742a265dfa12dc75bf3576d07.
Martin Liska [Sun, 13 Nov 2022 20:59:57 +0000 (21:59 +0100)]
Revert "sphinx: port .def files to RST"
This reverts commit
c8874c5e8a7cee2933923c40f4933602da2022fb.
Martin Liska [Sun, 13 Nov 2022 20:59:48 +0000 (21:59 +0100)]
Revert "sphinx: use tm.rst.in file in target macros"
This reverts commit
8f2b513c28ae24f0204b3b438747bbd1cfebba0a.
Martin Liska [Sun, 13 Nov 2022 20:59:42 +0000 (21:59 +0100)]
Revert "sphinx: support Sphinx in build system"
This reverts commit
41a45cba0021f597dbfdec1f782026215ea21726.
Martin Liska [Sun, 13 Nov 2022 20:59:37 +0000 (21:59 +0100)]
Revert "sphinx: add tm.rst.in"
This reverts commit
564a805f9f08b4346a854ab8dca2e5b561a7a28e.
Martin Liska [Sun, 13 Nov 2022 20:59:29 +0000 (21:59 +0100)]
Revert "sphinx: remove texinfo files"
This reverts commit
54ca4eef58661a7d7a511e2bbbe309bde1732abf.
Martin Liska [Sun, 13 Nov 2022 20:59:20 +0000 (21:59 +0100)]
Revert "sphinx: jit: port libgccjit to shared Sphinx"
This reverts commit
94246daa3efba88d4ae6619f24d737c01ba3dc89.
Martin Liska [Sun, 13 Nov 2022 20:59:18 +0000 (21:59 +0100)]
Revert "sphinx: ada: port to Sphinx"
This reverts commit
0a543515957ff47feba739e6f71062fb2fb99125.
Martin Liska [Sun, 13 Nov 2022 20:59:12 +0000 (21:59 +0100)]
Revert "sphinx: use proper lexers for target macros"
This reverts commit
c0eb1a3b7c944dd7cd5a4056a817a25aa8ce2569.
Martin Liska [Sun, 13 Nov 2022 20:59:03 +0000 (21:59 +0100)]
Revert "sphinx: add --with-sphinx-build"
This reverts commit
1f5a932e89b0c2c4a7af7f849ca2e2e3dbf329e0.
Martin Liska [Sun, 13 Nov 2022 20:59:01 +0000 (21:59 +0100)]
Revert "sphinx: fix cross manual references"
This reverts commit
72318642439703bba8c83423d4706e06444254d6.
Martin Liska [Sun, 13 Nov 2022 20:58:54 +0000 (21:58 +0100)]
Revert "sphinx: do not use tm.rst.in with empty content"
This reverts commit
66f55038a4238ce5fb1f198feb552653eb472d61.
Martin Liska [Sun, 13 Nov 2022 20:58:45 +0000 (21:58 +0100)]
Revert "sphinx: sync latest changes"
This reverts commit
8857a1e350cf34c4ac06429ec4cb97228489dd07.
Martin Liska [Sun, 13 Nov 2022 20:58:39 +0000 (21:58 +0100)]
Revert "sphinx: support installation if sphinx-build is missing"
This reverts commit
e5821d3f62b5bf532db1be661459b7553a956fa2.
Martin Liska [Sun, 13 Nov 2022 20:58:31 +0000 (21:58 +0100)]
Revert "sphinx: add update_web_docs_git.py script"
This reverts commit
6373b1fdf75ea0908dfaebdbfc54d8b55b08d409.
Martin Liska [Sun, 13 Nov 2022 20:58:22 +0000 (21:58 +0100)]
Revert "sphinx: fix building if sphinx-build is missing"
This reverts commit
1f9c79367e136e0ca5b775562e6111e1a0d0046f.
Martin Liska [Sun, 13 Nov 2022 20:58:13 +0000 (21:58 +0100)]
Revert "avr: sphinx: port gen-avr-mmcu to RST"
This reverts commit
79f1313608b468fd6a0f329d2e265fa67bba7cc1.
Martin Liska [Sun, 13 Nov 2022 20:58:06 +0000 (21:58 +0100)]
Revert "sphinx: simplify default in baseconf.py."
This reverts commit
8d7a55b7f4ce37ecc869bd31cadc3f9e059e2f44.
Martin Liska [Sun, 13 Nov 2022 20:57:56 +0000 (21:57 +0100)]
Revert "sphinx: update crontab with new script"
This reverts commit
d05a423c1e7b81021a1b6bee93db31a903d87667.
Martin Liska [Sun, 13 Nov 2022 20:57:36 +0000 (21:57 +0100)]
Revert "sphinx: update diagnostics URLs"
This reverts commit
9c3bc557995463fe1dcc37ec503af780a6c1a341.
Martin Liska [Sun, 13 Nov 2022 20:57:31 +0000 (21:57 +0100)]
Revert "docs: fix: WARNING: Parsing of expression failed. Using fallback parser."
This reverts commit
a305ac87b46e263a3bc0c886f9dfddf2664f6af8.
Martin Liska [Sun, 13 Nov 2022 20:57:11 +0000 (21:57 +0100)]
Revert "sphinx: add missing trailing newline"
This reverts commit
3ed1b4ce7c9bdf8c777d12da0f5fe4cae8ba7c8e.
Martin Liska [Sun, 13 Nov 2022 20:57:03 +0000 (21:57 +0100)]
Revert "docs: fix links pointing to gcc.gnu.org/install"
This reverts commit
0b3d926d796050468b8a844e5fb8c20bda741c26.
Martin Liska [Sun, 13 Nov 2022 20:56:51 +0000 (21:56 +0100)]
Revert "docs: create sources tarball"
This reverts commit
52eedc1fa3d211f29196eed60e11e6a8738329c2.
Martin Liska [Sun, 13 Nov 2022 20:56:44 +0000 (21:56 +0100)]
Revert "sphinx: add missing HAS_SPHINX_BUILD"
This reverts commit
8f5aa130fa61637baec476119e72849f7e3f8c67.
Martin Liska [Sun, 13 Nov 2022 20:56:34 +0000 (21:56 +0100)]
Revert "docs: Add missing variable name in example"
This reverts commit
d8c105810285ad97e8af31a328c8a75d4adc5a19.
Martin Liska [Sun, 13 Nov 2022 20:56:21 +0000 (21:56 +0100)]
Revert "doc: Use a separate directory for new modules we add to PATH"
This reverts commit
70f1c41061b2b55ed4cdc2e83c7cf326c7ebe7a4.
Martin Liska [Sun, 13 Nov 2022 20:56:06 +0000 (21:56 +0100)]
Revert "doc: Modernize baseconf.py."
This reverts commit
dd31c6923fbe8352f7efa830c47c6d0ab31cfce8.
Martin Liska [Sun, 13 Nov 2022 20:55:58 +0000 (21:55 +0100)]
Revert "maintainer-scripts: fix superfluous 'sh' for Python script"
This reverts commit
9072763f4f17e600a980ff510b2baf8ad8ada1b5.
Martin Liska [Sun, 13 Nov 2022 20:55:45 +0000 (21:55 +0100)]
Revert "sphinx: add missing newline for conf.py files."
This reverts commit
bd044dae51caea3c641f86ec5cb0ebccf7e06de7.
Martin Liska [Sun, 13 Nov 2022 20:55:34 +0000 (21:55 +0100)]
Revert "docs: move label directly before title"
This reverts commit
740cf7d6ab266cf4249fc5c247187622cb6a2c8f.
Martin Liska [Sun, 13 Nov 2022 20:55:18 +0000 (21:55 +0100)]
Partially revert
5c6546ca7d8cab1f1c129f5b55f709e2ceee0f94
gcc/ChangeLog:
* doc/gcc/gcc-command-options/options-that-control-static-analysis.rst:
Revert.
Martin Liska [Sun, 13 Nov 2022 20:54:44 +0000 (21:54 +0100)]
Partially revert
d3fe767c16e7c528e4fc71c8a68ac14b4573d880.
gcc/ChangeLog:
* doc/cpp/pragmas.rst: Revert.
Martin Liska [Sun, 13 Nov 2022 20:54:09 +0000 (21:54 +0100)]
Revert "sphinx: stop using parallel mode"
This reverts commit
08fd14f9589b6e0e3155ba728a5e7031b9250f91.
Martin Liska [Sun, 13 Nov 2022 20:54:03 +0000 (21:54 +0100)]
Revert "doc: update sphinx-build -j auto comment"
This reverts commit
02698e21de26c7d4217f856ee64436148e0aede7.
Martin Liska [Sun, 13 Nov 2022 20:53:54 +0000 (21:53 +0100)]
Revert "jit: doc: Use shared Indices and tables"
This reverts commit
3b54cc9d04c2efb2c8f9a0b515e638917636630c.
Martin Liska [Sun, 13 Nov 2022 20:53:34 +0000 (21:53 +0100)]
Partially revert
cd9eedb8ac2e904880da8d1e3c87a3557c38a04f
gcc/ChangeLog:
* doc/gcc/gcc-command-options/machine-dependent-options/aarch64-options.rst: Revert.
Martin Liska [Sun, 13 Nov 2022 20:53:09 +0000 (21:53 +0100)]
Partially revert
ca1db2725a3232b2e15eaa1bd7fbe33927843476
gcc/ChangeLog:
* doc/gcc/gcc-command-options/machine-dependent-options/aarch64-options.rst: Revert.
Martin Liska [Sun, 13 Nov 2022 20:52:28 +0000 (21:52 +0100)]
Partially revert
12c583a2a3da798e82737c2d0e11fd686636cfeb
gcc/ChangeLog:
* doc/gcc/gcc-command-options/options-that-control-static-analysis.rst: Revert.
* doc/gcc/gcc-command-options/options-to-request-or-suppress-warnings.rst: Revert.
Martin Liska [Sun, 13 Nov 2022 20:50:14 +0000 (21:50 +0100)]
Partially revert
59a63247992eb13153b82c4902aadf111460eac2.
gcc/fortran/ChangeLog:
* doc/gfortran/naming-and-argument-passing-conventions.rst:
Revert.
Martin Liska [Sun, 13 Nov 2022 20:48:34 +0000 (21:48 +0100)]
Revert "doc: Remove outdated reference to "core" and front-end downloads"
This reverts commit
05432288d4e560556ee0455562639b715d8f8b7d.
Martin Liska [Sun, 13 Nov 2022 20:48:24 +0000 (21:48 +0100)]
Revert "configure: always set SPHINX_BUILD"
This reverts commit
5e749ee3019d7917184af30dab8d09c933c0a4a1.
Martin Liska [Sun, 13 Nov 2022 20:48:17 +0000 (21:48 +0100)]
Revert "sphinx: include todolist only if INCLUDE_TODO env. set"
This reverts commit
c64fd69420fd153f9fb16a603ff0a711fbde8335.
Martin Liska [Sun, 13 Nov 2022 20:48:03 +0000 (21:48 +0100)]
Revert "doc: Update Jeff Law's email-address in contrib.rst"
This reverts commit
3bf46ea7bce58918ae8da1c936fe4c55456d2b6b.
Martin Liska [Mon, 14 Nov 2022 02:54:31 +0000 (03:54 +0100)]
Partially revert
d777b38cde91a87f2345dcd13901862a9513562a
gcc/ChangeLog:
* doc/gcc/gcc-command-options/option-summary.rst: Revert.
* doc/gcc/gcc-command-options/options-that-control-static-analysis.rst: Revert.
Haochen Jiang [Fri, 11 Nov 2022 02:17:18 +0000 (10:17 +0800)]
i386: Add AMX-TILE dependency for AMX related ISAs
gcc/ChangeLog:
* common/config/i386/i386-common.cc
(OPTION_MASK_ISA2_AMX_INT8_SET): Add AMX-TILE dependency.
(OPTION_MASK_ISA2_AMX_BF16_SET): Ditto.
(OPTION_MASK_ISA2_AMX_FP16_SET): Ditto.
(OPTION_MASK_ISA2_AMX_TILE_UNSET): Disable AMX_{INT8,
BF16, FP16} when disable AMX_TILE.
gcc/testsuite/ChangeLog:
* gcc.target/i386/amxbf16-dpbf16ps-2.c: Remove -amx-tile.
* gcc.target/i386/amxfp16-dpfp16ps-2.c: Ditto.
* gcc.target/i386/amxint8-dpbssd-2.c: Ditto.
* gcc.target/i386/amxint8-dpbsud-2.c: Ditto.
* gcc.target/i386/amxint8-dpbusd-2.c: Ditto.
* gcc.target/i386/amxint8-dpbuud-2.c: Ditto.
Martin Liska [Mon, 14 Nov 2022 08:27:16 +0000 (09:27 +0100)]
Partially revert
071e428c24ee8c1ed062597a093708bba29509c9
gcc/ChangeLog:
* doc/gcc/gcc-command-options/machine-dependent-options/x86-options.rst:
Revert.
* doc/gcc/gcc-command-options/option-summary.rst:
Revert.
Richard Biener [Mon, 14 Nov 2022 07:08:26 +0000 (08:08 +0100)]
restrict gcc.dg/pr107554.c to 64bit platforms
The following avoids exceeding the maximum object size on 32bit
platforms.
* gcc.dg/pr107554.c: Restrict to lp64.
Hongyu Wang [Thu, 8 Sep 2022 08:52:02 +0000 (16:52 +0800)]
Enable small loop unrolling for O2
Modern processors has multiple way instruction decoders
For x86, icelake/zen3 has 5 uops, so for small loop with <= 4
instructions (usually has 3 uops with a cmp/jmp pair that can be
macro-fused), the decoder would have 2 uops bubble for each iteration
and the pipeline could not be fully utilized.
Therefore, this patch enables loop unrolling for small size loop at O2
to fullfill the decoder as much as possible. It turns on rtl loop
unrolling when targetm.loop_unroll_adjust exists and O2 plus speed only.
In x86 backend the default behavior is to unroll small loops with less
than 4 insns by 1 time.
This improves 548.exchange2 by 9% on icelake and 7.4% on zen3 with
0.9% codesize increment. For other benchmarks the variants are minor
and overall codesize increased by 0.2%.
The kernel image size increased by 0.06%, and no impact on eembc.
gcc/ChangeLog:
* common/config/i386/i386-common.cc (ix86_optimization_table):
Enable small loop unroll at O2 by default.
* config/i386/i386.cc (ix86_loop_unroll_adjust): Adjust unroll
factor if -munroll-only-small-loops enabled and -funroll-loops/
-funroll-all-loops are disabled.
* config/i386/i386.h (struct processor_costs): Add 2 field
small_unroll_ninsns and small_unroll_factor.
* config/i386/i386.opt: Add -munroll-only-small-loops.
* doc/gcc/gcc-command-options/machine-dependent-options/x86-options.rst:
Document -munroll-only-small-loops.
* doc/gcc/gcc-command-options/option-summary.rst: Likewise.
* loop-init.cc (pass_rtl_unroll_loops::gate): Enable rtl
loop unrolling for -O2-speed and above if target hook
loop_unroll_adjust exists.
(pass_rtl_unroll_loops::execute): Set UAP_UNROLL flag
when target hook loop_unroll_adjust exists.
* config/i386/x86-tune-costs.h: Update all processor costs
with small_unroll_ninsns = 4 and small_unroll_factor = 2.
gcc/testsuite/ChangeLog:
* gcc.dg/guality/loop-1.c: Add additional option
-mno-unroll-only-small-loops.
* gcc.target/i386/pr86270.c: Add -mno-unroll-only-small-loops.
* gcc.target/i386/pr93002.c: Likewise.
Martin Liska [Mon, 14 Nov 2022 02:26:17 +0000 (03:26 +0100)]
gcc-changelog: temporarily disable check_line_start
contrib/ChangeLog:
* gcc-changelog/git_commit.py: Temporarily disable
check_line.start.
GCC Administrator [Mon, 14 Nov 2022 00:17:08 +0000 (00:17 +0000)]
Daily bump.
David Malcolm [Sun, 13 Nov 2022 22:53:23 +0000 (17:53 -0500)]
analyzer: new warning: -Wanalyzer-tainted-assertion [PR106235]
This patch adds a new -Wanalyzer-tainted-assertion warning to
-fanalyzer's "taint" mode (which also requires -fanalyzer-checker=taint).
It complains about attacker-controlled values being used in assertions,
or in any expression affecting control flow that guards a "noreturn"
function. As noted in the docs part of the patch, in such cases:
- when assertion-checking is enabled: an attacker could trigger
a denial of service by injecting an assertion failure
- when assertion-checking is disabled, such as by defining NDEBUG,
an attacker could inject data that subverts the process, since it
presumably violates a precondition that is being assumed by the code.
For example, given:
#include <assert.h>
int __attribute__((tainted_args))
test_tainted_assert (int n)
{
assert (n > 0);
return n * n;
}
compiling with
-fanalyzer -fanalyzer-checker=taint
gives:
t.c: In function 'test_tainted_assert':
t.c:6:3: warning: use of attacked-controlled value in condition for assertion [CWE-617] [-Wanalyzer-tainted-assertion]
6 | assert (n > 0);
| ^~~~~~
'test_tainted_assert': event 1
|
| 4 | test_tainted_assert (int n)
| | ^~~~~~~~~~~~~~~~~~~
| | |
| | (1) function 'test_tainted_assert' marked with '__attribute__((tainted_args))'
|
+--> 'test_tainted_assert': event 2
|
| 4 | test_tainted_assert (int n)
| | ^~~~~~~~~~~~~~~~~~~
| | |
| | (2) entry to 'test_tainted_assert'
|
'test_tainted_assert': events 3-6
|
|/usr/include/assert.h:106:10:
| 106 | if (expr) \
| | ^
| | |
| | (3) use of attacker-controlled value for control flow
| | (4) following 'false' branch (when 'n <= 0')...
|......
| 109 | __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION); \
| | ~~~~~~~~~~~~~
| | |
| | (5) ...to here
| | (6) treating '__assert_fail' as an assertion failure handler due to '__attribute__((__noreturn__))'
|
The testcases have various examples for BUG and BUG_ON from the
Linux kernel; there, the diagnostic treats "panic" as an assertion
failure handler, due to '__attribute__((__noreturn__))'.
gcc/analyzer/ChangeLog:
PR analyzer/106235
* analyzer.opt (Wanalyzer-tainted-assertion): New.
* checker-path.cc (checker_path::fixup_locations): Pass false to
pending_diagnostic::fixup_location.
* diagnostic-manager.cc (get_emission_location): Pass true to
pending_diagnostic::fixup_location.
* pending-diagnostic.cc (pending_diagnostic::fixup_location): Add
bool param.
* pending-diagnostic.h (pending_diagnostic::fixup_location): Add
bool param to decl.
* sm-taint.cc (taint_state_machine::m_tainted_control_flow): New.
(taint_diagnostic::describe_state_change): Drop "final".
(class tainted_assertion): New.
(taint_state_machine::taint_state_machine): Initialize
m_tainted_control_flow.
(taint_state_machine::alt_get_inherited_state): Support
comparisons being tainted, based on their arguments.
(is_assertion_failure_handler_p): New.
(taint_state_machine::on_stmt): Complain about calls to assertion
failure handlers guarded by an attacker-controller conditional.
Detect attacker-controlled gcond conditionals and gswitch index
values.
(taint_state_machine::check_control_flow_arg_for_taint): New.
gcc/ChangeLog:
PR analyzer/106235
* doc/gcc/gcc-command-options/option-summary.rst: Add
-Wno-analyzer-tainted-assertion.
* doc/gcc/gcc-command-options/options-that-control-static-analysis.rst:
Add -Wno-analyzer-tainted-assertion.
gcc/testsuite/ChangeLog:
PR analyzer/106235
* gcc.dg/analyzer/taint-assert-BUG_ON.c: New test.
* gcc.dg/analyzer/taint-assert-macro-expansion.c: New test.
* gcc.dg/analyzer/taint-assert.c: New test.
* gcc.dg/analyzer/taint-assert-system-header.c: New test.
* gcc.dg/analyzer/test-assert.h: New header.
* gcc.dg/plugin/analyzer_gil_plugin.c
(gil_diagnostic::fixup_location): Add bool param.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
José Rui Faustino de Sousa [Wed, 9 Nov 2022 20:30:25 +0000 (21:30 +0100)]
Fortran: diagnostics for actual arguments to pointer dummy arguments [PR94104]
Error message improvement. In Fortran 2008 actual procedure arguments
associated with a pointer, intent(in) attribute, dummy argument
can also have the target attribute, not just pointer.
gcc/fortran/ChangeLog:
PR fortran/94104
* interface.cc (gfc_compare_actual_formal): Improve error message
dependent on Fortran standard level.
gcc/testsuite/ChangeLog:
PR fortran/94104
* gfortran.dg/parens_2.f90: Adjust to improved error message.
* gfortran.dg/PR94104a.f90: New test.
* gfortran.dg/PR94104b.f90: New test.
John David Anglin [Sun, 13 Nov 2022 17:04:44 +0000 (17:04 +0000)]
Skip guality tests on hppa-hpux.
The guality check command hangs. This causes TCL errors in
other tests and slows testsuite execution.
2022-11-13 John David Anglin <danglin@gcc.gnu.org>
gcc/testsuite/ChangeLog:
* g++.dg/guality/guality.exp: Skip on hppa*-*-hpux*.
* gcc.dg/guality/guality.exp: Likewise.
* gfortran.dg/guality/guality.exp: Likewise.
Philipp Tomsich [Thu, 22 Sep 2022 23:37:14 +0000 (01:37 +0200)]
RISC-V: optimize '(a >= 0) ? b : 0' to srai + andn, if compiling for Zbb
If-conversion is turning '(a >= 0) ? b : 0' into a branchless sequence
not a5,a0
srai a5,a5,63
and a0,a1,a5
missing the opportunity to combine the NOT and AND into an ANDN.
This adds a define_split to help the combiner reassociate the NOT with
the AND.
gcc/ChangeLog:
* config/riscv/bitmanip.md: New define_split.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/zbb-srai-andn.c: New test.
Philipp Tomsich [Sat, 12 Nov 2022 21:44:41 +0000 (22:44 +0100)]
doc: Update Jeff Law's email-address in contrib.rst
ChangeLog:
* doc/contrib.rst: Update Jeff Law's email address.
Martin Liska [Sun, 13 Nov 2022 14:16:12 +0000 (15:16 +0100)]
sphinx: include todolist only if INCLUDE_TODO env. set
It is confusing that 'Indexes and tables' contains TODO. One gets
Index by clicking to the Index link.
PR web/107643
ChangeLog:
* doc/baseconf.py: Set include_todo tag if INCLUDE_TODO env
is set.
* doc/indices-and-tables.rst: Use include_todo tag.
Philipp Tomsich [Wed, 10 Nov 2021 16:30:20 +0000 (17:30 +0100)]
RISC-V: costs: support shift-and-add in strength-reduction
The strength-reduction implementation in expmed.cc will assess the
profitability of using shift-and-add using a RTL expression that wraps
a MULT (with a power-of-2) in a PLUS. Unless the RISC-V rtx_costs
function recognizes this as expressing a sh[123]add instruction, we
will return an inflated cost---thus defeating the optimization.
This change adds the necessary idiom recognition to provide an
accurate cost for this for of expressing sh[123]add.
Instead on expanding to
li a5,200
mulw a0,a5,a0
with this change, the expression 'a * 200' is sythesized as:
sh2add a0,a0,a0 // *5 = a + 4 * a
sh2add a0,a0,a0 // *5 = a + 4 * a
slli a0,a0,3 // *8
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_rtx_costs): Recognize shNadd,
if expressed as a plus and multiplication with a power-of-2.
Split costing for MINUS from PLUS.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/zba-shNadd-07.c: New test.
Martin Liska [Sun, 13 Nov 2022 14:07:17 +0000 (15:07 +0100)]
configure: always set SPHINX_BUILD
During the Sphinx-migration development, I used
SPHINX_BUILD='' in order to skip building info and manual
pages in gcc folder. However, we've got HAS_SPHINX_BUILD
which is the correct flag for that.
With the patch, one will get a nicer error message when
sphinx-build is missing and one builds (explicitly) a target which
depends on it.
PR other/107620
gcc/ChangeLog:
* configure: Regenerate.
* configure.ac: Always set sphinx-build.
libgomp/ChangeLog:
* configure: Regenerate.
* configure.ac: Always set sphinx-build.
libiberty/ChangeLog:
* configure: Regenerate.
* configure.ac: Always set sphinx-build.
libitm/ChangeLog:
* configure: Regenerate.
* configure.ac: Always set sphinx-build.
libquadmath/ChangeLog:
* configure: Regenerate.
* configure.ac: Always set sphinx-build.
Joseph Myers [Sun, 13 Nov 2022 12:58:49 +0000 (12:58 +0000)]
ginclude: C2x header version macros
C2x adds __STDC_VERSION_*_H__ macros to individual headers with
interface changes compared to C17. All the new header features in
headers provided by GCC have now been implemented, so define those
macros to the value given in the current working draft.
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
gcc/
* ginclude/float.h [__STDC_VERSION__ > 201710L]
(__STDC_VERSION_FLOAT_H__): New macro.
* ginclude/stdarg.h [__STDC_VERSION__ > 201710L]
(__STDC_VERSION_STDARG_H__): New macro.
* ginclude/stdatomic.h [__STDC_VERSION__ > 201710L]
(__STDC_VERSION_STDATOMIC_H__): New macro.
* ginclude/stddef.h [__STDC_VERSION__ > 201710L]
(__STDC_VERSION_STDDEF_H__): New macro.
* ginclude/stdint-gcc.h [__STDC_VERSION__ > 201710L]
(__STDC_VERSION_STDINT_H__): New macro.
* glimits.h [__STDC_VERSION__ > 201710L]
(__STDC_VERSION_LIMITS_H__): New macro.
gcc/testsuite/
* gcc.dg/c11-float-8.c, gcc.dg/c11-limits-1.c,
gcc.dg/c11-stdarg-4.c, gcc.dg/c11-stdatomic-3.c,
gcc.dg/c11-stddef-1.c, gcc.dg/c11-stdint-1.c,
gcc.dg/c2x-float-13.c, gcc.dg/c2x-limits-1.c,
gcc.dg/c2x-stdarg-5.c, gcc.dg/c2x-stdatomic-1.c,
gcc.dg/c2x-stddef-1.c, gcc.dg/c2x-stdint-1.c: New tests.
Jonathan Wakely [Fri, 28 Oct 2022 17:26:57 +0000 (18:26 +0100)]
doc: Remove outdated reference to "core" and front-end downloads
gcc/ChangeLog:
* doc/install/testing.rst: Remove anachronism about separate
source tarballs.
Jonathan Wakely [Thu, 7 Oct 2021 16:37:07 +0000 (17:37 +0100)]
libstdc++: Add C++20 clocks
Also add the basic types for timezones, without the non-inline
definitions needed to actually use them.
The get_leap_second_info function currently uses a hardcoded list of
leap seconds, correct as of the end of 2022. That needs to be replaced
with a dynamically generated list read from the system tzdata. That will
be done in a later patch.
libstdc++-v3/ChangeLog:
* include/std/chrono (utc_clock, tai_clock, gps_clock): Define.
(clock_time_conversion, clock_cast): Define.
(sys_info, local_info): Define structs for timezone information.
(nonexistent_local_time, ambiguous_local_time): Define
exceptions for invalid times.
(time_zone, time_zone_link, leap_second, zoned_traits, tzdb)
(tzdb_list): Define classes representing time zones.
(get_leap_second_info): Define new function returning leap
second offset for a given time point.
* testsuite/std/time/clock/gps/1.cc: New test.
* testsuite/std/time/clock/tai/1.cc: New test.
* testsuite/std/time/clock/utc/1.cc: New test.
Jonathan Wakely [Tue, 18 Oct 2022 20:20:06 +0000 (21:20 +0100)]
libstdc++: Implement C++20 <format> [PR104166]
This doesn't add the newer C++23 features like formatting ranges
and escaped string prsentation types.
However, C++23 extended floating-point types are supported, as are
128-bit integers.
It could do with more tests.
libstdc++-v3/ChangeLog:
PR libstdc++/104166
* include/Makefile.am (std_headers): Add <format>.
* include/Makefile.in: Regenerate.
* include/precompiled/stdc++.h: Add <format>.
* include/std/format: New file.
* python/libstdcxx/v6/printers.py (StdFormatArgsPrinter): New
printer for std::format_args.
* testsuite/std/format/arguments/args.cc: New test.
* testsuite/std/format/error.cc: New test.
* testsuite/std/format/formatter.cc: New test.
* testsuite/std/format/functions/format.cc: New test.
* testsuite/std/format/functions/format_to_n.cc: New test.
* testsuite/std/format/functions/size.cc: New test.
* testsuite/std/format/functions/vformat_to.cc: New test.
* testsuite/std/format/parse_ctx.cc: New test.
* testsuite/std/format/string.cc: New test.
* testsuite/std/format/string_neg.cc: New test.
Jonathan Wakely [Tue, 1 Nov 2022 09:48:41 +0000 (09:48 +0000)]
libstdc++: Allow std::to_chars for 128-bit integers in strict mode
This allows std::format to support __int128 when __STRICT_ANSI__ is
defined, which previously failed because __int128 is not an integral
type in strict mode.
With these changes, std::to_chars still rejects 128-bit integers in
strict mode, but std::format will be able to use __detail::__to_chars_i
for unsigned __int128.
libstdc++-v3/ChangeLog:
* include/bits/charconv.h (__integer_to_chars_is_unsigned):
New variable template.
(__to_chars_len, __to_chars_10_impl): Use variable template in
assertions to allow unsigned __int128 in strict mode.
* include/std/charconv (__to_chars, __to_chars_16)
(__to_chars_10, __to_chars_8, __to_chars_2): Likewise.
Bernhard Reutner-Fischer [Sat, 6 Nov 2021 05:51:00 +0000 (06:51 +0100)]
Fortran: Remove unused declaration
This function was removed years ago, remove it's prototype.
gcc/fortran/ChangeLog:
* gfortran.h (gfc_check_include): Remove declaration.
GCC Administrator [Sun, 13 Nov 2022 00:17:02 +0000 (00:17 +0000)]
Daily bump.
Jakub Jelinek [Sat, 12 Nov 2022 20:56:47 +0000 (21:56 +0100)]
libstdc++: Fix up to_chars ppc64le _Float128 overloads [PR107636]
As reported, I've misplaced __extension__ keywords in these cases
(wanted not to have them on the whole inlines because _Float128 is
completely standard now while __float128 is not, but before return
it is a syntax error.
I've verified on a short testcase that both g++ and clang++ accept
__extension__ after return keyword.
2022-11-12 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/107636
* include/std/charconv (to_chars): Fix up powerpc64le _Float128
overload __extension__ placement.
Harald Anlauf [Thu, 10 Nov 2022 21:30:27 +0000 (22:30 +0100)]
Fortran: fix treatment of character, value, optional dummy arguments [PR107444]
Fix handling of character dummy arguments that have the optional+value
attribute. Change name of internal symbols that carry the hidden presence
status of optional arguments to distinguish them from the internal hidden
character length. Update documentation to clarify the gfortran ABI.
gcc/fortran/ChangeLog:
PR fortran/107444
* trans-decl.cc (create_function_arglist): Extend presence status
to all intrinsic types, and change prefix of internal symbol to '.'.
* trans-expr.cc (gfc_conv_expr_present): Align to changes in
create_function_arglist.
(gfc_conv_procedure_call): Fix generation of procedure arguments for
the case of character dummy arguments with optional+value attribute.
* trans-types.cc (gfc_get_function_type): Synchronize with changes
to create_function_arglist.
* doc/gfortran/naming-and-argument-passing-conventions.rst: Clarify
the gfortran argument passing conventions with regard to OPTIONAL
dummy arguments of intrinsic type.
gcc/testsuite/ChangeLog:
PR fortran/107444
* gfortran.dg/optional_absent_7.f90: Adjust regex.
* gfortran.dg/optional_absent_8.f90: New test.
Joseph Myers [Sat, 12 Nov 2022 17:03:21 +0000 (17:03 +0000)]
c: C2x constexpr
Implement C2x constexpr (a feature based on the C++ one but much more
minimal, with only constexpr variables, not functions).
I believe this implementation is fully functional for use of this
feature. However, there are several things that seem unclear about
the specification that I'll need to raise in NB comments. There are
also areas where there may be followup bug fixes because the
implementation doesn't reject some more obscure cases that ought to be
rejected: cases where a constexpr initializer for floating type meets
the constraints for a constant expression in initializers but not
those for an arithmetic constant expression (previously we haven't had
to track whether something is an arithmetic constant expression in
detail, unlike with integer constant expressions), and some cases
where a tag or struct or union member gets declared indirectly in the
declaration specifiers or declarator of a constexpr declaration, which
is not permitted (modulo lack of clarity in the specification) for
underspecified declarations in general (the cases of a declaration in
the initializer, or a tagged type being directly declared as a type
specifier, are already detected).
Cases of ambiguity in the specification include:
* Many questions (previously raised in WG14 discussions) over the rule
about what conversions do or do not involve a change of value that's
not allowed in a constexpr initializer, that aren't properly
addressed by the normative text (and where the footnote on the
subject isn't very clear either, and the examples don't necessarily
follow from the normative text). I've made a series of choices
there, that include disallowing all conversions between real and
complex types or between binary and decimal floating types in
constexpr initializers, that might not necessarily agree with how
things end up getting clarified.
The dfp.cc change also arises here, to allow quiet NaN initializers
of one DFP type to be used in a constexpr initializer for another
DFP type (as is possible for signaling NaNs) by ensuring the result
of such a conversion is properly marked as canonical (note that most
of the DFP code doesn't actually do anything with NaN payloads at
all).
* Various issues with what exactly counts as part of a declaration for
the purposes of the rule on underspecified declarations not
declaring any identifiers other than ordinary identifiers (and not
declaring more than one ordinary identifier, though the latter is
undefined behavior). These include cases where the declaration of a
struct / union / enum type appears inside typeof or alignas in the
declaration specifiers (the latter also applies with auto), or in
the declarator (e.g. an array size or in a parameter declaration).
The issues are similar to those involved in C90 DR#115 and C99 DRs
#277 and #341; the intent may not be the same in all the different
cases involved, but it's not clear that the normative wording in the
various places is sufficient to deduce the differences in intent.
* The wording about producing a compound literal constant using member
access is present in one place but another place only applies that
to named constants.
* It's not clear when a structure or union constant (a constexpr
variable or compound literal with structure or union type, or a
member with such type extracted by a series of member access
operations) can itself be used in an initializer (constexpr or
otherwise). Based on general wording for initializers not having
been changed, the working draft might only strictly allow it at
automatic storage duration (but elsewhere it would be undefined
behavior, not a constraint violation, so no diagnostic required) -
since that's the only case mentioned where a single expression of
structure or union type can be used to initialize an object of such
a type. But it definitely seems to be allowed in even constexpr
initializers at automatic storage duration - and since generally
constexpr initializers (any storage duration) are *more* constrained
than ordinary static storage duration initializers, it would seem
odd for it not to be allowed at static storage duration.
* When you do allow such initializers, it's then not entirely clear
how the constraint that constexpr pointer initializers must be null
pointer constants should be applied (given that a constexpr object
of pointer type is a null pointer but *not* a null pointer
constant). My guess would be that a constexpr struct or union
containing such a field should still be allowed as an initializer,
but the wording could be read otherwise.
* It also becomes important with constexpr exactly what kind of
constant expression an implicit zero initializer is; the wording for
default initialization only really deals with the value of the
initializer and not what kind of constant it is. In particular,
this affects whether {} is a valid constexpr initializer for a
pointer not of type void *, since the wording only talks about a
null pointer, not whether it's a null pointer *constant*. I assumed
that it should be a null pointer constant in that case.
* It's also not entirely clear whether constexpr can be used in the
declaration part of a for loop (which "shall only declare
identifiers for objects having storage class auto or register"). I
interpreted it as allowed (treating such objects as implicitly auto
just like those with no storage class specifiers), but it could also
be argued that constexpr is another storage class specifier and so
not allowed there.
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
gcc/
* dfp.cc (decimal_from_binary): Convert a canonical NaN to a
canonical NaN.
gcc/c-family/
* c-common.cc (c_common_reswords): Use D_C2X instead of D_CXXONLY.
gcc/c/
* c-decl.cc (start_underspecified_init)
(finish_underspecified_init): Handle name == NULL_TREE for
compound literals.
(merge_decls): Merge C_DECL_DECLARED_CONSTEXPR.
(shadow_tag_warned): Check for constexpr.
(start_decl): Add parameter do_push.
(build_compound_literal): Set C_DECL_DECLARED_CONSTEXPR.
(grokdeclarator): Handle constexpr.
(finish_struct): Set C_TYPE_FIELDS_NON_CONSTEXPR.
(declspecs_add_scspec): Handle constexpr.
* c-parser.cc (c_token_starts_compound_literal)
(c_token_starts_declspecs, c_parser_declaration_or_fndef)
(c_parser_declspecs, c_parser_gnu_attribute_any_word)
(c_parser_compound_literal_scspecs)
(c_parser_postfix_expression_after_paren_type): Handle constexpr.
Update calls to start_init.
(c_parser_declaration_or_fndef, c_parser_initializer)
(c_parser_initval): Pass true for new argument of
convert_lvalue_to_rvalue. Call convert_lvalue_to_rvalue for
constexpr compound literals.
(c_parser_static_assert_declaration_no_semi)
(c_parser_enum_specifier, c_parser_struct_declaration)
(c_parser_alignas_specifier, c_parser_initelt, c_parser_label):
Call convert_lvalue_to_rvalue on expressions required to be
integer constant expressions.
(c_parser_omp_declare_reduction): Update call to start_init.
* c-tree.h (C_TYPE_FIELDS_NON_CONSTEXPR)
(C_DECL_DECLARED_CONSTEXPR): New macros.
(struct c_declspecs): Add constexpr_p.
(start_decl, convert_lvalue_to_rvalue, start_init): Update
prototypes.
* c-typeck.cc (require_constant_value, require_constant_elements):
Change to bool.
(require_constexpr_value, maybe_get_constexpr_init)
(constexpr_init_fits_real_type, check_constexpr_init): New.
(convert_lvalue_to_rvalue): Add new parameter for_init. Call
maybe_get_constexpr_init.
(store_init_value): Update call to digest_init.
(digest_init): Add parameters int_const_expr, arith_const_expr and
require_constexpr. Check constexpr initializers.
(constructor_top_level): Remove.
(struct initializer_stack): Remove top_level. Add
require_constexpr_value.
(start_init): Remove parameter top_level. Add parameters
init_require_constant and init_require_constexpr. Save
require_constexpr_value on stack.
(pop_init_level): Use a null pointer constant for zero initializer
of pointer initialized with {}.
(output_init_element): Update call to digest_init. Avoid passing
null pointer constants of pointer type through digest_init a
second time when initializing a constexpr object.
gcc/testsuite/
* gcc.dg/c11-keywords-1.c: Also test constexpr.
* gcc.dg/c2x-constexpr-1.c, gcc.dg/c2x-constexpr-2a.c,
gcc.dg/c2x-constexpr-2b.c, gcc.dg/c2x-constexpr-3.c,
gcc.dg/c2x-constexpr-4.c, gcc.dg/c2x-constexpr-5.c,
gcc.dg/c2x-constexpr-6.c, gcc.dg/c2x-constexpr-7.c,
gcc.dg/c2x-constexpr-8.c, gcc.dg/c2x-constexpr-9.c,
gcc.dg/dfp/c2x-constexpr-dfp-1.c,
gcc.dg/dfp/c2x-constexpr-dfp-2.c, gcc.dg/gnu2x-constexpr-1.c,
gcc.target/i386/excess-precision-11.c,
gcc.target/i386/excess-precision-12.c: New tests.
Aldy Hernandez [Sat, 12 Nov 2022 10:27:49 +0000 (11:27 +0100)]
[frange] Avoid testing signed zero test for -fno-signed-zeros.
This patch moves a test that is meant to only work for signed zeros
into range_tests_signed_zeros.
I am not aware of any architectures where this is failing, but it is
annoying to see selftests failing when -fno-signed-zeros is used.
gcc/ChangeLog:
* value-range.cc (range_tests_signbit): Move to set from here...
(range_tests_signed_zeros): ...to here.
Aldy Hernandez [Fri, 11 Nov 2022 17:46:01 +0000 (18:46 +0100)]
[range-ops] Add ability to represent open intervals in frange.
Currently we represent < and > with a closed interval. So < 3.0 is
represented as [-INF, +3.0]. This means 3.0 is included in the range,
and though not ideal, is conservatively correct. Jakub has found a
couple cases where properly representing < and > would help
optimizations and tests, and this patch allows representing open
intervals with real_nextafter.
There are a few caveats.
First, we leave MODE_COMPOSITE_P types pessimistically as a closed interval.
Second, for -ffinite-math-only, real_nextafter will saturate the
maximum representable number into +INF. However, this will still do
the right thing, as frange::set() will crop things appropriately.
Finally, and most frustratingly, representing < and > -+0.0 is
problematic because we flush denormals to zero. Let me explain...
real_nextafter(+0.0, +INF) gives 0x0.8p-148 as expected, but setting a
range to this value yields [+0.0, 0x0.8p-148] because of the flushing.
On the other hand, real_nextafter(+0.0, -INF) (surprisingly) gives
-0.0.8p-148, but setting a range to that value yields [-0.0x8p-148,
-0.0]. I say surprising, because according to cppreference.com,
std::nextafter(+0.0, -INF) should give -0.0. But that's neither here
nor there because our flushing denormals to zero prevents us from even
representing ranges involving small values around 0.0. We ultimately
end up with ranges looking like this:
> +0.0 => [+0.0, INF]
> -0.0 => [+0.0, INF]
< +0.0 => [-INF, -0.0]
< -0.0 => [-INF, -0.0]
I suppose this is no worse off that what we had before with closed
intervals. One could even argue that we're better because we at least
have the right sign now ;-).
gcc/ChangeLog:
* range-op-float.cc (build_lt): Adjust with frange_nextafter
instead of default to a closed range.
(build_gt): Same.
Jakub Jelinek [Sat, 12 Nov 2022 08:47:50 +0000 (09:47 +0100)]
libgomp: Fix up build on mingw [PR107641]
Pointers should be first casted to intptr_t/uintptr_t before casting
them to another integral type to avoid warnings.
Furthermore, the function has code like
else if (upper <= UINT_MAX)
something;
else
something_else;
so it seems using unsigned type for upper where upper <= UINT_MAX is always
true is not intended.
2022-11-12 Jakub Jelinek <jakub@redhat.com>
PR libgomp/107641
* env.c (parse_unsigned_long): Cast params[2] to uintptr_t rather than
unsigned long. Change type of upper from unsigned to unsigned long.