This should have been part of r15-5367. One day I'll remember to do this
before buildbot sends me hate mail.
gcc/c-family/ChangeLog:
* c.opt.urls: Regenerate.
In C23, bool is now a keyword. So, doing a typedef for it is invalid.
2024-11-17 John David Anglin <danglin@gcc.gnu.org>
libgcc/ChangeLog:
PR target/117627
* config/pa/linux-atomic.c: Remove typedef for bool type.
This warning covers the C23 incompibilities resulting from using
() as parameter lists in function declarations.
The warning name comes from Clang. The implementation is not
perfect because GCC treats these two declarations as equivalent:
void f ();
void f (not_a_type);
This is a bit confusing because they are clearly visually distinct.
However, as of GCC 14, the second form is an error by default, so
treating both the same as far as -Wdeprecated-non-prototype does
not seem so bad from a user experience view.
gcc/c-family/
PR c/95445
* c-opts.cc (c_common_post_options): Initialize
warn_deprecated_non_prototype.
* c.opt (Wdeprecated-non-prototype): New option.
* c.opt.urls: Regenerate.
gcc/c/
PR c/95445
* c-decl.cc (start_function): Warn about parameters
after parameter-less declaration.
* c-typeck.cc (build_function_call_vec): Pass fntype
to convert_arguments.
(convert_arguments): Change argument to fntype and
compute typelist. Warn about parameter list mismatches
on first parameter.
gcc/
PR c/95445
* doc/invoke.texi: Document -Wdeprecated-non-prototype.
gcc/testsuite/
PR c/95445
* gcc.dg/Wdeprecated-non-prototype-1.c: New test.
* gcc.dg/Wdeprecated-non-prototype-2.c: New test.
* gcc.dg/Wdeprecated-non-prototype-3.c: New test.
* gcc.dg/Wdeprecated-non-prototype-4.c: New test.
While experimenting with testing module std I noticed that gcc -M broke on
it; it seems I need to set directives_only even sooner than I did in
r15-4219.
gcc/c-family/ChangeLog:
* c-ppoutput.cc (preprocess_file): Don't set directives_only here.
gcc/cp/ChangeLog:
* module.cc (module_preprocess_options): Set directives_only here.
The C++ modules code has a -fmodule-header (or -x c++-{user,system}-header)
option to specify looking up headers to compile to header units on the usual
include paths. I'd like to have the same functionality for full C++20
modules such as module std, which I proposed to live on the include path at
bits/std.cc. But this behavior doesn't seem necessarily connected to
modules, so I'm proposing a general C/C++ option to specify the behavior of
looking in the include path for the input files specified on the command
line.
Other ideas for the name of the option are very welcome.
The libcpp change is to allow -fsearch-include-path{,=user} to find files in
the current working directory, like -include. This can be handy for a quick
compile of both std.cc and a file that imports it, e.g.
g++ -std=c++20 -fmodules -fsearch-include-path bits/std.cc importer.cc
gcc/ChangeLog:
* doc/cppopts.texi: Document -fsearch-include-path.
* doc/invoke.texi: Mention it for modules.
gcc/c-family/ChangeLog:
* c.opt: Add -fsearch-include-path.
* c-opts.cc (c_common_post_options): Handle it.
gcc/cp/ChangeLog:
* module.cc (module_preprocess_options): Don't override it.
libcpp/ChangeLog:
* internal.h (search_path_head): Declare.
* files.cc (search_path_head): No longer static.
* init.cc (cpp_read_main_file): Use it.
This patch introduces an installed source form of module std and std.compat.
To help a build system find them, we install a libstdc++.modules.json file
alongside libstdc++.so, which tells the build system where the files are and
any special flags it should use when compiling them (none, in this case).
The format is from a proposal in SG15. The build system can find this file
with 'gcc -print-file-name=libstdc++.modules.json'.
It seems preferable to use a relative path from this file to the sources so
that moving the installation doesn't break the reference, but I didn't see
any obvious way to compute that without relying on coreutils, perl, or
python, so I wrote a POSIX shell script for it. The .. canonicalization
bits aren't necessary since I discovered $(abspath), but I guess I might as
well leave them in.
Currently this installs the sources under $(gxx_include_dir)/bits/,
i.e. /usr/include/c++/15/bits. So with my -fsearch-include-path change,
std.cc can be compiled with g++ -fsearch-include-path bits/std.cc. Note
that if someone actually tries to #include <bits/std.cc> it will fail with
"error: module control-line cannot be in included file".
Any ideas about a more user-friendly way to express "compile module std" are
welcome.
The sources currently have the extension .cc, like other source files.
std.cc started with m.cencora's implementation in PR114600. I've made some
adjustments, but more is probably desirable, e.g. of the <algorithm>
handling of namespace ranges, and to remove exports of templates that are
only specialized in a particular header. I've filled in a bunch of missing
exports, and added some FIXMEs where I noticed bits that are not implemented
yet.
Since bits/stdc++.h also intends to include the whole standard library, I
include it rather than duplicate it. But stdc++.h comments out <execution>,
due to TBB issues; I include it separately and suppress TBB usage, so module
std won't currently provide parallel execution.
It seemed most convenient for the two files to be monolithic so we don't
need to worry about include paths. So the C library names that module
std.compat exports in both namespace std and :: are a block of code that is
appended to both files, adjusted based on whether the macro STD_COMPAT is
defined before the block.
In this implementation std.compat imports std; it would also be valid for it
to duplicate everything in std. I see the libc++ std.compat also imports
std.
As discussed in the PR, module std is supported in C++20 mode even though it
was added in C++23.
Changes to test module std will follow in a separate patch. In my testing
I've noticed a few compiler bugs that break various testcases, so I don't
expect to enable module std testing by default at first.
PR libstdc++/106852
libstdc++-v3/ChangeLog:
* include/bits/version.def: Add __cpp_lib_modules.
* include/bits/version.h: Regenerate.
* src/c++23/Makefile.am: Add modules std and std.compat.
* src/c++23/Makefile.in: Regenerate.
* src/c++23/std-clib.cc.in: New file.
* src/c++23/std.cc.in: New file.
* src/c++23/std.compat.cc.in: New file.
* src/c++23/libstdc++.modules.json.in: New file.
contrib/ChangeLog:
* relpath.sh: New file.
I forgot to mark asm statements as necessary in ipa-fnsummary. This should
mask failure of gcc.dg/guality/pr36728-2.c where the patch enabled
cloning which breaks debug info.
gcc/ChangeLog:
* ipa-fnsummary.cc (find_necessary_statements): ASM statements are
necessary.
C attributes reproducible and unsequenced implies that calling function twice
leads to same effect if parameters are otherwise unchanged (function call
itself does not count). This is bit bit stronger that modref's notion of
nondeterminism that says that same inputs will yield same outputs (function
call itself does count).
This patch makes reproducible/unsequenced imply determinism and cleans up
determinism handling. By itself it is not useful, since we can not make use of it
unless we know what are the inputs/outputs of the function which I plan to handle
by the "fn spec" attribute.
gcc/ChangeLog:
* ipa-modref.cc (modref_summary::useful_p): const/pure implies
determinism.
(modref_summary_lto::useful_p): Likewise.
(ignore_nondeterminism_p): Add CALLEE_FNTYPE parameter; check for
reproducible/unsequenced
(modref_access_analysis::record_access_p): Use ignore_nondeterminism_p
when handling volatile accesses.
(modref_access_analysis::get_access_for_fnspec): Update.
(modref_access_analysis::process_fnspec): Cleanup handling of NOVOPS.
(modref_access_analysis::analyze_call): Use ignore_nondeterminism_p
when handling asm statements.
(modref_access_analysis::analyze_stmt): Update.
(propagate_unknown_call): Update.
(modref_propagate_in_scc): Update.
(ipa_merge_modref_summary_after_inlining): Update.
This patch makes it clear that vector sizes and capacities are not
negative. With recent change to ipa-fnsummary this should not affect
inlining and improves codegen of some vector manipulation functions.
I tested clang build. Looking for throw_bad calls there are only 3
called considerably often (bad_allloc, bad_array_new_length and
function_callv).
The patch seems to reduce bad_alloc and bad_array_new_length calls
considerably:
bad_alloc 380->147
bad_array_new_length 832->128
libstdc++-v3/ChangeLog:
PR tree-optimization/109442
* include/bits/stl_vector.h: (vector::size(),
vector::capacity()): Add __builtin_unreachable call to announce
that size and capacity are non-negative.
gcc/testsuite/ChangeLog:
PR tree-optimization/109442
* g++.dg/tree-ssa/pr109442.C: New test.
while working on -fmalloc-dce I noticed that tree-ssa-dce.cc still has an
outdated list of builtions that are known to not read memory that can be
replaced by query to fnspec and modref.
If I get things right, dce does some dead store removal, but only on those
memory object that are non-aliased (automatic variabels with no address taken)
and for all other memory addresses it resorts to
mark_all_reaching_defs_necessary expecting DSE to do the rest. So we really
want to only check if there are no memory reads at all rather then trying to
understand them by parsing fnspec or modref summary.
I did run testsuite ensuring that all builtins matched previously are
still matched. There are few testcases where this check fails, due to
type incompatibility. New code uses gimple_call_builtin while other
just checked callee_decl.
We test things like calling free() without parmeter which I don't think
we want to care about, but there is also testase declaring
void * calloc (long, long)
where builtin declaration expects unsigned long. I am not sure if this
case should not be allowed by gimple_call_builtin?
Bootstrappe/regtested x86_64-linux. OK?
gcc/ChangeLog:
* ipa-modref.cc (ipa_modref_callee_reads_no_memory_p): New function.
* ipa-modref.h (ipa_modref_callee_reads_no_memory_p): Declare
* tree-ssa-dce.cc (propagate_necessity): Use it.
gcc/cp/ChangeLog:
* decl.cc (cxx_build_operator_new): Break out from ...
(cxx_build_operator_delete): Break out from ...
(cxx_init_operator_new_delete_decls): Break out from ...
(cxx_init_decl_processing): ... here.
Since r15-5327, GNU-C23 is being used as C language default.
libf7.h doesn't assume headers like stdbool.h are present
and defines bool, true and false on its own.
libgcc/config/avr/libf7/
* libf7.h (bool, true, false): Don't define in C23 or higher.
For unsigned types, you can optimize `max<a,b> == 0` into
`(a|b) == 0` (that is both have to be zero). A similar thing happens for `!= 0`.
This optimization fixes the missed optimization (g++.dg/tree-ssa/pr115275.C)
that was reported exposed by adding phiprop early.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/115275
gcc/ChangeLog:
* match.pd (umax(a,b) ==/!= 0): New pattern.
gcc/testsuite/ChangeLog:
* g++.dg/tree-ssa/pr115275.C: New test.
* gcc.dg/tree-ssa/max_eqne-1.c: New test.
* gcc.dg/tree-ssa/max_eqne-2.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
This patch simplify `min(a,b) op max(a,b)` to `a op b`. This optimization
will work for all the binary commutative operations. So, the `op` here can
be one of {plus, mult, bit_and, bit_xor, bit_ior, eq, ne, min, max}.
PR tree-optimization/109401
gcc/ChangeLog:
* match.pd (min(a,b) op max(a,b) -> a op b): New pattern.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr109401.c: New test.
* gcc.dg/tree-ssa/pr109401-1.c: New test.
Signed-off-by: Eikansh Gupta <quic_eikagupt@quicinc.com>
Some of the function definitions used K&R style definitions (but not all).
This just moves them all to be ANSI C
Bootstrapped and tested on x86_64-linux-gnu.
libiberty/ChangeLog:
* testsuite/test-demangle.c (get_line): Change K&R style
definition into ANSI C90 definitions.
(fail): Likewise.
(main): Likewise.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
This patch avoids (clobber (match_dup)) in insn patterns for tablejump.
The machine description now uses a scratch_operand instead which is
possible since the clobbered entity is known in advance:
3-byte PC : REG_Z
2-byte PC + JMP : REG_Z
2-byte PC + RJMP : None, hence scratch:HI is used.
The avr-casesi pass and optimization has to be adjusted to the new patterns.
PR target/116781
gcc/
* config/avr/avr.md (*tablejump_split, *tablejump): Add
operand 2 as a "scratch_operand" instead of a match_dup.
(casesi): Adjust expander operands accordingly. Use a scratch:HI
when the jump address is not clobbered. This is the case for a
2-byte PC + has no JMP instruction. In all the other cases, the
affected operand is REG_Z (reg:HI 30).
(casesi_<mode>_sequence): Adjust matcher to new anatomy.
* config/avr/avr-passes.cc (avr_is_casesi_sequence)
(avr_is_casesi_sequence, avr_optimize_casesi)
(avr_casei_sequence_check_operands): Adjust to new anatomy.
For operations like X o= CST, regalloc may spill l-reg X to a d-reg:
D = X
D o= CST
X = D
where it is better to instead
D = CST
X o= D
This patch adds an according RTL peephole.
gcc/
* config/avr/avr.md: Add a peephole2 that improves bit operations
with a lower register and a constant.
This test passes different kinds of objects to the underlying function. So
just pass in -std=gnu17.
gcc/testsuite
* gcc.target/arc/add_n-combine.c: Pass in -std=gnu17.
Since the switch to -std=gnu23 by default, float.h (included from
tsystem.h) defines INFINITY macro (to __builtin_inff ()), which now
results in a warning when compiling libgcc2.c which defines it
to something else (and, worse aarch64 compiles it with -Werror and
build fails).
libgcc2.c asserts INFINITY has the expected type which depends on
the macros with which libgcc2.c is being compiled, so guarding
the define with #ifndef INFINITY wouldn't work.
So this patch instead #undefs the macro before defining it.
2024-11-16 Jakub Jelinek <jakub@redhat.com>
PR libgcc/117624
* libgcc2.c (INFINITY): Add #undef before #define.
2024-11-16 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/109066
* resolve.cc (generate_component_assignments): If the temporary
for 'var' is a pointer and 'expr' is neither a constant or
a variable, change its attribute from pointer to allocatable.
This avoids assignment to a temporary point that has neither
been allocated or associated.
gcc/testsuite/
PR fortran/109066
* gfortran.dg/defined_assignment_12.f90: New test.
A HP/UX linker patch from the GCC 3.3 era and Binutils 2.14
no longer should require special mention.
These originally came in via commit c512449722 in April 2004 as
* doc/install.texi: Update HP-UX 11 installation procedure.
gcc:
PR target/69374
* doc/install.texi (Specific) <hppa*-hp-hpux11>: Remove references
to HP/UX linker patch from 2004 and Binutils 2.14.
A few SH tests want to create a bool typedef which doesn't work for c23.
Easiest fix which should have no impact on the test behavior would be to just
change the name of the typedef so that doesn't conflict.
One test has a crazy function signature (similar to the PRU test someone just
fixed up). For that I'm using -std=gnu17.
Pushing to the trunk.
testsuite/
* gcc.target/sh/pr51244-15.c: Use "mybool" rather than "bool".
* gcc.target/sh/pr52933-1.c: Similarly.
* gcc.target/sh/pr54089-1.c: Similarly.
* gcc.target/sh/pr54089-7.c: Similarly.
* gcc.target/sh/pr54089-8.c: Similarly.
* gcc.target/sh/pr54089-9.c: Similarly.
* gcc.target/sh/pr64366.c: Use -std=gnu17.
testglue.c (which is used for exit/abort wrappers in the testsuite) isn't c23
compatible. The testing harness tries to build testglue.c and use it, but
doesn't report a failure if the build fails, instead it's just not used. As a
result we get all kinds of failures on targets which depend on testglue to
report back simulator status -- like tens of thousands of execution failures.
This patch just adds -std=gnu17 to the command line to build testglue.c.
There's other fallout from the c23 change.. My tester is chewing through
things right now...
Installing on the trunk.
testsuite
* lib/wrapper.exp (${tool}_maybe_build_wrapper): Pass -std=gnu17 flag
to build testglue wrapper.
Provide function declaration in order to fix the test case build with
the new -std=gnu23 default.
gcc/testsuite/ChangeLog:
* gcc.target/pru/pr64366.c (foobar): Provide full function
delaration.
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
The following flips the vectorizer to forced SLP, there is almost
no expected fallout at this point, the remains should be target
specific cost modeling issues.
* params.opt (vect-force-slp): Default to 1.
The following tries to reduce the amount of difference between
SLP and non-SLP for single-element interleaving load classification.
This fixes another fallout of --param vect-force-slp=1
PR tree-optimization/117606
* tree-vect-stmts.cc (get_group_load_store_type): For single
element interleaving also fall back to VMAT_ELEMENTWISE if
a left-over permutation isn't supported.
We fail to demote this to VMAT_ELEMENTWISE and thus run into the three
vector permutation limit (and would not consider to use strided loads
or gathers).
This resolves another bunch of SVE regressions with --param
vect-force-slp=1
PR tree-optimization/117605
* tree-vect-stmts.cc (get_group_load_store_type): Also
apply group size limit for single-element interleaving
to VMAT_CONTIGUOUS_REVERSE.
The following ensures that peeling a single iteration for gaps is
sufficient by enforcing niter masking (partial vector use) given
we cannot (always) statically decide when the vector size isn't known.
The condition guarding this and thus statically giving a pass in
some cases for VL vectors is questionable, the patch doesn't address
this.
This fixes a set of known failout from enabling
--param vect-force-slp=1 by default.
PR tree-optimization/117558
* tree-vectorizer.h (_loop_vec_info::must_use_partial_vectors_p): New.
(LOOP_VINFO_MUST_USE_PARTIAL_VECTORS_P): Likewise.
* tree-vect-loop.cc (_loop_vec_info::_loop_vec_info): Initialize
must_use_partial_vectors_p.
(vect_determine_partial_vectors_and_peeling): Enforce it.
(vect_analyze_loop_2): Reset before restarting.
* tree-vect-stmts.cc (get_group_load_store_type): When peeling
a single gap iteration cannot be determined safe statically
enforce the use of partial vectors.
This extends my last year attempt to make inliner metric ignore
conditionals guarding __builtin_unreachable. Compared to previous
patch, this one implements a "mini-dce" in ipa-fnsummary to avoid
accounting all statements that are only used to determine conditionals
guarding __builtin_unnecesary. These will be removed later once value
ranges are determined.
While working on this, I noticed that we do have a lot of dead code while
computing fnsummary for early inline. Those are only used to apply
large-function growth, but it seems there is enough dead code to make this
valud kind of irrelevant. Also there seems to be quite a lot of const/pure
calls that can be cheaply removed before we inline them. So I wonder if we
want to run one DCE before early inlining.
gcc/ChangeLog:
PR tree-optimization/109442
* ipa-fnsummary.cc (builtin_unreachable_bb_p): New function.
(guards_builtin_unreachable): New function.
(STMT_NECESSARY): New macro.
(mark_stmt_necessary): New function.
(mark_operand_necessary): New function.
(find_necessary_statements): New function.
(analyze_function_body): Use it.
gcc/testsuite/ChangeLog:
* gcc.dg/ipa/fnsummary-1.c: New test.
We aren't enabling modules by default yet, but let's fix these tests now so
they won't fail when that happens.
gcc/testsuite/ChangeLog:
* g++.dg/template/error25.C: Adjust export diagnostic.
* g++.old-deja/g++.benjamin/tem05.C: Likewise.
* g++.old-deja/g++.pt/export1.C: Likewise.
* g++.dg/pch/pch.exp: Specify -fno-modules.
When forming the composite type from two tagged type, we need to find the
original type for a typedecl to get the correct tag.
PR c/117548
gcc/c/ChangeLog:
* c-decl.cc (finish_struct): Add checking assertion.
* c-typeck.cc (c_type_original): New function.
(composite_types_internal): Get tag from original type.
gcc/testsuite/ChangeLog:
* gcc.dg/pr117548.c: New test.
r15-5327-g55e3bd376b2214 changes the default to -std=gnu23 but this
test relies on unprototyped functions. Follow Joseph's advice
in that commit and tweak the test accordingly.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr66891.c: Pass -std=gnu17.
r15-5327-g55e3bd376b2214 changes the default to -std=gnu23 but these
tests now trigger -Wold-style-definition. Follow Joseph's advice
in that commit and tweak the tests accordingly.
gcc/testsuite/ChangeLog:
* gcc.dg/graphite/id-15.c: Pass -Wno-old-style-definition.
* gcc.dg/graphite/pr38413.c: Ditto.
* gcc.dg/graphite/pr38510.c: Ditto.
This patch adds missing return statements after a call to RAISE. Four
of the modules in libgm2 have procedure functions with missing return
statements. These errors were exposed after the reimplementation of
parameter declaration patch and triggered by -Wreturn-type. The patch
also adds exit statements to the M2RTS noreturn functions.
gcc/m2/ChangeLog:
PR modula2/117555
* gm2-libs-iso/EXCEPTIONS.mod (CurrentNumber): Add return
statement.
* gm2-libs-iso/IOChan.mod (ReadResult): Ditto.
(CurrentFlags): Ditto.
(DeviceError): Ditto.
* gm2-libs-iso/IOLink.mod (DeviceTablePtrValue): Ditto.
* gm2-libs-iso/LongConv.mod (ValueReal): Ditto.
* gm2-libs/M2RTS.mod (Halt): Add noreturn attribute.
Add exit (1).
(HaltC): Add exit (1).
* pge-boot/GM2RTS.cc (M2RTS_Halt): Add exit (1).
(M2RTS_HaltC): Ditto.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Change the default language version for C compilation from -std=gnu17
to -std=gnu23. A few tests are updated to remove local definitions of
bool, true and false (where making such an unconditional test change
seemed to make more sense than changing the test conditionally earlier
or building it with -std=gnu17); most test issues were already
addressed in previous patches. In the case of
ctf-function-pointers-2.c, it was agreed in bug 117289 that it would
be OK to put -std=gnu17 in the test and leave more optimal BTF / CTF
output for this test as a potential future improvement.
Since the original test fixes, more such fixes have become necessary
and so are included in this patch. More noinline attributes are added
to simulate-thread tests where () meaning a prototype affected test
results, while gcc.dg/torture/pr117496-1.c (a test declaring a
function with () then calling it with arguments) gets -std=gnu17
added.
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
NOTE: it's likely there are target-specific tests for non-x86 targets
that need updating as a result of this change. See commit
9fb5348e30 ("testsuite: Prepare for
-std=gnu23 default") for examples of changes to prepare the testsuite
to work with a -std=gnu23 default. In most cases, adding
-Wno-old-style-definition (for warnings for old-style function
definitions) or -std=gnu17 (for other issues such as unprototyped
function declarations with ()) is appropriate, but watch out for cases
that indicate bugs with -std=gnu23 (in particular, any ICEs - there
was only the one nested function test where I had to fix an ICE on
x86_64).
gcc/
* doc/invoke.texi (-std=gnu17, -std=gnu23): Document -std=gnu23 as
default for C code.
gcc/c-family/
* c-opts.cc (c_common_init_options): Default to C23.
gcc/testsuite/
* c-c++-common/analyzer/asm-x86-dyndbg-2.c,
c-c++-common/analyzer/asm-x86-lp64-2.c,
c-c++-common/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c,
c-c++-common/analyzer/coreutils-cksum-pr108664.c,
c-c++-common/analyzer/feasibility-3.c,
c-c++-common/analyzer/pr105783.c, c-c++-common/analyzer/sock-1.c,
c-c++-common/attributes-4.c, gcc.dg/Warray-bounds-78.c,
gcc.dg/analyzer/asm-x86-dyndbg-1.c: Do not define bool, true or
false.
* gcc.dg/debug/ctf/ctf-function-pointers-2.c: Use -std-gnu17.
* gcc.dg/gnu23-version-2.c: New test.
* gcc.dg/simulate-thread/atomic-load-int.c,
gcc.dg/simulate-thread/atomic-load-longlong.c,
gcc.dg/simulate-thread/atomic-load-short.c: Add more noinline
attributes.
* gcc.dg/torture/pr117496-1.c: Use -std=gnu17.
This patch enforces a const expression increment in a FOR loop.
It also fixes missing error locations. The FOR loop last iterator
value is now calculated during M2GenGCC after all types and constants have
been resolved. This results in fewer quadruples (as there is no need to
build two paths for step > 0 and step < 0).
gcc/m2/ChangeLog:
PR modula2/117371
* gm2-compiler/M2Base.mod (MixMetaTypes): Add parameter TRUE to
MetaErrorDecl.
(IsUserType): Test against ZType.
(MixTypesDecl): Test for ZType.
* gm2-compiler/M2GenGCC.mod (ErrorMessageDecl): Add parameter TRUE to
MetaErrorDecl.
(CodeLastForIterator): New procedure.
(FoldLastForIterator): Ditto.
(PerformLastForIterator): Ditto.
(CodeStatement): Add case clause for LastForIteratorOp.
(ErrorMessageDecl): Add iserror parameter.
Call MetaErrorDecl with iserror parameter.
(checkIncorrectMeta): Call MetaErrorDecl with TRUE parameter.
(CheckBinaryExpressionTypes): Ditto.
(CheckElementSetTypes): Ditto.
* gm2-compiler/M2LexBuf.def (MakeVirtualTok): Update comment
detailing the fall back when UnknownTokenNo is encountered.
(MakeVirtual2Tok): Ditto.
* gm2-compiler/M2LexBuf.mod (MakeVirtualTok): Check against
UnknownTokenNo.
(MakeVirtual2Tok): Ditto.
* gm2-compiler/M2MetaError.def (MetaErrorDecl): Add error parameter.
* gm2-compiler/M2MetaError.mod (MetaErrorDecl): Add error
parameter.
Issue warning if error is FALSE.
* gm2-compiler/M2Quads.def (QuadOperator): Add LastForIteratorOp.
* gm2-compiler/M2Quads.mod (AddQuadInformation): New case clause
LastForIteratorOp.
(CheckAddTuple2Read): New procedure.
(BuildForLoopToRangeCheck): Remove.
(ForLoopLastIteratorVariable): Ditto.
(ForLoopLastIteratorConstant): Ditto.
(ForLoopLastIterator): Reimplement.
(BuildForToByDo): Remove ByType from call to ForLoopLastIterator.
(WriteQuad): New case clause LastForIteratorOp.
(WriteOperator): Ditto.
* gm2-compiler/M2Students.def
(CheckForVariableThatLooksLikeKeyword): Replace with ...
(CheckVariableAgainstKeyword): ... this.
* gm2-compiler/M2Students.mod
(CheckForVariableThatLooksLikeKeyword): Replace with ...
(CheckVariableAgainstKeyword): ... this.
* gm2-compiler/M2SymInit.mod (CheckLastForIterator): New
procedure.
(CheckReadBeforeInitQuad): New case clause to call
CheckLastForIterator.
* gm2-compiler/P2SymBuild.mod: Replace
CheckForVariableThatLooksLikeKeyword with CheckVariableAgainstKeyword.
gcc/testsuite/ChangeLog:
PR modula2/117371
* gm2/iso/fail/forloopbyvar.mod: New test.
* gm2/iso/fail/forloopbyvar4.mod: New test.
* gm2/iso/fail/forloopbyvar5.mod: New test.
* gm2/iso/pass/forloopbyvar3.mod: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
This patch improves the codegen for the following test case:
uint64x2_t foo (uint64x2_t r) {
uint32x4_t a = vreinterpretq_u32_u64 (r);
uint32_t t;
t = a[0]; a[0] = a[1]; a[1] = t;
t = a[2]; a[2] = a[3]; a[3] = t;
return vreinterpretq_u64_u32 (a);
}
from (-O1):
foo:
mov v31.16b, v0.16b
ins v0.s[0], v0.s[1]
ins v0.s[1], v31.s[0]
ins v0.s[2], v31.s[3]
ins v0.s[3], v31.s[2]
ret
to:
foo:
rev64 v0.4s, v0.4s
ret
This is achieved by extending the following match.pd pattern to account
for type differences between @0 and @1 due to view converts.
/* Simplify vector inserts of other vector extracts to a permute. */
(simplify
(bit_insert @0 (BIT_FIELD_REF@2 @1 @rsize @rpos) @ipos)
The patch was bootstrapped and regtested on aarch64-linux-gnu and
x86_64-linux-gnu, no regression.
OK for mainline?
Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
Co-authored-by: Richard Biener <rguenther@suse.de>
gcc/
PR tree-optimization/117093
* match.pd: Extend
(bit_insert @0 (BIT_FIELD_REF@2 @1 @rsize @rpos) @ipos) to allow
type differences between @0 and @1 due to view converts.
gcc/testsuite/
PR tree-optimization/117093
* gcc.dg/tree-ssa/pr117093.c: New test.