Age | Commit message (Collapse) | Author | Files | Lines |
|
On s390x, for input:
(call_insn/u 7 6 11 2 (parallel [
(set (reg:SI 2 %r2)
(call (subreg:QI (symbol_ref:SI ("__tls_get_offset") [flags 0x1]) 3)
(const_int 0 [0])))
(clobber (reg:SI 14 %r14))
(use (unspec:SI [
(const_int 0 [0])
] UNSPEC_TLSLDM))
]) "/tmp/foo.c":12:26 2602 {*brasl_tls}
(expr_list:REG_EH_REGION (const_int -2147483648 [0xffffffff80000000])
(nil))
(expr_list (use (reg:SI 2 %r2))
(expr_list (use (reg:SI 12 %r12))
(nil))))
after r16-1041-g2da641d0170090, get_call_rtx_from returns:
(call (subreg:QI (symbol_ref:SI ("__tls_get_offset") [flags 0x1]) 3)
(const_int 0 [0]))
and we got
Program received signal SIGSEGV, Segmentation fault.
0x000000000131174f in prepare_call_arguments (
bb=<basic_block 0x7fffe99dfba0 (2)>, insn=0x7fffe980cc60)
at /export/gnu/import/git/sources/gcc/gcc/var-tracking.cc:6277
6277 fndecl = MEM_EXPR (XEXP (call, 0));
(gdb) bt
bb=<basic_block 0x7fffe99dfba0 (2)>, insn=0x7fffe980cc60)
at /export/gnu/import/git/sources/gcc/gcc/var-tracking.cc:6277
at /export/gnu/import/git/sources/gcc/gcc/var-tracking.cc:10297
at /export/gnu/import/git/sources/gcc/gcc/var-tracking.cc:10526
at /export/gnu/import/git/sources/gcc/gcc/var-tracking.cc:10579
at /export/gnu/import/git/sources/gcc/gcc/var-tracking.cc:10616
Update prepare_call_arguments to check MEM_P before using MEM_EXPR.
gcc/
PR debug/120525
* var-tracking.cc (prepare_call_arguments): Use MEM_EXPR only
if MEM_P is true.
gcc/testsuite/
PR debug/120525
* gcc.dg/pr120525.c: New test.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
Fix a typo that prevented the warning from being activated with -Wc++compat.
PR c/120078
gcc/c-family/ChangeLog:
* c.opt (Wjump-misses-init): Fix typo.
gcc/testsuite/ChangeLog:
* gcc.dg/Wjump-misses-init-3.c: New test.
|
|
avoid ICE.
The checking assertion in composite_type_internal for structures and unions may
fail if there are self-referential types. To avoid this, we move them out of
the recursion. This should also be more efficient and covers other types.
We have to ignore some cases where we form composite types with qualifiers
not matching (PR120510).
gcc/c/ChangeLog:
* c-typeck.cc (composite_type_internal,composite_type): Move
checking assertions.
gcc/testsuite/ChangeLog:
* gcc.dg/gnu23-tag-composite-6.c: Update.
|
|
[PR116892]
After forward declaration of an enum and when completing it with the
attribute packed, we need to propagate TYPE_PACKED to all main variants.
PR c/116892
gcc/c/ChangeLog:
* c-decl.cc (finish_enum): Propagate TYPE_PACKED.
gcc/testsuite/ChangeLog:
* gcc.dg/pr116892.c: New test.
|
|
This testcase was fixed by r16-906-g8da568c885dc90. Since
this is a C testcase, it would be useful to have a C testcase besides
a C++ one too.
Tested for x86_64-linux-gnu.
PR tree-optimization/116824
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/phiprop-2.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
|
|
When we have a smallish CSWTCH, it could be placed in the rodata.cst16
section so it can be merged with other constants across TUs.
The fix is simple; just mark the decl as mergable (DECL_MERGEABLE).
DECL_MERGEABLE was added with r14-1500-g4d935f52b0d5c0 specifically
to improve these kind of decls.
PR tree-optimization/120451
gcc/ChangeLog:
* tree-switch-conversion.cc (switch_conversion::build_one_array): Mark
the newly created decl as mergable.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/cswtch-6.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
|
|
get_aka_type will create a new type for diagnostics, but for tagged types
attributes will then be ignored with a warning. This can lead to reentering
warning code which leads to an ICE. Fix this by ignoring the attributes
for tagged types.
PR c/120380
gcc/c/ChangeLog:
* c-objc-common.cc (get_aka_type): Ignore attributes for tagged types.
gcc/testsuite/ChangeLog:
* gcc.dg/pr120380.c: New test.
|
|
When doing early break vectorization of a loop with a conditional
reduction the epilog creation code is confused as to before which exit
to insert the conditional reduction induction IV update. The
following make sure this is done before the main IV exit.
PR tree-optimization/120357
* tree-vect-loop.cc (vect_create_epilog_for_reduction): Create
the conditional reduction induction IV increment before the
main IV exit.
* gcc.dg/vect/vect-early-break_136-pr120357.c: New testcase.
|
|
Update HTML output so that it renders highlight-a vs highlight-b
via <span> tags in the message itself, in the quoted source line,
in the underlines, and in the labels and their vertical bars.
Example output can be seen at:
https://dmalcolm.fedorapeople.org/gcc/2025-05-28/diagnostic-ranges.c.html
gcc/ChangeLog:
PR other/116792
* diagnostic-format-html.cc (HTML_STYLE): Add ".highlight-a" and
".highlight-b".
(html_builder::make_element_for_diagnostic): Handle begin_color
and end_color.
* diagnostic-show-locus.cc (to_html::to_html): Add "richloc"
param and use it to initialize m_richloc.
(to_html::colorize_text_for_range_idx): Drop.
(to_html::get_location_range_by_idx): New.
(to_html::get_highlight_color_for_range_idx): New.
(to_html::m_richloc): New field.
(print_html_span_start): Update for new param of to_html ctor.
(line_printer::m_was_in_range_p): New field.
(line_printer::m_last_range_idx): New field.
(layout_printer<Sink>::print_source_line): Use set_in_range
and set_outside_range rather than colorization calls.
(layout_printer<Sink>::set_in_range): New.
(layout_printer<Sink>::set_outside_range): New.
(layout_printer<Sink>::print_annotation_line): Use set_in_range
and set_outside_range rather than colorization calls.
(layout_printer<to_text>::begin_label): Convert param from label
to state_idx. Add "is_label_text" param and use it to guard logic
for turning off colorization within paths.
(layout_printer<to_html>::begin_label): Likewise. Push <span>
for any highlight color.
(layout_printer<to_text>::end_label): Likewise.
(layout_printer<to_text>::end_label): Likewise, popping the
<span>.
(layout_printer<Sink>::print_any_labels): Convert begin/end_label
calls to pass in state_idx rather than label. Use begin/end_label
rather than colorization calls.
(layout_printer<Sink>::layout_printer): Likewise.
(layout_printer<Sink>::layout_printer): Initialize new fields.
(diagnostic_source_print_policy::print_as_html): Update for new
param of to_html ctor.
gcc/testsuite/ChangeLog:
PR other/116792
* gcc.dg/format/diagnostic-ranges-html.py: New test script.
* gcc.dg/format/diagnostic-ranges.c: Add HTML generation to
options, and invoke the new script to check the HTML output.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
There is only one last_field for a structure type, but there might
be multiple last_fields for a union type, therefore we should ORed
the result of TYPE_INCLUDES_FLEXARRAY for multiple last_fields of
a union type.
PR c/120354
gcc/c/ChangeLog:
* c-decl.cc (finish_struct): Or the results for TYPE_INCLUDES_FLEXARRAY.
gcc/testsuite/ChangeLog:
* gcc.dg/pr120354.c: New test.
|
|
The root cause of the bug is: the TYPE_INCLUDES_FLEXARRAY marking of the
structure type is not copied to its aliased type.
The fix is to copy this marking to all the variant types of the current
structure type.
PR c/120353
gcc/c/ChangeLog:
* c-decl.cc (finish_struct): Copy TYPE_INCLUDES_FLEXARRAY marking
to all the variant types of the current structure type.
gcc/testsuite/ChangeLog:
* gcc.dg/pr120353.c: New test.
|
|
The following fixes conditional store elimination and store motion
so they consider stores to STRING_CSTs as trapping.
PR tree-optimization/120341
* tree-ssa-loop-im.cc (can_sm_ref_p): STRING_CSTs are readonly.
* tree-ssa-phiopt.cc (cond_store_replacement): Likewise.
* gcc.dg/torture/pr120341-1.c: New testcase.
* gcc.dg/torture/pr120341-2.c: Likewise.
|
|
This got broken with r13-9727 and fixed with either of
r13-9729 or r13-9728.
2025-05-30 Jakub Jelinek <jakub@redhat.com>
PR target/120480
* gcc.dg/pr120480.c: New test.
|
|
This patch adds support for "declare mapper" directives (and the "mapper"
modifier on "map" clauses) for C.
gcc/c/ChangeLog:
* c-decl.cc (c_omp_mapper_id, c_omp_mapper_decl, c_omp_mapper_lookup,
c_omp_extract_mapper_directive, c_omp_map_array_section,
c_omp_scan_mapper_bindings_r, c_omp_scan_mapper_bindings): New
functions.
* c-objc-common.h (LANG_HOOKS_OMP_FINISH_MAPPER_CLAUSES,
LANG_HOOKS_OMP_MAPPER_LOOKUP, LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE,
LANG_HOOKS_OMP_MAP_ARRAY_SECTION): Define langhooks for C.
* c-parser.cc (c_parser_omp_clause_map): Add declare_mapper_p
parameter; handle mapper modifier.
(c_parser_omp_all_clauses): Update call to c_parser_omp_clause_map.
(c_parser_omp_target): Instantiate explicit mappers and record bindings
for implicit mappers.
(c_parser_omp_declare_mapper): Parse "declare mapper" directives.
(c_parser_omp_declare): Support "declare mapper".
(c_parser_omp_declare_reduction): Use inform not error_at.
* c-tree.h (c_omp_finish_mapper_clauses, c_omp_mapper_lookup,
c_omp_extract_mapper_directive, c_omp_map_array_section,
c_omp_mapper_id, c_omp_mapper_decl, c_omp_scan_mapper_bindings,
c_omp_instantiate_mappers): Add prototypes.
* c-typeck.cc (c_finish_omp_clauses): Handle GOMP_MAP_PUSH_MAPPER_NAME
and GOMP_MAP_POP_MAPPER_NAME.
(c_omp_finish_mapper_clauses): New function (langhook).
libgomp/ChangeLog:
* testsuite/libgomp.c-c++-common/declare-mapper-9.c: Enable for C.
* testsuite/libgomp.c-c++-common/declare-mapper-10.c: Likewise.
* testsuite/libgomp.c-c++-common/declare-mapper-11.c: Likewise.
* testsuite/libgomp.c-c++-common/declare-mapper-12.c: Likewise.
* testsuite/libgomp.c-c++-common/declare-mapper-13.c: Likewise.
* testsuite/libgomp.c-c++-common/declare-mapper-14.c: Likewise.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/declare-mapper-3.c: Enable for C.
* c-c++-common/gomp/declare-mapper-4.c: Likewise.
* c-c++-common/gomp/declare-mapper-5.c: Likewise.
* c-c++-common/gomp/declare-mapper-6.c: Likewise.
* c-c++-common/gomp/declare-mapper-7.c: Likewise.
* c-c++-common/gomp/declare-mapper-8.c: Likewise.
* c-c++-common/gomp/declare-mapper-9.c: Likewise.
* c-c++-common/gomp/declare-mapper-10.c: Likewise.
* c-c++-common/gomp/declare-mapper-12.c: Likewise.
* c-c++-common/gomp/map-6.c: Update dg-error.
* gcc.dg/gomp/udr-3.c: Update for change to dg-note.
* c-c++-common/gomp/declare-mapper-11.c: New.
* gcc.dg/gomp/declare-mapper-10.c: New test.
* gcc.dg/gomp/declare-mapper-11.c: New test.
* gcc.dg/gomp/declare-mapper-13.c: New test.
|
|
I noticed whilst working on another issue that in diagnostic-show-locus
within the quoted source lines and the annotation underlines that when
we're showing highlight-{a,b} that we emit
start-colorization-code, character, end-colorization-code
per *character*, rather than just when the colorization changes.
This was due to me failing to implement consolidation of such changes in
colorizer::set_named_color in r15-2015-g7d73c01ce6d1ab.
Fixed thusly, simplifying the output.
I manually inspected all of the changed testcases in a terminal with
color enabled and verified that the output is visually identical to
before.
gcc/ChangeLog:
* diagnostic-show-locus.cc (colorizer::m_current_named_color): New
field.
(colorizer::set_named_color): Use it to consolidate repeated calls
to the same color.
gcc/testsuite/ChangeLog:
* g++.dg/diagnostic/bad-binary-ops-highlight-colors.C: Update
expected multiline output for quoted source and underlines to
reflect emitting color codes when changes happen, rather than
per character.
* g++.dg/diagnostic/long-short-colorization.C: Likewise.
* g++.dg/plugin/show-template-tree-color-labels.C: Likewise.
* gcc.dg/bad-binary-ops-highlight-colors.c: Likewise.
* gcc.dg/format/colors.c: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
As the rtl.texi documentation of RTX_AUTOINC expressions says:
If a register used as the operand of these expressions is used in
another address in an insn, the original value of the register is
used. Uses of the register outside of an address are not permitted
within the same insn as a use in an embedded side effect expression
because such insns behave differently on different machines and hence
must be treated as ambiguous and disallowed.
late-combine was failing to follow this rule. One option would have
been to enforce it during the substitution phase, like combine does.
This could either be a dedicated condition in the substitution code
or, more generally, an extra condition in can_merge_accesses.
(The latter would include extending is_pre_post_modify to uses.)
However, since the restriction applies to patterns rather than to
actions on patterns, the more robust fix seemed to be test and reject
this case in (a subroutine of) rtl_ssa::recog. We already do something
similar for hard-coded register clobbers.
Using vec_rtx_properties isn't the lightest-weight operation
out there. I did wonder about relying on the is_pre_post_modify
flag of the definitions in the new_defs array, but that would
require callers that create new autoincs to set the flag before
calling recog. Normally these flags are instead updated
automatically based on the final pattern.
Besides, recog itself has had to traverse the whole pattern,
and it is even less light-weight than vec_rtx_properties.
At least the pattern should be in cache.
The rtl-ssa fix showed up a mistake (of mine) in the rtl_properties
walker: try_to_add_src would drop all flags except IN_NOTE before
recursing into RTX_AUTOINC addresses.
RTX_AUTOINCs only occur in addresses, and so for them, the flags coming
into try_to_add_src are set by:
unsigned int base_flags = flags & rtx_obj_flags::STICKY_FLAGS;
...
if (MEM_P (x))
{
...
unsigned int addr_flags = base_flags | rtx_obj_flags::IN_MEM_STORE;
if (flags & rtx_obj_flags::IS_READ)
addr_flags |= rtx_obj_flags::IN_MEM_LOAD;
try_to_add_src (XEXP (x, 0), addr_flags);
return;
}
This means that the only flags that can be set are:
- IN_NOTE (the sole member of STICKY_FLAGS)
- IN_MEM_STORE
- IN_MEM_LOAD
Thus dropping all flags except IN_NOTE had the effect of dropping
IN_MEM_STORE and IN_MEM_LOAD, and nothing else. But those flags
are the ones that mark something as being part of a mem address.
The exclusion was therefore exactly wrong.
gcc/
PR rtl-optimization/120347
* rtlanal.cc (rtx_properties::try_to_add_src): Don't drop the
IN_MEM_LOAD and IN_MEM_STORE flags for autoinc registers.
* rtl-ssa/changes.cc (recog_level2): Check whether an
RTX_AUTOINCed register also appears outside of an address.
gcc/testsuite/
PR rtl-optimization/120347
* gcc.dg/torture/pr120347.c: New test.
|
|
For invalid nesting of a structure definition in a definition
of itself or when using a rather obscure construction using statement
expressions, we can create mutually recursive pairs of non-identical
but compatible structure types. This can lead to invalid composite
types and an ICE. If we detect recursion even for swapped pairs
when forming composite types, this is avoided.
PR c/120381
gcc/c/ChangeLog:
* c-typeck.cc (composite_type_internal): Stop recursion for
swapped pairs.
gcc/testsuite/ChangeLog:
* gcc.dg/pr120381.c: New test.
* gcc.dg/gnu23-tag-composite-6.c: New test.
|
|
In GCC 15 we allowed jump-function generation code to skip over a
type-cast converting one integer to another as long as the latter can
hold all the values of the former or has at least the same precision.
This works well for IPA-CP where we do then evaluate each jump
function as we propagate values and value-ranges. However, the
test-case in PR 120295 shows a problem with inlining, where we combine
pass-through jump-functions so that they are always relative to the
function which is the root of the inline tree. Unfortunately, we are
happy to combine also those with type-casts to a different signedness
which makes us use sign zero extension for the expected value ranges
where we should have used sign extension. When the value-range which
then leads to wrong insertion of a call to builtin_unreachable is
being computed, the information about an existence of a intermediary
signed type has already been lost during previous inlining.
This patch simply blocks combining such jump-functions so that it is
back-portable to GCC 15. Once we switch pass-through jump functions
to use a vector of operations rather than having room for just one, we
will be able to address this situation with adding an extra conversion
instead.
gcc/ChangeLog:
2025-05-19 Martin Jambor <mjambor@suse.cz>
PR ipa/120295
* ipa-prop.cc (update_jump_functions_after_inlining): Do not
combine pass-through jump functions with type-casts changing
signedness.
gcc/testsuite/ChangeLog:
2025-05-19 Martin Jambor <mjambor@suse.cz>
PR ipa/120295
* gcc.dg/ipa/pr120295.c: New test.
|
|
The patch tries to solve miss vectorization for below case.
void
foo (int* a, int* restrict b)
{
b[0] = a[0] * a[64];
b[1] = a[65] * a[1];
b[2] = a[2] * a[66];
b[3] = a[67] * a[3];
b[4] = a[68] * a[4];
b[5] = a[69] * a[5];
b[6] = a[6] * a[70];
b[7] = a[7] * a[71];
}
In vect_analyze_data_ref_accesses, a[0], a[1], .. a[7], a[64], ...,
a[71] are in same group with size of 71. It caused vectorization
unprofitable.
gcc/ChangeLog:
PR tree-optimization/119181
* tree-vect-data-refs.cc (vect_analyze_data_ref_accesses):
Split datarefs when there's a gap bigger than
MAX_BITSIZE_MODE_ANY_MODE.
gcc/testsuite/ChangeLog:
* gcc.dg/vect/bb-slp-pr119181.c: New test.
|
|
It has been standardized in C2y.
PR c/117025
gcc/c/ChangeLog:
* c-parser.cc (c_parser_sizeof_or_countof_expression):
Add -Wpedantic diagnostic for _Countof in <= C23 mode.
gcc/testsuite/ChangeLog:
* gcc.dg/countof-compat.c: New test.
* gcc.dg/countof-no-compat.c: New test.
* gcc.dg/countof-pedantic.c: New test.
* gcc.dg/countof-pedantic-errors.c: New test.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
PR c/117025
gcc/ChangeLog:
* Makefile.in (USER_H): Add <stdcountof.h>.
* ginclude/stdcountof.h: New file.
gcc/testsuite/ChangeLog:
* gcc.dg/countof-stdcountof.c: New test.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
This operator is similar to sizeof but can only be applied to an array,
and returns its number of elements.
FUTURE DIRECTIONS:
- We should make it work with array parameters to functions,
and somehow magically return the number of elements of the array,
regardless of it being really a pointer.
Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3550.pdf>
Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117025>
Link: <https://inbox.sourceware.org/gcc/M8S4oQy--3-2@tutanota.com/T/>
Link: <https://inbox.sourceware.org/gcc-patches/20240728141547.302478-1-alx@kernel.org/T/#t>
Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3313.pdf>
Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3325.pdf>
Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3369.pdf>
Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3469.htm>
Link: <https://github.com/llvm/llvm-project/issues/102836>
Link: <https://thephd.dev/the-big-array-size-survey-for-c>
Link: <https://thephd.dev/the-big-array-size-survey-for-c-results>
Link: <https://stackoverflow.com/questions/37538/#57537491>
PR c/117025
gcc/ChangeLog:
* doc/extend.texi: Document _Countof operator.
gcc/c-family/ChangeLog:
* c-common.h (enum rid): Add RID_COUNTOF.
(c_countof_type): New function prototype.
* c-common.def (COUNTOF_EXPR): New tree.
* c-common.cc (c_common_reswords): Add RID_COUNTOF entry.
(c_countof_type): New function.
gcc/c/ChangeLog:
* c-tree.h (in_countof): Add global variable declaration.
(c_expr_countof_expr): Add function prototype.
(c_expr_countof_type): Add function prototype.
* c-decl.cc (start_struct, finish_struct): Add support for
_Countof.
(start_enum, finish_enum): Add support for _Countof.
* c-parser.cc (c_parser_sizeof_expression): New macro.
(c_parser_countof_expression): New macro.
(c_parser_sizeof_or_countof_expression): Rename function and add
support for _Countof.
(c_parser_unary_expression): Add RID_COUNTOF entry.
* c-typeck.cc (in_countof): Add global variable.
(build_external_ref): Add support for _Countof.
(record_maybe_used_decl): Add support for _Countof.
(pop_maybe_used): Add support for _Countof.
(is_top_array_vla): New function.
(c_expr_countof_expr, c_expr_countof_type): New functions.
gcc/testsuite/ChangeLog:
* gcc.dg/countof-compile.c: New test.
* gcc.dg/countof-vla.c: New test.
* gcc.dg/countof-vmt.c: New test.
* gcc.dg/countof-zero-compile.c: New test.
* gcc.dg/countof-zero.c: New test.
* gcc.dg/countof.c: New test.
Suggested-by: Xavier Del Campo Romero <xavi.dcr@tutanota.com>
Co-authored-by: Martin Uecker <uecker@tugraz.at>
Acked-by: "James K. Lowden" <jklowden@schemamania.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
This patch reworks the HTML output from the the option
-fdiagnostics-add-output=experimental-html
so that for source quoting and path printing, rather than simply adding
the textual output inside <pre> elements, it breaks up the output
into HTML tags reflecting the structure of the output, using CSS, SVG
and a little javascript to help the user navigate the diagnostics and
the events within any paths.
This uses ideas from the patch I posted in:
https://gcc.gnu.org/pipermail/gcc-patches/2020-November/558603.html
but reworks the above patch so that:
* rather than printing source to a pretty_printer, the HTML is created
by building a DOM tree in memory, using a new xml::printer class. This
should be less error-prone than the pretty_printer approach, since it
ought to solve escaping issues. Instead of a text vs html boolean,
the code is generalized via templates with to_text vs to_html sinks.
This templatization applies both to path-printing and
diagnostic-show-locus.cc.
* the HTML output can have multiple diagnostics and multiple paths rather
than just a single path. The javascript keyboard controls now cycle
through all diagnostics and all events within them
An example of the output can be seen at:
https://dmalcolm.fedorapeople.org/gcc/2025-05-27/malloc-1.c.html
where the keys "j" and "k" cycle through diagnostics and events
within them.
gcc/ChangeLog:
PR other/116792
* diagnostic-format-html.cc: Define INCLUDE_STRING.
Include "xml.h", "xml-printer.h", and "json.h".
(html_generation_options::html_generation_options): New.
(namespace xml): Move decls to xml.h and convert from using
label_text to std::string.
(xml::text::write_as_xml): Reimplement indentation so it is done
by this node, rather than the parent.
(xml::node_with_children::add_text): Convert from label_text to
std::string. Consolidate runs of text into a single node.
(xml::document::write_as_xml): Reimplement indentation.
(xml::element::write_as_xml): Reimplement indentation so it is
done by this node, rather than the parent. Convert from
label_text to std::string. Update attribute-printing to new
representation to preserve insertion order.
(xml::element::set_attr): Convert from label_text to std::string.
Record insertion order.
(xml::raw::write_as_xml): New.
(xml::printer::printer): New.
(xml::printer::push_tag): New.
(xml::printer::push_tag_with_class): New.
(xml::printer::pop_tag): New.
(xml::printer::set_attr): New.
(xml::printer::add_text): New.
(xml::printer::add_raw): New.
(xml::printer::push_element): New.
(xml::printer::append): New.
(xml::printer::get_insertion_point): New.
(html_builder::add_focus_id): New.
(html_builder::m_html_gen_opts): New field.
(html_builder::m_head_element): New field.
(html_builder::m_next_diag_id): New field.
(html_builder::m_ui_focus_ids): New field.
(make_div): Convert from label_text to std::string.
(make_span): Likewise.
(HTML_STYLE): New.
(HTML_SCRIPT): New.
(html_builder::html_builder): Fix indentation. Add
"html_gen_opts" param. Initialize new fields. Reimplement
using xml::printer. Optionally add style and script tags.
(class html_path_label_writer): New.
(html_builder::make_element_for_diagnostic): Convert from
label_text to std::string. Set "id" on "gcc-diagnostic" and
"gcc-message" <div> elements; add the latter to the focus ids.
Use diagnostic_context::maybe_show_locus_as_html rather than
html_builder::make_element_for_source. Use print_path_as_html
rather than html_builder::make_element_for_path.
(html_builder::make_element_for_source): Drop.
(html_builder::make_element_for_path): Drop.
(html_builder::make_element_for_patch): Convert from label_text to
std::string.
(html_builder::make_metadata_element): Likewise. Use
xml::printer.
(html_builder::make_element_for_metadata): Convert from label_text
to std::string.
(html_builder::emit_diagram): Expand comment.
(html_builder::flush_to_file): Write out initializer for
"focus_ids" into javascript.
(html_output_format::html_output_format): Add param
"html_gen_opts" and use it to initialize m_builder.
(html_file_output_format::html_file_output_format): Likewise, to
initialize base class.
(make_html_sink): Likewise, to pass to ctor.
(selftest::test_html_diagnostic_context::test_html_diagnostic_context):
Set up html_generation_options.
(selftest::html_buffered_output_format::html_buffered_output_format):
Add html_gen_opts param.
(selftest::test_simple_log): Add id attributes to expected text
for "gcc-diagnostic" and "gcc-message" elements. Update
whitespace for indentation fixes.
(selftest::test_metadata): Update whitespace for indentation
fixes.
(selftest::test_printer): New selftest.
(selftest::test_attribute_ordering): New selftest.
(selftest::diagnostic_format_html_cc_tests): Call the new
selftests.
* diagnostic-format-html.h (struct html_generation_options): New.
(make_html_sink): Add "html_gen_opts" param.
(print_path_as_html): New decl.
* diagnostic-path-output.cc: Define INCLUDE_MAP. Add includes of
"diagnostic-format-html.h", "xml.h", and "xml-printer.h".
(path_print_policy::path_print_policy): Add ctor.
(path_print_policy::get_diagram_theme): Fix whitespace.
(struct stack_frame): New.
(begin_html_stack_frame): New function.
(end_html_stack_frame): New function.
(emit_svg_arrow): New function.
(event_range::print): Rename to...
(event_range::print_as_text): ...this. Update call to
diagnostic_start_span.
(event_range::print_as_html): New, based on the above, but ported
from pretty_printer to xml::printer.
(thread_event_printer::print_swimlane_for_event_range): Rename
to...
(thread_event_printer::print_swimlane_for_event_range_as_text):
...this. Update for renaming of event_range::print to
event_range::print_as_text.
(thread_event_printer::print_swimlane_for_event_range_as_html):
New.
(print_path_summary_as_text): Update for "_as_text" renaming.
(print_path_summary_as_html): New.
(print_path_as_html): New.
* diagnostic-show-locus.cc: Add defines of INCLUDE_MAP and
INCLUDE_STRING. Add includes of "xml.h" and "xml-printer.h".
(struct char_display_policy): Replace "m_print_cb" with
"m_print_text_cb" and "m_print_html_cb".
(struct to_text): New.
(struct to_html): New.
(get_printer): New.
(default_diagnostic_start_span_fn<to_text>): New.
(default_diagnostic_start_span_fn<to_html>): New.
(class layout): Update "friend class layout_printer;" for
template.
(enum class margin_kind): New.
(class layout_printer): Convert into a template.
(layout_printer::m_pp): Replace field with...
(layout_printer::m_sink): ...this.
(layout_printer::m_colorizer): Drop field in favor of a pointer
in the "to_text" sink.
(default_print_decoded_ch): Convert into a template.
(escape_as_bytes_print): Likewise.
(escape_as_unicode_print): Likewise.
(make_char_policy): Update to use both text and html callbacks.
(layout_printer::print_gap_in_line_numbering): Replace with...
(layout_printer<to_text>::print_gap_in_line_numbering): ...this
(layout_printer<to_html>::print_gap_in_line_numbering): ...and
this.
(layout_printer::print_source_line): Convert to template, using
m_sink.
(layout_printer::print_leftmost_column): Likewise.
(layout_printer::start_annotation_line): Likewise.
(layout_printer<to_text>::end_line): New.
(layout_printer<to_html>::end_line): New.
(layout_printer::print_annotation_line): Convert to template,
using m_sink.
(class line_label): Add field m_original_range_idx.
(layout_printer<to_text>::begin_label): New.
(layout_printer<to_html>::begin_label): New.
(layout_printer<to_text>::end_label): New.
(layout_printer<to_html>::end_label): New.
(layout_printer::print_any_labels): Convert to template, using
m_sink.
(layout_printer::print_leading_fixits): Likewise.
(layout_printer::print_trailing_fixits): Likewise.
(layout_printer::print_newline): Drop.
(layout_printer::move_to_column): Convert to template, using
m_sink.
(layout_printer::show_ruler): Likewise.
(layout_printer::print_line): Likewise.
(layout_printer::print_any_right_to_left_edge_lines): Likewise.
(layout_printer::layout_printer): Likewise.
(diagnostic_context::maybe_show_locus_as_html): New.
(diagnostic_source_print_policy::diagnostic_source_print_policy):
Update for split of start_span_cb into text vs html variants.
(diagnostic_source_print_policy::print): Update for use of
templates; use to_text.
(diagnostic_source_print_policy::print_as_html): New.
(layout_printer::print): Convert to template, using m_sink.
(selftest::make_element_for_locus): New.
(selftest::make_raw_html_for_locus): New.
(selftest::test_layout_x_offset_display_utf8): Update for use of
templates.
(selftest::test_layout_x_offset_display_tab): Likewise.
(selftest::test_one_liner_caret_and_range): Add test coverage of
HTML output.
(selftest::test_one_liner_labels): Likewise.
* diagnostic.cc (diagnostic_context::initialize): Update for split
of start_span_cb into text vs html variants.
(default_diagnostic_start_span_fn): Move to
diagnostic-show-locus.cc, converting to template.
* diagnostic.h (class xml::printer): New forward decl.
(diagnostic_start_span_fn): Replace typedef with "using",
converting to a template.
(struct to_text): New forward decl.
(struct to_html): New forward decl.
(get_printer): New decl.
(diagnostic_location_print_policy::print_text_span_start): New
decl.
(diagnostic_location_print_policy::print_html_span_start): New
decl.
(class html_label_writer): New.
(diagnostic_source_print_policy::print_as_html): New decl.
(diagnostic_source_print_policy::get_start_span_fn): Replace
with...
(diagnostic_source_print_policy::get_text_start_span_fn): ...this
(diagnostic_source_print_policy::get_html_start_span_fn): ...and
this
(diagnostic_source_print_policy::m_start_span_cb): Replace with...
(diagnostic_source_print_policy::m_text_start_span_cb): ...this
(diagnostic_source_print_policy::m_html_start_span_cb): ...and
this.
(diagnostic_context::maybe_show_locus_as_html): New decl.
(diagnostic_context::m_text_callbacks::m_start_span): Replace
with...
(diagnostic_context::m_text_callbacks::m_text_start_span): ...this
(diagnostic_context::m_text_callbacks::m_html_start_span): ...and
this.
(diagnostic_start_span): Update for template change.
(diagnostic_show_locus_as_html): New inline function.
(default_diagnostic_start_span_fn): Convert to template.
* doc/invoke.texi (experimental-html): Add "css" and "javascript"
keys.
* opts-diagnostic.cc (html_scheme_handler::make_sink): Likewise.
* selftest-diagnostic.cc
(selftest::test_diagnostic_context::start_span_cb): Update for
template changes.
* selftest-diagnostic.h
(selftest::test_diagnostic_context::start_span_cb): Likewise.
* xml-printer.h: New file.
* xml.h: New file, based on material in diagnostic-format-html.cc,
but using std::string rather than label_text.
(xml::element::m_key_insertion_order): New field.
(struct xml::raw): New.
gcc/fortran/ChangeLog
PR other/116792
* error.cc (gfc_diagnostic_start_span): Update for diagnostic.h
changes.
gcc/testsuite/ChangeLog:
PR other/116792
* gcc.dg/html-output/missing-semicolon.c: Add ":javascript=no" to
html output.
* gcc.dg/html-output/missing-semicolon.py: Move repeated
definitions into lib/htmltest.py.
* gcc.dg/plugin/diagnostic_group_plugin.cc: Update for template
changes.
* gcc.dg/plugin/diagnostic-test-metadata-html.c: Add
":javascript=no" to html output. Add
"-fdiagnostics-show-line-numbers".
* gcc.dg/plugin/diagnostic-test-metadata-html.py: Move repeated
definitions into lib/htmltest.py. Add checks of annotated source.
* gcc.dg/plugin/diagnostic-test-paths-2.c: Add ":javascript=no" to
html output.
* gcc.dg/plugin/diagnostic-test-paths-2.py: Move repeated
definitions into lib/htmltest.py. Add checks of execution path.
* gcc.dg/plugin/diagnostic-test-paths-4.c: Add
-fdiagnostics-add-output=experimental-html:javascript=no. Add
invocation ot diagnostic-test-paths-4.py.
* gcc.dg/plugin/diagnostic-test-paths-4.py: New test script.
* gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c: Add
-fdiagnostics-add-output=experimental-html:javascript=no. Add
invocation of diagnostic-test-show-locus.py.
* gcc.dg/plugin/diagnostic-test-show-locus.py: New test script.
* lib/htmltest.py: New test support script.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
With all-SLP we annotate statements slightly differently. This patch
uses STMT_VINFO_RELEVANT_P in order to walk through potential program
points.
Also it makes the LMUL estimate always use the same path. This helps
fix a number of test cases that regressed since GCC 14.
There are still some failing ones but it appears to me that the chosen
LMUL is still correct and we just expect different log messages.
gcc/ChangeLog:
* config/riscv/riscv-vector-costs.cc (compute_estimated_lmul):
Always use vect_vf_for_cost and TARGET_MIN_VLEN.
gcc/testsuite/ChangeLog:
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-3.c: Adjust
expectations.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-9.c: Ditto.
|
|
[aarch64] [vxworks] mark x18 as fixed, adjust tests
VxWorks uses x18 as the TCB, so STATIC_CHAIN_REGNUM has long been set
(in gcc/config/aarch64/aarch64-vxworks.h) to use x9 instead.
This patch marks x18 as fixed if the newly-introduced
TARGET_OS_USES_R18 is defined, so that it is not chosen by the
register allocator, rejects -fsanitize-shadow-call-stack due to the
register conflict, and adjusts tests that depend on x18 or on the
static chain register.
for gcc/ChangeLog
* config/aarch64/aarch64-vxworks.h (TARGET_OS_USES_R18): Define.
Update comments.
* config/aarch64/aarch64.cc (aarch64_conditional_register_usage):
Mark x18 as fixed on VxWorks.
(aarch64_override_options_internal): Issue sorry message on
-fsanitize=shadow-call-stack if TARGET_OS_USES_R18.
for gcc/testsuite/ChangeLog
* gcc.dg/cwsc1.c (CHAIN, aarch64): x9 instead x18 for __vxworks.
* gcc.target/aarch64/reg-alloc-4.c: Drop x18-assigned asm
operand on vxworks.
* gcc.target/aarch64/shadow_call_stack_1.c: Don't expect
-ffixed-x18 error on vxworks, but rather the sorry message.
* gcc.target/aarch64/shadow_call_stack_2.c: Skip on vxworks.
* gcc.target/aarch64/shadow_call_stack_3.c: Likewise.
* gcc.target/aarch64/shadow_call_stack_4.c: Likewise.
* gcc.target/aarch64/shadow_call_stack_5.c: Likewise.
* gcc.target/aarch64/shadow_call_stack_6.c: Likewise.
* gcc.target/aarch64/shadow_call_stack_7.c: Likewise.
* gcc.target/aarch64/shadow_call_stack_8.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-19.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-20.c: Likewise.
|
|
targets
Shifts are the only special case I'm aware of where the most
significant limb (if it is has padding bits) is accessed inside of a loop or
with access outside of a loop but with variable idx. Everything else should
access the most significant limb using INTEGER_CST idx and thus can (and
should) deal with the needed extension on that access directly.
And RSHIFT_EXPR shouldn't really violate the content of the padding bits.
For LSHIFT_EXPR we should IMHO do the following (which fixes the testcase
on s390x-linux).
The LSHIFT_EXPR is
/* Lower
dst = src << n;
as
unsigned n1 = n % limb_prec;
size_t n2 = n / limb_prec;
size_t n3 = n1 != 0;
unsigned n4 = (limb_prec - n1) % limb_prec;
size_t idx;
size_t p = prec / limb_prec - (prec % limb_prec == 0);
for (idx = p; (ssize_t) idx >= (ssize_t) (n2 + n3); --idx)
dst[idx] = (src[idx - n2] << n1) | (src[idx - n2 - n3] >> n4);
if (n1)
{
dst[idx] = src[idx - n2] << n1;
--idx;
}
for (; (ssize_t) idx >= 0; --idx)
dst[idx] = 0; */
as described in the comment (note, the comments are for the little-endian
lowering only, didn't want to complicate it with endianity).
As can be seen, the most significant limb can be modifier either inside
of the loop or in the if (n1) body if the loop had 0 iterations.
In your patch you've modified I believe just the loop and not the if body,
and made it conditional on every iteration (furthermore through
gimplification of COND_EXPR which is not the way this is done elsewhere in
gimple-lower-bitint.cc, there is if_then helper and it builds
gimple_build_cond etc.). I think that is way too expensive. In theory we
could peel off the first iteration manually and do the info->extended
handling in there and do it again inside of the if (n1) case if idx ==
(bitint_big_endian ? size_zero_node : p) in that case, but I think just
doing the extension after the loops is easier.
Note, we don't need to worry about volatile here, the shift is done into
an addressable variable memory only if it is non-volatile, otherwise it
is computed into a temporary and then copied over into the volatile var.
2025-05-22 Jakub Jelinek <jakub@redhat.com>
* gimple-lower-bitint.cc (bitint_extended): New variable.
(bitint_large_huge::lower_shift_stmt): For LSHIFT_EXPR with
bitint_extended if lhs has most significant partial limb extend
it afterwards.
* gcc.dg/bitintext.h: New file.
* gcc.dg/torture/bitint-82.c: New test.
|
|
Since r13-6296, we haven't got 4 simdclone calls for these tests on
ia32 without avx_runtime. With avx_runtime, we get 3 such calls even
on ia32, but we didn't test for anything on ia32 with avx_runtime.
Adjust and simplify the expectations and comments.
for gcc/testsuite/ChangeLog
* gcc.dg/vect/vect-simd-clone-16e.c: Expect fewer calls on ia32.
* gcc.dg/vect/vect-simd-clone-17e.c: Likewise.
* gcc.dg/vect/vect-simd-clone-18e.c: Likewise.
|
|
Some tsvc tests add vect_early_break options without requiring the
feature to be available. Add the requirements.
for gcc/testsuite/ChangeLog
* gcc.dg/vect/tsvc/vect-tsvc-s332.c: Require vect_early_break_hw.
* gcc.dg/vect/tsvc/vect-tsvc-s481.c: Likewise.
* gcc.dg/vect/tsvc/vect-tsvc-s482.c: Likewise.
|
|
The vector operations are only turned into BIT_INSERT_EXPR with -msse
on ia32.
for gcc/testsuite/ChangeLog
* gcc.dg/tree-ssa/forwprop-41.c: Add -msse on x86.
|
|
The string length optimizations at 8-byte blocks requires -msse2;
-msse is not enough. Bump it.
for gcc/testsuite/ChangeLog
* gcc.dg/strlenopt-80.c: Bump to -msse2.
|
|
The 8-byte memory operations will only be inlined on ia32 with
-msse2. Bump it.
for gcc/testsuite/ChangeLog
* gcc.dg/memcpy-6.c: Bump to -msse2.
|
|
SSE_FLOAT_MODE_P only holds for DFmode with SSE2, and that's a
condition for copysign<mode>3 to be available under TARGET_SSE_MATH.
Various copysign testcases use -msse -mfpmath=sse on ia32 to enable
the copysign builtins and patterns, but that would only be enough if
the tests were limited to floats. Since they test doubles as well, we
need -msse2 instead of -msse.
for gcc/testsuite/ChangeLog
* gcc.dg/fold-copysign-1.c: Bump to sse2 on ia32.
* gcc.dg/pr55152-2.c: Likewise.
* gcc.dg/tree-ssa/abs-4.c: Likewise.
* gcc.dg/tree-ssa/backprop-6.c: Likewise.
|
|
This was introduced by r15-1797-gd8fe4f05ef448e . I had missed that
the LHS of the cabs call could be NULL. This seems to only happen at -O0,
I tried to produce one that happens at -O1 but needed many different
options to prevent the removal of the call.
Anyways the fix is just keep around the call if the LHS is null.
Bootstrapped and tested on x86_64-linux-gnu.
PR middle-end/120369
gcc/ChangeLog:
* tree-complex.cc (gimple_expand_builtin_cabs): Return early
if the LHS of cabs is null.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/pr120369-1.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
|
|
The following patch adds big endian support to the bitintlower pass.
While the rest of the _BitInt support has been written with endianity
in mind, in the bitintlower pass I've written it solely little endian
at the start, because the pass is large and complicated and there were
no big-endian backends with _BitInt psABI at the point of writing it,
so the big-endian support would be completely untested.
Now that I got privately a patch to add s390x support, I went through
the whole pass and added the support.
Some months ago I've talked about two possibilities to do the big-endian
support, one perhaps easier would be keep the idx vars (INTEGER_CSTs
for bitint_prec_large and partially SSA_NAMEs, partially INTEGER_CSTs
for bitint_prec_huge) iterating like for little-endian from 0 upwards
and do the big-endian index correction only when accessing the limbs
(but mergeable casts between _BitInts with different number of limbs
would be a nightmare), which would have the disadvantage that we'd need
to wait until propagation and ivopts to fix stuff up (and not sure it
would be able to fix everything), or change stuff so that the idxes
used between the different bitint_large_huge class methods iterate on
big endian from highest down to 0.
The following patch implements the latter.
On s390x with the 3 patches from IBM without this patch I got on
make -j32 -k check-gcc GCC_TEST_RUN_EXPENSIVE=1 RUNTESTFLAGS="GCC_TEST_RUN_EXPENSIVE=1 dg.exp='*bitint* pr112673.c builtin-stdc-bit-*.c pr112566-2.c pr112511.c pr116588.c pr116003.c
+pr113693.c pr113602.c flex-array-counted-by-7.c' dg-torture.exp='*bitint* pr116480-2.c pr114312.c pr114121.c' dfp.exp=*bitint* vect.exp='vect-early-break_99-pr113287.c'
+tree-ssa.exp=pr113735.c"
347 FAILs, 326 out of that execution failures (and that doesn't include
some tests that happened to succeed by pure luck because e.g. comparisons
weren't implemented correctly).
With this patch (and 2 small patches I'm going to post next) I got this
down to
FAIL: gcc.dg/dfp/bitint-1.c (test for excess errors)
FAIL: gcc.dg/dfp/bitint-2.c (test for excess errors)
FAIL: gcc.dg/dfp/bitint-3.c (test for excess errors)
FAIL: gcc.dg/dfp/bitint-4.c (test for excess errors)
FAIL: gcc.dg/dfp/bitint-5.c (test for excess errors)
FAIL: gcc.dg/dfp/bitint-6.c (test for excess errors)
FAIL: gcc.dg/dfp/bitint-8.c (test for excess errors)
FAIL: gcc.dg/torture/bitint-64.c -O3 -g execution test
FAIL: gcc.dg/torture/bitint-64.c -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects execution test
where the dfp stuff is due to missing DPD dfp <-> _BitInt support
I'm working on next, and bitint-64.c is some expansion related
issue with _Atomic _BitInt(5) (will look at it later, but there
bitint lowering isn't involved at all).
Most of the patch just tweaks things so that it iterates in the
right direction, for casts with different number of limbs does the
needed index adjustments and unfortunately due to that (and e.g.
add/sub/mul overflow BE lowering) has some pessimizations on the
SSA conflict side; on little-endian mergeable ops have the
advantage that all the accesses iterate from index 0 up, so even
if there is e.g. overlap between the lhs and some used values, except
for mul/div where libgcc APIs require no overlap we don't need to
avoid it, all the limbs are updated in sync before going on to handle
next limb. On big-endian, that isn't the case, casts etc. can result
in index adjustments and so we could overwrite a limb that will still
need to be processed as input. So, there is a special case that looks
for different numbers of limbs among arguments and in that case marks
the lhs as conflicting with the inputs.
On little-endian, this patch shouldn't affect code generation, with
one little exception; in the separate_ext handling in lower_mergeable_stmt
the loop (if bitint_large_huge) was iterating using some idx and then
if bo_idx was non-zero, adding that constant to a new SSA_NAME and using
that to do the limb accesses. As the limb accesses are the only place
where the idx is used (apart from the loop exit test), I've changed it
to iterate on idxes with bo_idx already added to those.
P.S., would be nice to eventually also enable big-endian aarch64,
but I don't have access to those, so can't test that myself.
P.S., at least in the current s390x patches it wants info->extended_p,
this patch doesn't change anything about that. I believe most of the
time the _BitInt vars/params/return values are already extended, but
there is no testcase coverage for that, I will work on that incrementally
(and then perhaps arm 32-bit _BitInt support can be enabled too).
2025-05-20 Jakub Jelinek <jakub@redhat.com>
* gimple-lower-bitint.cc (bitint_big_endian): New variable.
(bitint_precision_kind): Set it.
(struct bitint_large_huge): Add unsigned argument to
finish_arith_overflow.
(bitint_large_huge::limb_access_type): Handle bitint_big_endian.
(bitint_large_huge::handle_operand): Likewise.
(bitint_large_huge::handle_cast): Likewise.
(bitint_large_huge::handle_bit_field_ref): Likewise.
(bitint_large_huge::handle_load): Likewise.
(bitint_large_huge::lower_shift_stmt): Likewise.
(bitint_large_huge::finish_arith_overflow): Likewise.
Add nelts argument.
(bitint_large_huge::lower_addsub_overflow): Handle bitint_big_endian.
Adjust finish_arith_overflow caller.
(bitint_large_huge::lower_mul_overflow): Likewise.
(bitint_large_huge::lower_bit_query): Handle bitint_big_endian.
(bitint_large_huge::lower_stmt): Likewise.
(build_bitint_stmt_ssa_conflicts): Likewise.
(gimple_lower_bitint): Likewise.
* gcc.dg/torture/bitint-78.c: New test.
* gcc.dg/torture/bitint-79.c: New test.
* gcc.dg/torture/bitint-80.c: New test.
* gcc.dg/torture/bitint-81.c: New test.
|
|
The ICE in PR120276 resulted from a comparison of VNx4QI and V8QI using
partial_subreg_p in the function copy_value during the RTL pass
regcprop, failing the assertion in
inline bool
partial_subreg_p (machine_mode outermode, machine_mode innermode)
{
/* Modes involved in a subreg must be ordered. In particular, we must
always know at compile time whether the subreg is paradoxical. */
poly_int64 outer_prec = GET_MODE_PRECISION (outermode);
poly_int64 inner_prec = GET_MODE_PRECISION (innermode);
gcc_checking_assert (ordered_p (outer_prec, inner_prec));
return maybe_lt (outer_prec, inner_prec);
}
Returning from the function if the modes are not ordered before reaching
the call to partial_subreg_p resolves the ICE and passes bootstrap and
testing without regression.
OK for mainline?
Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
gcc/
PR middle-end/120276
* regcprop.cc (copy_value): Return in case of unordered modes.
gcc/testsuite/
PR middle-end/120276
* gcc.dg/torture/pr120276.c: New test.
|
|
This patch adds trigonometric pi-based functions as gcc builtins: acospi, asinpi, atan2pi,
atanpi, cospi, sinpi, and tanpi. Latest glibc already provides support for
these functions, which we plan to leverage in future gfortran implementations.
The patch includes two test cases to verify both correct code generation and
function definition.
If approved, I suggest committing this foundational change first. Constant
folding for these builtins will be addressed in subsequent patches.
Best regards,
Yuao
From 9a9683d250078ce1bc687797c26ca05a9e91b350 Mon Sep 17 00:00:00 2001
From: Yuao Ma <c8ef@outlook.com>
Date: Wed, 14 May 2025 22:14:00 +0800
Subject: [PATCH] gcc: add trigonometric pi-based functions as gcc builtins
Add trigonometric pi-based functions as GCC builtins: acospi, asinpi, atan2pi,
atanpi, cospi, sinpi, and tanpi. Latest glibc already provides support for
these functions, which we plan to leverage in future gfortran implementations.
The patch includes two test cases to verify both correct code generation and
function definition.
If approved, I suggest committing this foundational change first. Constant
folding for these builtins will be addressed in subsequent patches.
gcc/ChangeLog:
* builtins.def (TRIG_TYPE): New.
(BUILT_IN_ACOSPI): New.
(BUILT_IN_ACOSPIF): New.
(BUILT_IN_ACOSPIL): New.
(BUILT_IN_ASINPI): New.
(BUILT_IN_ASINPIF): New.
(BUILT_IN_ASINPIL): New.
(BUILT_IN_ATANPI): New.
(BUILT_IN_ATANPIF): New.
(BUILT_IN_ATANPIL): New.
(BUILT_IN_COSPI): New.
(BUILT_IN_COSPIF): New.
(BUILT_IN_COSPIL): New.
(BUILT_IN_SINPI): New.
(BUILT_IN_SINPIF): New.
(BUILT_IN_SINPIL): New.
(BUILT_IN_TANPI): New.
(BUILT_IN_TANPIF): New.
(BUILT_IN_TANPIL): New.
(TRIG2_TYPE): New.
(BUILT_IN_ATAN2PI): New.
(BUILT_IN_ATAN2PIF): New.
(BUILT_IN_ATAN2PIL): New.
gcc/testsuite/ChangeLog:
* gcc.dg/builtins-1.c: Builtin codegen test.
* gcc.dg/c23-builtins-1.c: Builtin signature test.
|
|
Since this optimization now walks the vops, it is better to only
do it in forwprop rather than in all the time in fold_stmt.
The next patch will add the limit to the alias walk.
gcc/ChangeLog:
* gimple-fold.cc (optimize_memcpy_to_memset): Move to
tree-ssa-forwprop.cc.
(gimple_fold_builtin_memory_op): Remove call to
optimize_memcpy_to_memset.
(fold_stmt_1): Likewise.
* tree-ssa-forwprop.cc (optimize_memcpy_to_memset): Move from
gimple-fold.cc.
(simplify_builtin_call): Try to optimize memcpy/memset.
(pass_forwprop::execute): Try to optimize memcpy like assignment
from a previous memset.
gcc/testsuite/ChangeLog:
* gcc.dg/pr78408-1.c: Update scan to forwprop1 only.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
|
|
Any known bits from the LHS range can be used to specify known bits in
the non-mask operand.
PR tree-optimization/116546
gcc/
* range-op.cc (operator_bitwise_and::op1_range): Utilize bitmask
from the LHS to improve op1's bitmask.
gcc/testsuite/
* gcc.dg/pr116546.c: New.
|
|
In various situations a cast that is ultimately unreahcable may produce
an UNDEFINED result, and we can't check the bounds in this case.
PR tree-optimization/120277
gcc/
* range-op-ptr.cc (operator_cast::fold_range): Check if the cast
if UNDEFINED before setting bounds.
gcc/testsuite/
* gcc.dg/pr120277.c: New.
|
|
This patch fixes (hopefully the) one remaining place where gimple SRA
was still creating a load into const aggregates. It occurs when there
is a replacement for a load but that replacement is not type
compatible - typically because it is a single field structure.
I have used testcases from duplicates because the original test-case
no longer reproduces for me.
gcc/ChangeLog:
2025-05-13 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/111873
* tree-sra.cc (sra_modify_expr): When processing a load which has
a type-incompatible replacement, do not store the contents of the
replacement into the original aggregate when that aggregate is
const.
gcc/testsuite/ChangeLog:
2025-05-13 Martin Jambor <mjambor@suse.cz>
* gcc.dg/ipa/pr120044-1.c: New test.
* gcc.dg/ipa/pr120044-2.c: Likewise.
* gcc.dg/tree-ssa/pr114864.c: Likewise.
|
|
Add barebones support for
* diagnostic metadata rules
* quoted source
* generated patches
* execution paths
gcc/ChangeLog:
PR other/116792
* diagnostic-format-html.cc: Include "diagnostic-format-text.h",
"pretty-print-urlifier.h" and "edit-context.h".
(html_builder::html_builder): Fix indentation in decl.
(html_builder::make_element_for_diagnostic): Split out metadata
code into make_element_for_metadata. Call
make_element_for_source, make_element_for_path, and
make_element_for_patch.
(html_builder::make_element_for_source): New.
(html_builder::make_element_for_path): New.
(html_builder::make_element_for_patch): New.
(html_builder::make_metadata_element): New.
(html_builder::make_element_for_metadata): New.
(html_output_format::get_builder): New.
(selftest::test_html_diagnostic_context::get_builder): New.
(selftest::test_simple_log): Update test to print a quoted string,
and verify that it uses a "gcc-quoted-text" span.
(selftest::test_metadata): New.
(selftest::diagnostic_format_html_cc_tests): Call it.
gcc/testsuite/ChangeLog:
PR other/116792
* gcc.dg/html-output/missing-semicolon.py: Verify that we don't
have an empty "gcc-annotated-source" and we do have a
"gcc-generated-patch".
* gcc.dg/plugin/diagnostic-test-metadata-html.c: New test.
* gcc.dg/plugin/diagnostic-test-metadata-html.py: New test script.
* gcc.dg/plugin/diagnostic-test-paths-2.c: Add
"-fdiagnostics-add-output=experimental-html" to options. Add
invocation of diagnostic-test-paths-2.py.
* gcc.dg/plugin/diagnostic-test-paths-2.py: New test script.
* gcc.dg/plugin/plugin.exp (plugin_test_list): Add
diagnostic-test-metadata-html.c.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
When there are trailing 0's in the bitmask, set_range_from_bitmask () removes
the lower positive ranges which do not match the value. This reworks it to
provide the same functionailty for the negative ranges in signed types.
If the lower 4 bits are all 0:
int [-INF, +INF] MASK 0xfffffff0 VALUE 0x0
becomes:
int [-INF, -16][0, 0][16, 2147483632] MASK 0xfffffff0 VALUE 0x0
gcc/
* tree-ssanames.cc (set_bitmask): Use int_range_max for temps.
* value-range.cc (irange::set_range_from_bitmask): Handle all
trailing zero values.
gcc/testsuite/
* gcc.dg/tree-ssa/vrp124.c: New.
|
|
We now inline main_1, confusing the expected number of vectorizations.
PR testsuite/120222
* gcc.dg/tree-ssa/gen-vect-28.c: Use noipa on main_1.
|
|
The PR120089 fix added more PHIs to LOOP_VINFO_EARLY_BREAKS_LIVE_IVS
but not checking that we only add PHIs with a latch argument. The
following adds this missing check.
PR tree-optimization/120211
* tree-vect-stmts.cc (vect_stmt_relevant_p): Only add PHIs
from the loop header to LOOP_VINFO_EARLY_BREAKS_LIVE_IVS.
* gcc.dg/vect/vect-early-break_135-pr120211.c: New testcase.
* gcc.dg/torture/pr120211-1.c: Likewise.
|
|
vectors of DFP [PR119909]
On PowerPC, there is a psabi warning for argument passing of a DFP vector.
We are not expecting this warning and we get a failure due to it.
Adding -Wno-psabi fixes the testcase.
Committed as obvious after a quick test.
gcc/testsuite/ChangeLog:
PR testsuite/119909
* gcc.dg/torture/pr119131-1.c: Add -Wno-psabi.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
|
|
I have mistakenly assumed that switch lowering cannot encounter a switch
with zero clusters. This patch removes the relevant assert and instead
gives up bit-test lowering when this happens.
PR tree-optimization/120080
gcc/ChangeLog:
* tree-switch-conversion.cc (bit_test_cluster::find_bit_tests):
Replace assert with return.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr120080.c: New test.
Signed-off-by: Filip Kastl <fkastl@suse.cz>
|
|
gcc.dg/pr87600.h and gcc.dg/pr89313.c test for __powerpc__ and
__POWERPC__ to choose ppc register names, but ppc-elf defines neither;
it defines __PPC__, so test for that as well.
for gcc/testsuite/ChangeLog
* gcc.dg/pr87600.h (REG1, REG2): Test for __PPC__ as well.
* gcc.dg/pr89313.c (REG): Likewise.
|
|
RTL DSE forms store groups from unique invariant bases but that is
confused when presented with constant addresses where it assigns
one store group per unique address. That causes it to not consider
0x101:QI to alias 0x100:SI. Constant accesses can really alias
to every object, in practice they appear for I/O and for access
to objects fixed via linker scripts for example. So simply avoid
registering a store group for them.
PR rtl-optimization/120182
* dse.cc (canon_address): Constant addresses have no
separate store group.
* gcc.dg/torture/pr120182.c: New testcase.
|
|
The following addresses a too conservative sanity check of SLP nodes
we want to promote external. The issue lies in code generation
for such external which relies on get_later_stmt to figure an
insert location. But get_later_stmt relies on the ability to
totally order stmts, specifically implementation-wise that they
are all from the same BB, which is what is verified at the moment.
The patch changes this to require stmts to be orderable by
dominance queries. For simplicity and seemingly enough for the
testcase in PR119960, this handles the case of two distinct BBs.
PR tree-optimization/119960
* tree-vect-slp.cc (vect_slp_can_convert_to_external):
Handle cases where defs from multiple BBs are ordered
by their dominance relation.
* gcc.dg/vect/bb-slp-pr119960-1.c: New testcase.
|
|
Limit option '-mgeneral-regs-only' to those in supported backends.
Version log:
https://patchwork.sourceware.org/project/gcc/patch/20250508080102.1340059-1-jiawei@iscas.ac.cn/
gcc/testsuite/ChangeLog:
* gcc.dg/pr119160.c: Limit backends.
|