This also implements the proposed resolutions of the tentatively ready
LWG issues 3760, 3761 and 3801 for cartesian_product_view.
I'm not sure how/if we should implement the recommended practice of:
iterator::difference_type should be the smallest signed-integer-like
type that is sufficiently wide to store the product of the maximum
sizes of all underlying ranges if such a type exists
because for e.g.
extern std::vector<int> x, y;
auto v = views::cartesian_product(x, y);
IIUC it'd mean difference_type should be __int128 (on 64-bit systems),
which seems quite wasteful: in practice the size of any cartesian product
probably won't exceed the precision of say ptrdiff_t, and using anything
larger will just incur unnecessary space/time overhead. It's also
probably not worth the complexity to use less precision than ptrdiff_t
(when possible) either. So this patch defines difference_type as
common_type_t<ptrdiff_t, range_difference_t<_First>, range_difference_t<_Vs>...>
which should mean it's least as large as the difference_type of each
underlying range, and at least as large as ptrdiff_t. This patch also
adds assertions to catch any overflow that occurs due to this choice of
difference_type.
libstdc++-v3/ChangeLog:
* include/std/ranges (__maybe_const_t): New alias for
__detail::__maybe_const_t.
(__detail::__cartesian_product_is_random_access): Define.
(__detail::__cartesian_product_common_arg): Define.
(__detail::__cartesian_product_is_bidirectional): Define.
(__detail::__cartesian_product_is_common): Define.
(__detail::__cartesian_product_is_sized): Define.
(__detail::__cartesian_is_sized_sentinel): Define.
(__detail::__cartesian_common_arg_end): Define.
(cartesian_product_view): Define.
(cartesian_product_view::_Iterator): Define.
(views::__detail::__can_cartesian_product_view): Define.
(views::_CartesianProduct, views::cartesian_product): Define.
* testsuite/std/ranges/cartesian_product/1.cc: New test.
I found some additional cases when working on the demangler. May as
well check their mangling.
gcc/testsuite/
* g++.dg/abi/lambda-tpl1.h: Add more cases.
* g++.dg/abi/lambda-tpl1-17.C: Add checks.
* g++.dg/abi/lambda-tpl1-18.C: Likewise.
* g++.dg/abi/lambda-tpl1-18vs17.C: Likewise.
The previous commit introduced a regression as some Ada tests end up passing
NULL as the filename to remap_filename. Handle this as before to fix them.
gcc/
* file-prefix-map.cc (remap_filename): Handle NULL filenames.
The following patch updates from fast_float trunk. That way
it grabs two of the 4 LOCAL_PATCHES, some smaller tweaks, to_extended
cleanups and most importantly fix for the incorrect rounding case,
PR107468 aka https://github.com/fastfloat/fast_float/issues/149
Using std::fegetround showed in benchmarks too slow, so instead of
doing that the patch limits the fast path where it uses floating
point multiplication rather than integral to cases where we can
prove there will be no rounding (the multiplication will be exact, not
just that the two multiplication or division operation arguments are
exactly representable).
2022-11-07 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/107468
* src/c++17/fast_float/MERGE: Adjust for merge from upstream.
* src/c++17/fast_float/LOCAL_PATCHES: Remove commits that were
upstreamed.
* src/c++17/fast_float/README.md: Merge from fast_float
662497742fea7055f0e0ee27e5a7ddc382c2c38e commit.
* src/c++17/fast_float/fast_float.h: Likewise.
* testsuite/20_util/from_chars/pr107468.cc: New test.
The following patch adds std::{to,from}_chars support for std::float128_t
on glibc 2.26+ for {i?86,x86_64,ia64,powerpc64le}-linux.
When long double is already IEEE quad, previous changes already handle
it by using long double overloads in _Float128 overloads.
The powerpc64le case (with explicit or implicit -mabi=ibmlongdouble)
is handled by using the __float128/__ieee128 entrypoints which are
already in the library and used for -mabi=ieeelongdouble.
For i?86, x86_64 and ia64 this patch adds new library entrypoints,
mostly by enabling the code that was already there for powerpc64le-linux.
Those use __float128 or __ieee128, the patch uses _Float128 for the
exported overloads and internally as template parameter. While
powerpc64le-linux uses __sprintfieee128 and __strtoieee128,
for _Float128 the patch uses the glibc 2.26 strfromf128 and strtof128
APIs. So that one can build gcc against older glibc and then compile
user programs on newer glibc, the patch uses weak references unless
gcc is compiled against glibc 2.26+. strfromf128 unfortunately can't
handle %.0Lf and %.*Le, %.*Lf, %.*Lg format strings sprintf/__sprintfieee128
use, we need to remove the L from those and replace * with actually
directly printing the precision into the format string (i.e. it can
handle %.0f and %.27f (floating point type is implied from the function
name)).
Unlike the std::{,b}float16_t support, this one actually exports APIs
with std::float128_t aka _Float128 in the mangled name, because no
standard format is superset of it. On the other side, e.g. on i?86/x86_64
it doesn't have restrictions like for _Float16/__bf16 which ISAs need
to be enabled in order to use it.
The denorm_min case in the testcase is temporarily commented out because
of the ERANGE subnormal issue Patrick posted patch for.
2022-11-07 Jakub Jelinek <jakub@redhat.com>
* include/std/charconv (from_chars, to_chars): Add _Float128
overfloads if _GLIBCXX_HAVE_FLOAT128_MATH is defined.
* config/abi/pre/gnu.ver (GLIBCXX_3.4.31): Export
_ZSt8to_charsPcS_DF128_, _ZSt8to_charsPcS_DF128_St12chars_format,
_ZSt8to_charsPcS_DF128_St12chars_formati and
_ZSt10from_charsPKcS0_RDF128_St12chars_format.
* src/c++17/floating_from_chars.cc (USE_STRTOF128_FOR_FROM_CHARS):
Define if needed.
(__strtof128): Declare.
(from_chars_impl): Handle _Float128.
(from_chars): New _Float128 overload if USE_STRTOF128_FOR_FROM_CHARS
is define.
* src/c++17/floating_to_chars.cc (__strfromf128): Declare.
(FLOAT128_TO_CHARS): Define even when _Float128 is supported and
wider than long double.
(F128_type): Use _Float128 for that case.
(floating_type_traits): Specialize for F128_type rather than
__float128.
(sprintf_ld): Add length argument. Handle _Float128.
(__floating_to_chars_shortest, __floating_to_chars_precision):
Pass length to sprintf_ld.
(to_chars): Add _Float128 overloads for the F128_type being
_Float128 cases.
* testsuite/20_util/to_chars/float128_c++23.cc: New test.
The problem here is that we are transforming a division by a power of
2 into a right shift, and using this to shift the maybe nonzero bits.
This gives the wrong result when the number being divided is negative.
In the testcase we are dividing this by 8:
[irange] int [-256, -255] NONZERO 0xffffff01
and coming up with:
[irange] int [-32, -31] NONZERO 0xffffffe0
The maybe nonzero bits are wrong as -31 has the LSB set (0xffffffe1)
whereas the bitmask says the lower 4 bits are off.
PR tree-optimization/107541
gcc/ChangeLog:
* range-op.cc (operator_div::fold_range): Restrict power of 2
optimization to positive numbers.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/pr107541.c: New test.
The check whether reallocation on assignment was required did not handle
kind=4 characters correctly such that there was always a reallocation,
implying issues with pointer addresses and lower bounds. Additionally,
with all deferred strings, the old memory was not freed on reallocation.
And, finally, inside the block which was only executed if string lengths
or bounds or dynamic types changed, was a subcheck of the same, which
was effectively a no op but still confusing and at least added with -O0
extra instructions to the binary.
PR fortran/107508
gcc/fortran/ChangeLog:
* trans-array.cc (gfc_alloc_allocatable_for_assignment): Fix
string-length check, plug memory leak, and avoid generation of
effectively no-op code.
* trans-expr.cc (alloc_scalar_allocatable_for_assignment): Extend
comment; minor cleanup.
gcc/testsuite/ChangeLog:
* gfortran.dg/widechar_11.f90: New test.
When doing the loop unswitching re-org we promised to followup
with improvements on the cost modeling. The following makes sure we
try to unswitch on the most profitable condition first. As most profitable
we pick the condition leading to the edge with the highest profile count.
Note the profile is only applied when picking the first unswitching
opportunity since the profile counts are not updated with earlier
unswitchings in mind. Further opportunities are picked in DFS order.
* tree-ssa-loop-unswitch.cc (unswitch_predicate::count): New.
(unswitch_predicate::unswitch_predicate): Initialize count.
(init_loop_unswitch_info): First collect candidates and
determine the outermost loop to unswitch.
(tree_ssa_unswitch_loops): First perform all guard hoisting,
then perform unswitching on innermost loop predicates.
(find_unswitching_predicates_for_bb): Keep track of the
most profitable predicate to unswitch on.
(tree_unswitch_single_loop): Unswitch given predicate if
not NULL.
gcc/range-op.cc:1752:16: warning: 'wi_fold' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
gcc/range-op.cc:1757:16: warning: 'wi_op_overflows' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
gcc/range-op.cc:1759:16: warning: 'op1_range' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
gcc/range-op.cc:1763:16: warning: 'op2_range' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
gcc/range-op.cc:1928:16: warning: 'wi_fold' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
gcc/range-op.cc:1933:16: warning: 'wi_op_overflows' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
gcc/ChangeLog:
* range-op.cc: Add final override keywords.
Document that gprof won't work on windows with PIE and -no-pie must be
used.
gcc/ada/
* doc/gnat_ugn/gnat_and_program_execution.rst: Mention the needed
-no-pie for windows to use gprof.
* gnat_ugn.texi: Regenerate.
Tune the hash function that combines entity identifiers with source
locations of where those entities are referenced. Previously the source
location was multiplied by 2 ** 7 (i.e. shifted left by 7 bits), then
added to the entity identifier, and finally divided modulo 2 ** 16 (i.e.
masked to only use the lowest 16 bits). This hash routine caused
collisions that could make some tests up to twice slower.
With a large entity number the source location was only contributing few
bits to the hash value. This large entity number might correspond to
entity like Ada.Characters.Latin_1.NUL that occurs thousands of times in
generated code.
gcc/ada/
* lib-xref.adb (Hash): Tune hash function.
Recently added call to In_Pragma_Expression caused a performance
regression. It might require climbing syntax trees of arbitrarily deep
expressions, while previously references within pragmas were detected in
bounded time.
This patch restores the previous efficiency. However, while the original
code only detected references directly within pragma argument
associations, now we also detect references inside aggregates, e.g.
like those in pragma Refined_State.
gcc/ada/
* sem_prag.adb (Non_Significant_Pragma_Reference): Detect
references with aggregates; only assign local variables Id and C
when necessary.
Use named notation in calls to Expand_Composite_Equality.
gcc/ada/
* exp_ch4.adb
(Component_Equality, Expand_Array_Equality)
(Expand_Record_Equality): Use named notation.
Print warning for a user-defined "=" that does not compose
as might be expected (i.e. is ignored for predefined "=" of
a containing record or array type). This warning is enabled by
-gnatw_q; we don't enable it by default because it generates
too many false positives. We also don't enable it via -gnatwa.
gcc/ada/
* exp_ch4.adb
(Expand_Array_Equality): Do not test Ltyp = Rtyp here, because
that is necessarily true. Move assertion thereof to more general
place.
(Expand_Composite_Equality): Pass in Outer_Type, for use in
warnings. Rename Typ to be Comp_Type, to more clearly distinguish
it from Outer_Type. Print warning when appropriate.
* exp_ch4.ads: Minor comment fix.
* errout.ads: There is no such pragma as Warning_As_Pragma --
Warning_As_Error must have been intended. Improve comment for ?x?.
* exp_ch3.adb
(Build_Untagged_Equality): Update comment to be accurate for more
recent versions of Ada.
* sem_case.adb
(Choice_Analysis): Declare user-defined "=" functions as abstract.
* sem_util.ads
(Is_Bounded_String): Give RM reference in comment.
* warnsw.ads, warnsw.adb
(Warn_On_Ignored_Equality): Implement new warning switch -gnatw_q.
* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
Document new warning switch.
* gnat_ugn.texi: Regenerate.
Queries that ultimately examine the same field of an AST
node (e.g. Nkind) are visibly more efficient when inlined.
In particular, routines Is_Body_Or_Package_Declaration and Is_Body can
apparently be inlined into a single Nkind membership test.
This patch fixes some of the performance lost with the recent changes,
which increased the number of calls to Is_Body_Or_Package_Declaration
(as it is typically used to prevent AST search from climbing too far).
However, it should be generally beneficial to inline routines like this.
gcc/ada/
* sem_aux.ads (Is_Body): Annotate with Inline.
* sem_util.ads (Is_Body_Or_Package_Declaration): Likewise.
Protect the building of postcondition pragmas in case the
postcondition is not present due to inlining.
gcc/ada/
* freeze.adb
(Build_Inherited_Condition_Pragmas): Do nothing if A_Post is
empty.
The names of imported / exported symbols were not consistent
between the device and the host when compiling for CUDA.
Remove the function Device_Ada_Final_Link_Name as it is no
longer referenced.
gcc/ada/
* bindgen.adb: fixed the way the device init and final symbols are
computed, re-using the normal way these symbols would be computed
with a __device_ prefix. Also fixed the "is null;" procedure on
the host side which are not Ada 95, replaced with a procedure
raising an exception as it should never be called. Remove the
unused function Device_Ada_Final_Link_Name.
Co-authored-by: Steve Baird <baird@adacore.com>
When the binder is invoked with a "-d_c" switch, add an argument to that
switch which is the library name on the device side; so "-d_c" becomes
"-d_c=some_library_name". This does not effect the case where "-d_c" is
specified as a switch for compilation (as opposed to binding). Use this
new piece of information in the code generated by the binder to invoke
elaboration code on the device side from the host side.
gcc/ada/
* opt.ads: Declare new string pointer variable, CUDA_Device_Library_Name.
Modify comments for existing Boolean variable Enable_CUDA_Device_Expansion.
* switch-b.adb: When "-d_c" switch is encountered, check that the next
character is an "'='; use the remaining characters to initialize
Opt.CUDA_Device_Library_Name.
* bindgen.adb: Remove (for now) most support for host-side invocation of
device-side finalization. Make use of the new CUDA_Device_Library_Name
in determining the string used to refer (on the host side) to the
device-side initialization procedure. Declare the placeholder routine
that is named in the CUDA_Execute pragma (and the CUDA_Register_Function
call) as an exported null procedure, rather than as an imported procedure.
It is not clear whether it is really necessary to specify the link-name
for this should-never-be-called subprogram on the host side, but for now it
shouldn't hurt to do so.
Detection of external-vs-internal calls to protected objects relied on
the scope stack. This didn't work when the call appeared in an instance
of generic unit, because instances are analyzed in different context to
where they appear.
gcc/ada/
* exp_ch6.adb (Expand_Protected_Subprogram_Call): Examine scope
tree and not the scope stack.
GNAT normally warns on "return ...;" if the "..." is known to be True or
False, but not when it is a Boolean literal True or False. This patch
also suppresses the warning when the type is derived from Boolean, and
has convention C or Fortran (and therefore True is represented as
"nonzero").
Without this fix, GNAT would give warnings like "False is always False".
gcc/ada/
* sem_warn.adb
(Check_For_Warnings): Remove unnecessary exception handler.
(Warn_On_Known_Condition): Suppress warning when we detect a True
or False that has been turned into a more complex expression
because True is represented as "nonzero". (Note that the complex
expression will subsequently be constant-folded to a Boolean True
or False). Also simplify to always print "condition is always ..."
instead of special-casing object names. The special case was
unhelpful, and indeed wrong when the expression is a literal.
Recently routine Safe_To_Capture_Value was adapted, so that various data
properties like validity/nullness/values are tracked also for
in-parameters. Now a similar routine Safe_To_Capture_In_Parameter_Value,
which was only used to track data nullness, is redundant, so this patch
deconstructs it.
Also the removed routine had at least few problems and limitations, for
example:
1) it only worked for functions and procedures, but not for protected
entries and task types (whose discriminants work very much like
in-parameters)
2) it only worked for subprogram bodies with no spec, because of this
dubious check (here simplified):
if Nkind (Parent (Parent (Current_Scope))) /= N_Subprogram_Body then
return False;
3) it only recognized references within short-circuit operators as
certainly evaluated if they were directly their left hand expression,
e.g.:
X.all and then ...
but not when they were certainly evaluated as part of a bigger
expression on the left hand side, e.g.:
(X.all > 0) and then ...
4) it categorizes parameters with 'Unrestricted_Access attribute as safe
to capture, which is not necessarily wrong, but risky (because the
object becomes aliased).
Routine Safe_To_Capture_Value, which is kept by this patch, seems to
behave better in all those situations, though it has its own problems as
well and ideally should be further scrutinized.
gcc/ada/
* checks.adb (Safe_To_Capture_In_Parameter_Value): Remove.
* sem_util.adb (Safe_To_Capture_Value): Stop search at the current
body.
Subprogram names starting with No_ seem unnecessarily confusing.
Cleanup related to improved detection of references to uninitialized
objects; semantics is unaffected.
gcc/ada/
* sem_warn.adb (Warn_On_In_Out): Remove No_ prefix; flip return
values between True and False; adapt caller.
To check if a node is located in a generic instance we can either look
at Instantiation_Location or at the Instantiation_Depth, but just
looking at the location is simpler and more efficient.
Cleanup related to improved detection of references to uninitialized
objects; semantics is unaffected.
gcc/ada/
* sem_ch13.adb (Add_Call): Just look at Instantiation_Depth.
* sem_ch3.adb (Derive_Subprograms): Likewise.
* sem_warn.adb (Check_References): Remove redundant filtering with
Instantiation_Depth that follows filtering with
Instantiation_Location.
* sinput.adb (Instantiation_Depth): Reuse Instantiation_Location.
Non-modified IN OUT parameters are first collected and then filtered by
examining uses of their enclosing subprograms. In this filtering we
don't need to look again at properties of the formal parameters
themselves.
Cleanup related to improved detection of references to uninitialized
objects; semantics is unaffected.
gcc/ada/
* sem_warn.adb
(No_Warn_On_In_Out): For subprograms we can simply call
Warnings_Off.
(Output_Non_Modified_In_Out_Warnings): Remove repeated
suppression.
Implement Ada 2022 4.3.4(11/5), which rejects box compound delimiter <>
in delta record aggregates, just like another rule rejects it in delta
array aggregates.
gcc/ada/
* sem_aggr.adb (Resolve_Delta_Array_Aggregate): Reject boxes in
delta array aggregates.
Move routine Enclosing_Declaration_Or_Statement from body of Sem_Res to spec
of Sem_Util, so it can be reused. In particular, GNATprove needs this
functionality to climb from an arbitrary subexpression with target_name (@)
to the enclosing assignment statement. Behaviour of the compiler is
unaffected.
gcc/ada/
* sem_res.adb (Enclosing_Declaration_Or_Statement): Moved to
Sem_Util.
* sem_util.ads (Enclosing_Declaration_Or_Statement): Moved from
Sem_Res.
* sem_util.adb (Enclosing_Declaration_Or_Statement): Likewise.
When experimentally enabling frontend inlining by default, the
unnecessary call to Comes_From_Predefined_Lib_Unit in Resolve appears to
be a performance bottleneck (most likely this call is expensive because
it involves a loop over the currently inlined subprograms).
Code cleanup; semantics is unaffected.
gcc/ada/
* sem_res.adb (Resolve): Only call Comes_From_Predefined_Lib_Unit
when its result might be needed.
Code cleanup related to fixing visibility of actual parameters in
inlining-for-proof in GNATprove mode; semantics is unaffected.
gcc/ada/
* sem_ch12.adb (Check_Generic_Actuals): Remove redundant parens;
refactor an excessive if-statement; remove repeated call to Node.
Improve location of the comment about a special case for GNATprove mode.
gcc/ada/
* inline.adb (Establish_Actual_Mapping_For_Inlined_Call): Move
comment next to a condition that it describes.
In some cases, a Put_Image aspect specification for a scalar type was not
correctly inherited by a descendant of that type.
gcc/ada/
* exp_put_image.adb
(Image_Should_Call_Put_Image): Correctly handle the case of an
inherited Put_Image aspect specification for a scalar type.
A recent patch removed two rewritings, where we kept the operator node
but replaced its operands. This patch removes explicit setting of the
operands; instead, the operator is already created together with its
operands, which seems a bit safer and more consistent with how we
typically create operator nodes.
It is a cleanup only; semantics is unaffected.
gcc/ada/
* exp_ch4.adb
(Expand_Modular_Addition): Rewrite using Make_XXX calls.
(Expand_Modular_Op): Likewise.
(Expand_Modular_Subtraction): Likewise.
* exp_imgv.adb
(Expand_User_Defined_Enumeration_Image): Likewise.
This patch removes handling of references to unset objects that relied
on Original_Node. This handling was only needed because of rewriting
that reused operator nodes, for example, when an array inequality like:
A < B
was rewritten into:
System.Compare_Array_Unsigned_8.Compare_Array_U8
(A'Address, B'Address, A'Length, B'Length) < 0
by keeping the node for operator "<" and only substituting its operands.
It seems safer to simply create an new operator node when rewriting and
not rely on Original_Node afterwards.
Cleanup related to improved detection uninitialized objects.
gcc/ada/
* checks.adb (Apply_Arithmetic_Overflow_Strict): Rewrite using a
newly created operator node.
* exp_ch4.adb (Expand_Array_Comparison): Likewise.
* exp_ch6.adb (Add_Call_By_Copy_Code): Rewriting actual parameter
using its own location and not the location of the subprogram
call.
* sem_warn.adb (Check_References): Looping with Original_Node is
no longer needed.
Pragma Obsolescent appearing before declaration was putting the
Obsolescent flag on the Standard package, which is certainly wrong. The
problem was that we relied on the Find_Lib_Unit_Name routine without
sanitizing the pragma placement with Check_Valid_Library_Unit_Pragma.
Part of cleaning up the warnings machinery to better handle references
to unset objects.
gcc/ada/
* sem_prag.adb (Analyze_Pragma [Pragma_Obsolescent]): Reject
misplaced pragma.
Fix minor inconsistency in tags of warnings about obsolescent entities.
Part of cleaning up the warnings machinery to better handle references
to unset objects.
gcc/ada/
* sem_warn.adb (Output_Obsolescent_Entity_Warnings): Tag warnings
about obsolescent functions just like we tag similar warnings for
packages and procedures.
Attributes 'Input and 'Read are similar, but only the 'Read denotes a
subprogram with parameter of mode OUT where operand validity checks need
to be suppressed.
Cleanup related to fix for attributes 'Has_Same_Storage and
'Overlaps_Storage.
gcc/ada/
* exp_attr.adb (Expand_N_Attribute_Reference): Remove useless
skipping for attribute Input.
As the test case in PR107412 shows, we can fold IFN .LEN_{LOAD,
STORE} into normal vector load/store if the given length is known
to be equal to the length of the whole vector. It would help to
improve overall cycles as normally the latency of vector access
with length in bytes is bigger than normal vector access, and it
also saves the preparation for length if constant length can not
be encoded into instruction (such as on power).
PR tree-optimization/107412
gcc/ChangeLog:
* gimple-fold.cc (gimple_fold_mask_load_store_mem_ref): Rename to ...
(gimple_fold_partial_load_store_mem_ref): ... this, add one parameter
mask_p indicating it's for mask or length, and add some handlings for
IFN LEN_{LOAD,STORE}.
(gimple_fold_mask_load): Rename to ...
(gimple_fold_partial_load): ... this, add one parameter mask_p.
(gimple_fold_mask_store): Rename to ...
(gimple_fold_partial_store): ... this, add one parameter mask_p.
(gimple_fold_call): Add the handlings for IFN LEN_{LOAD,STORE},
and adjust calls on gimple_fold_mask_load_store_mem_ref to
gimple_fold_partial_load_store_mem_ref.
gcc/testsuite/ChangeLog:
* gcc.target/powerpc/pr107412.c: New test.
* gcc.target/powerpc/p9-vec-length-epil-8.c: Adjust scan times for
folded LEN_LOAD.
Add flag -mprefer-remote-atomic to control whether to generate raoint
insn for atomic operations.
gcc/ChangeLog:
* config/i386/i386.opt:Add -mprefer-remote-atomic.
* config/i386/sync.md (atomic_<plus_logic><mode>):
New define_expand.
(atomic_add<mode>): Rename to below one.
(atomic_add<mode>_1): To this.
(atomic_<logic><mode>): Ditto.
(atomic_<logic><mode>_1): Ditto.
* doc/invoke.texi: Add -mprefer-remote-atomic.
gcc/testsuite/ChangeLog:
* gcc.target/i386/raoint-atomic-fetch.c: New test.
Use operand[2] mode in can_vec_set_var_idx_p when checking vec_set_optab.
This change allows non-VOID index operand in vec_set_optab.
2022-11-06 Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog:
* optabs.cc (can_vec_set_var_idx_p): Use operand[2]
mode when checking vec_set_optab.