aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2023-05-25ada: Tune warning about assignment just before a raise statementPiotr Trojanek3-6/+5
Tune warning about a possibly ineffective assignment to a formal parameter that happens just before a raise statement. The warning is now emitted for parameters of all by-copy types and not just of scalar types (this gives more warnings), but is suppressed for aliased parameters (this removes some spurious warnings). gcc/ada/ * sem_ch11.adb (Analyze_Raise_Expression): Tune warning condition. * libgnat/g-dirope.ads (Open): Remove a potentially inaccurate comment. * libgnat/g-dirope.adb (Open): Remove a potentially useless assignment; the Dir output parameter should be assigned a null value anyway by the preceding call to Free.
2023-05-25ada: Accept aliased parameters in Exceptional_CasesPiotr Trojanek1-1/+2
Aliased parameters, just like parameters by-reference types, can safely appear in consequences of Exceptional_Cases aspect. gcc/ada/ * sem_res.adb (Resolve_Entity_Name): Allow aliased parameters; tune error message.
2023-05-25ada: Fix incorrect handling of Aggregate aspectMarc Poulhiès1-2/+8
This change fixes 2 incorrect handlings of the aspect. The arguments are now correctly resolved and the aspect is rejected on non array types. gcc/ada/ * sem_ch13.adb (Analyze_One_Aspect): Mark Aggregate aspect as needing delayed resolution and reject the aspect on non-array type.
2023-05-25ada: Fix obsolete comment in Sinfo.UtilsBob Duff1-1/+1
...caused by moving code here from Atree. gcc/ada/ * sinfo-utils.adb: Update comment to refer to New_Node_Debugging_Output.
2023-05-25ada: Fix SPARK context not restored when Load_Unit is failingMarc Poulhiès2-12/+31
When Load_Unit fails to find the unit or encounters an error, the Load_Fail procedure is called and an exception is raised, skipping the restoration of the SPARK/Ghost context stored on procedure entry. gcc/ada/ * rtsfind.adb (Load_RTU.Restore_SPARK_Context): New. (Load_RTU): Use Restore_SPARK_Context on all exit paths. * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Initialize local variable to Empty.
2023-05-25ada: Restrict use of formal parameters within exceptional casesPiotr Trojanek2-0/+69
Restrict references to formal parameters within the new SPARK aspect Exceptional_Cases and allow occurrences of 'Old in this aspect. gcc/ada/ * sem_attr.adb (Analyze_Attribute_Old_Result): Allow uses of 'Old and 'Result within the new aspect. * sem_res.adb (Within_Exceptional_Cases_Consequence): New utility routine. (Resolve_Entity_Name): Restrict use of formal parameters within the new aspect.
2023-05-25RISC-V: Remove FRM_REGNUM dependency for rtx conversionsJuzhe-Zhong1-9/+3
According to RVV ISA: The conversions use the dynamic rounding mode in frm, except for the rtz variants, which round towards zero. So rtz conversion patterns should not have FRM dependency. We can't support mode switching for FRM yet since rvv intrinsic doc is not updated but I think this patch is correct. gcc/ChangeLog: * config/riscv/vector.md: Remove FRM_REGNUM dependency in rtz instructions. Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai>
2023-05-25testsuite, analyzer: Fix testcases with fcloseChristophe Lyon2-0/+4
The gcc.dg/analyzer/data-model-4.c and gcc.dg/analyzer/torture/conftest-1.c fail with recent glibc headers and succeed with older headers. The new error message is: warning: use of possibly-NULL 'f' where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument] Like similar previous fixes in this area, this patch updates the testcase so that this warning isn't reported. 2023-05-23 Christophe Lyon <christophe.lyon@linaro.org> gcc/testsuite/ * gcc.dg/analyzer/data-model-4.c: Exit if fopen returns NULL. * gcc.dg/analyzer/torture/conftest-1.c: Likewise.
2023-05-25Stream out NANs correctly.Aldy Hernandez3-9/+25
NANs don't have bounds, so there's no need to stream them out. gcc/ChangeLog: * data-streamer-in.cc (streamer_read_value_range): Handle NANs. * data-streamer-out.cc (streamer_write_vrange): Same. * value-range.h (class vrange): Make streamer_write_vrange a friend.
2023-05-25Disallow setting of NANs in frange setter unless setting trees.Aldy Hernandez2-11/+11
frange::set() is confusing in that we can set a NAN by specifying a bound of +-NAN, even though we tecnically disallow NANs in the setter because the kind can never be VR_NAN. This is a wart for get_tree_range(), which builds a range out of a tree from the source, to work correctly. It's ugly, and it showed its limitation while implementing LTO streaming of ranges. This patch disallows passing NAN bounds in frange::set() and fixes get_tree_range. gcc/ChangeLog: * value-query.cc (range_query::get_tree_range): Set NAN directly if necessary. * value-range.cc (frange::set): Assert that bounds are not NAN.
2023-05-25Hash known NANs correctly for franges.Aldy Hernandez1-7/+7
We're ICEing when trying to hash a known NAN. This is unnoticeable because the only user would be IPA, and even so, it currently doesn't handle floats. However, handling floats is a flip of a switch, so it's best to handle them already. gcc/ChangeLog: * value-range.cc (add_vrange): Handle known NANs.
2023-05-25Add an frange::set_nan() variant that takes a nan_state.Aldy Hernandez1-15/+17
Generalize frange::set_nan() to take a nan_state and make current set_nan() methods syntactic sugar. This is in preparation for better streaming of NANs for LTO/IPA. gcc/ChangeLog: * value-range.h (frange::set_nan): New.
2023-05-24[PR100106] Reject unaligned subregs when strict alignment is requiredAlexandre Oliva2-0/+19
The testcase for pr100106, compiled with optimization for 32-bit powerpc -mcpu=604 with -mstrict-align expands the initialization of a union from a float _Complex value into a load from an SCmode constant pool entry, aligned to 4 bytes, into a DImode pseudo, requiring 8-byte alignment. The patch that introduced the testcase modified simplify_subreg to avoid changing the MEM to outermode, but simplify_gen_subreg still creates a SUBREG or a MEM that would require stricter alignment than MEM's, and lra_constraints appears to get confused by that, repeatedly creating unsatisfiable reloads for the SUBREG until it exceeds the insn count. Avoiding the unaligned SUBREG, expand splits the DImode dest into SUBREGs and loads each SImode word of the constant pool with the proper alignment. for gcc/ChangeLog PR target/100106 * emit-rtl.cc (validate_subreg): Reject a SUBREG of a MEM that requires stricter alignment than MEM's. for gcc/testsuite/ChangeLog PR target/100106 * gcc.target/powerpc/pr100106-sa.c: New.
2023-05-24[testsuite] require profiling for -pgAlexandre Oliva2-0/+2
Fix two tests that use -pg but don't declare their requirement for profiling support. for gcc/testsuite/ChangeLog * gcc.target/i386/mcount_pic.c: Add dg-require-profiling. * gcc.target/i386/pr104447.c: Likewise.
2023-05-24[testsuite] require pthread for openmpAlexandre Oliva1-0/+2
Fix test that uses -fopenmp without declaring requirement for pthread support. for gcc/testsuite/ChangeLog * g++.dg/pr80481.C: Add explicit pthread requirement.
2023-05-24[testsuite] require pic for pr103074.cAlexandre Oliva1-0/+1
Fix test that uses -fPIC without stating the requirement for PIC support. for gcc/testsuite/ChangeLog * gcc.target/i386/pr103074.c: Require fpic support.
2023-05-24[testsuite] tsvc: skip include malloc.h when unavailableAlexandre Oliva1-1/+4
tsvc tests all fail on systems that don't offer a malloc.h, other than those that explicitly rule that out. Use the preprocessor to test for malloc.h's availability. tsvc.h also expects a definition for struct timeval, but it doesn't include sys/time.h. Add a conditional include thereof. for gcc/testsuite/ChangeLog * gcc.dg/vect/tsvc/tsvc.h: Test for and conditionally include malloc.h and sys/time.h.
2023-05-24[testsuite] [x86] cope with --enable-frame-pointerAlexandre Oliva13-0/+26
Various x86 tests fail if the toolchain is configured with --enable-frame-pointer, because the unexpected extra insns mess with the expected asm counts. Add -fomit-frame-pointer so that they can still pass. for gcc/testsuite/ChangeLog * gcc.target/i386/pieces-memcpy-7.c: Add -fomit-frame-pointer. * gcc.target/i386/pieces-memcpy-8.c: Likewise. * gcc.target/i386/pieces-memcpy-9.c: Likewise. * gcc.target/i386/pieces-memset-1.c: Likewise. * gcc.target/i386/pieces-memset-36.c: Likewise. * gcc.target/i386/pieces-memset-4.c: Likewise. * gcc.target/i386/pieces-memset-40.c: Likewise. * gcc.target/i386/pieces-memset-41.c: Likewise. * gcc.target/i386/pieces-memset-7.c: Likewise. * gcc.target/i386/pieces-memset-8.c: Likewise. * gcc.target/i386/pieces-memset-9.c: Likewise. * gcc.target/i386/pr102230.c: Likewise. * gcc.target/i386/pr78103-2.c: Likewise.
2023-05-25Daily bump.GCC Administrator5-1/+466
2023-05-24Gimple range PHI analyzer and testcasesAndrew MacLeod8-1/+699
Provide a PHI analyzer framework to provive better initial values for PHI nodes which formk groups with initial values and single statements which modify the PHI values in some predicatable way. PR tree-optimization/107822 PR tree-optimization/107986 gcc/ * Makefile.in (OBJS): Add gimple-range-phi.o. * gimple-range-cache.h (ranger_cache::m_estimate): New phi_analyzer pointer member. * gimple-range-fold.cc (fold_using_range::range_of_phi): Use phi_analyzer if no loop info is available. * gimple-range-phi.cc: New file. * gimple-range-phi.h: New file. * tree-vrp.cc (execute_ranger_vrp): Utililze a phi_analyzer. gcc/testsuite/ * gcc.dg/pr107822.c: New. * gcc.dg/pr107986-1.c: New.
2023-05-24Provide relation queries for a stmt.Andrew MacLeod2-15/+124
Allow fur_list and fold_stmt to be provided a range_query rather than always defaultsing to NULL (which becomes a global query). Also provide a fold_relations () routine which can provide a range_trio for an arbitrary statement using any range_query * gimple-range-fold.cc (fur_list::fur_list): Add range_query param to contructors. (fold_range): Add range_query parameter. (fur_relation::fur_relation): New. (fur_relation::trio): New. (fur_relation::register_relation): New. (fold_relations): New. * gimple-range-fold.h (fold_range): Adjust prototypes. (fold_relations): New.
2023-05-24Make ssa_cache a range_query.Andrew MacLeod4-1/+27
By providing range_of_expr as a range_query, we can fold and do other interesting things using values from the global table. Make ranger's knonw globals available via const_query. * gimple-range-cache.cc (ssa_cache::range_of_expr): New. * gimple-range-cache.h (class ssa_cache): Inherit from range_query. (ranger_cache::const_query): New. * gimple-range.cc (gimple_ranger::const_query): New. * gimple-range.h (gimple_ranger::const_query): New prototype.
2023-05-24Make ssa_cache and ssa_lazy_cache virtual.Andrew MacLeod2-39/+41
Making them virtual allows us to interchangebly use the caches. * gimple-range-cache.cc (ssa_cache::dump): Use get_range. (ssa_cache::dump_range_query): Delete. (ssa_lazy_cache::dump_range_query): Delete. (ssa_lazy_cache::get_range): Move from header file. (ssa_lazy_cache::clear_range): ditto. (ssa_lazy_cache::clear): Ditto. * gimple-range-cache.h (class ssa_cache): Virtualize. (class ssa_lazy_cache): Inherit and virtualize.
2023-05-24Fortran: reject bad DIM argument of SIZE intrinsic in simplification [PR104350]Harald Anlauf2-1/+30
gcc/fortran/ChangeLog: PR fortran/104350 * simplify.cc (simplify_size): Reject DIM argument of intrinsic SIZE with error when out of valid range. gcc/testsuite/ChangeLog: PR fortran/104350 * gfortran.dg/size_dim_2.f90: New test.
2023-05-24Fortran: checking and simplification of RESHAPE intrinsic [PR103794]Harald Anlauf6-6/+77
gcc/fortran/ChangeLog: PR fortran/103794 * check.cc (gfc_check_reshape): Expand constant arguments SHAPE and ORDER before checking. * gfortran.h (gfc_is_constant_array_expr): Add prototype. * iresolve.cc (gfc_resolve_reshape): Expand constant argument SHAPE. * simplify.cc (is_constant_array_expr): If array is determined to be constant, expand small array constructors if needed. (gfc_is_constant_array_expr): Wrapper for is_constant_array_expr. (gfc_simplify_reshape): Fix check for insufficient elements in SOURCE when no padding specified. gcc/testsuite/ChangeLog: PR fortran/103794 * gfortran.dg/reshape_10.f90: New test. * gfortran.dg/reshape_11.f90: New test.
2023-05-24Remove deprecated vrange::kind().Aldy Hernandez1-3/+0
gcc/ChangeLog: * value-range.h (vrange::kind): Remove.
2023-05-24PR middle-end/109840: Preserve popcount/parity type in match.pd.Roger Sayle3-10/+67
PR middle-end/109840 is a regression introduced by my recent patch to fold popcount(bswap(x)) as popcount(x). When the bswap and the popcount have the same precision, everything works fine, but this optimization also allowed a zero-extension between the two. The oversight is that we need to be strict with type conversions, both to avoid accidentally changing the argument type to popcount, and also to reflect the effects of argument/return-value promotion in the call to bswap, so this zero extension needs to be preserved/explicit in the optimized form. Interestingly, match.pd should (in theory) be able to narrow calls to popcount and parity, removing a zero-extension from its argument, but that is an independent optimization, that needs to check IFN_ support. Many thanks to Andrew Pinski for his help/fixes with these transformations. 2023-05-24 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog PR middle-end/109840 * match.pd <popcount optimizations>: Preserve zero-extension when optimizing popcount((T)bswap(x)) and popcount((T)rotate(x,y)) as popcount((T)x), so the popcount's argument keeps the same type. <parity optimizations>: Likewise preserve extensions when simplifying parity((T)bswap(x)) and parity((T)rotate(x,y)) as parity((T)x), so that the parity's argument type is the same. gcc/testsuite/ChangeLog PR middle-end/109840 * gcc.dg/fold-parity-8.c: New test. * gcc.dg/fold-popcount-11.c: Likewise.
2023-05-24Provide an API for ipa_vr.Aldy Hernandez13-95/+136
This patch encapsulates the ipa_vr internals into an API. It also makes it type agnostic, in preparation for upcoming changes to IPA. Interestingly, there's a 0.44% improvement to IPA-cp, which I'm sure we'll soak up with future changes in this area :). gcc/ChangeLog: * ipa-cp.cc (ipa_value_range_from_jfunc): Use new ipa_vr API. (ipcp_store_vr_results): Same. * ipa-prop.cc (ipa_vr::ipa_vr): New. (ipa_vr::get_vrange): New. (ipa_vr::set_unknown): New. (ipa_vr::streamer_read): New. (ipa_vr::streamer_write): New. (write_ipcp_transformation_info): Use new ipa_vr API. (read_ipcp_transformation_info): Same. (ipa_vr::nonzero_p): Delete. (ipcp_update_vr): Use new ipa_vr API. * ipa-prop.h (class ipa_vr): Provide an API and hide internals. * ipa-sra.cc (zap_useless_ipcp_results): Use new ipa_vr API. gcc/testsuite/ChangeLog: * gcc.dg/ipa/pr78121.c: Adjust for vrange::dump use. * gcc.dg/ipa/vrp1.c: Same. * gcc.dg/ipa/vrp2.c: Same. * gcc.dg/ipa/vrp3.c: Same. * gcc.dg/ipa/vrp4.c: Same. * gcc.dg/ipa/vrp5.c: Same. * gcc.dg/ipa/vrp6.c: Same. * gcc.dg/ipa/vrp7.c: Same. * gcc.dg/ipa/vrp8.c: Same.
2023-05-24Fix sprintf length warningJan-Benedict Glaw1-1/+1
One of the supplied argument strings is unneccesarily long (c-sky, using basically the same code, fixed it to a shorter length) and this fixes overflow warnings, as GCC fails to deduce that the full 256 bytes for load_op[] are not used at all. gcc/ChangeLog: * config/mcore/mcore.cc (output_inline_const) Make buffer smaller to silence overflow warnings later on.
2023-05-24i386: Add v<any_shift:insn>v4qi3 expanderUros Bizjak7-19/+85
Also, move v<any_shift:insn>v8qi3 expander to a better place and enable it with TARGET_MMX_WITH_SSE. Remove handling of V8QImode from ix86_expand_vecop_qihi2 since all partial QI->HI vector modes expand via ix86_expand_vecop_qihi_partial. gcc/ChangeLog: * config/i386/i386-expand.cc (ix86_expand_vecop_qihi2): Remove handling of V8QImode. * config/i386/mmx.md (v<insn>v8qi3): Move from sse.md. Call ix86_expand_vecop_qihi_partial. Enable for TARGET_MMX_WITH_SSE. (v<insn>v4qi3): Ditto. * config/i386/sse.md (v<insn>v8qi3): Remove. gcc/testsuite/ChangeLog: * gcc.target/i386/vect-shiftv4qi.c (dg-options): Remove -ftree-vectorize. * gcc.target/i386/vect-shiftv8qi.c (dg-options): Ditto. * gcc.target/i386/vect-vshiftv4qi.c: New test. * gcc.target/i386/vect-vshiftv8qi.c: New test.
2023-05-24aarch64: PR target/99195 Annotate vector shift patterns for vec-concat-zeroKyrylo Tkachov4-12/+61
Continuing the series of straightforward annotations, this one handles the normal (not widening or narrowing) vector shifts. Tests included. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. gcc/ChangeLog: PR target/99195 * config/aarch64/aarch64-simd.md (aarch64_simd_lshr<mode>): Rename to... (aarch64_simd_lshr<mode><vczle><vczbe>): ... This. (aarch64_simd_ashr<mode>): Rename to... (aarch64_simd_ashr<mode><vczle><vczbe>): ... This. (aarch64_simd_imm_shl<mode>): Rename to... (aarch64_simd_imm_shl<mode><vczle><vczbe>): ... This. (aarch64_simd_reg_sshl<mode>): Rename to... (aarch64_simd_reg_sshl<mode><vczle><vczbe>): ... This. (aarch64_simd_reg_shl<mode>_unsigned): Rename to... (aarch64_simd_reg_shl<mode>_unsigned<vczle><vczbe>): ... This. (aarch64_simd_reg_shl<mode>_signed): Rename to... (aarch64_simd_reg_shl<mode>_signed<vczle><vczbe>): ... This. (vec_shr_<mode>): Rename to... (vec_shr_<mode><vczle><vczbe>): ... This. (aarch64_<sur>shl<mode>): Rename to... (aarch64_<sur>shl<mode><vczle><vczbe>): ... This. (aarch64_<sur>q<r>shl<mode>): Rename to... (aarch64_<sur>q<r>shl<mode><vczle><vczbe>): ... This. gcc/testsuite/ChangeLog: PR target/99195 * gcc.target/aarch64/simd/pr99195_1.c: Add testing for shifts. * gcc.target/aarch64/simd/pr99195_6.c: Likewise. * gcc.target/aarch64/simd/pr99195_8.c: New test.
2023-05-24target/109944 - avoid STLF fail for V16QImode CTOR expansionRichard Biener3-5/+53
The following dispatches to V2DImode CTOR expansion instead of using sets of (subreg:DI (reg:V16QI 146) [08]) which causes LRA to spill DImode and reload V16QImode. The same applies for V8QImode or V4HImode construction from SImode parts which happens during 32bit libgcc build. PR target/109944 * config/i386/i386-expand.cc (ix86_expand_vector_init_general): Perform final vector composition using ix86_expand_vector_init_general instead of setting the highpart and lowpart which causes spilling. * gcc.target/i386/pr109944-1.c: New testcase. * gcc.target/i386/pr109944-2.c: Likewise.
2023-05-24Only update global value if it changes.Andrew MacLeod3-6/+14
Do not update and propagate a global value if it hasn't changed. PR tree-optimization/109695 * gimple-range-cache.cc (ranger_cache::get_global_range): Add changed param. * gimple-range-cache.h (ranger_cache::get_global_range): Ditto. * gimple-range.cc (gimple_ranger::range_of_stmt): Pass changed flag to set_global_range. (gimple_ranger::prefill_stmt_dependencies): Ditto.
2023-05-24Use negative values to reflect always_current in the temporal cache.Andrew MacLeod1-13/+30
Instead of using 0, use negative timestamps to reflect always_current state. If the value doesn't change, keep the timestamp rather than creating a new one and invalidating any dependencies. PR tree-optimization/109695 * gimple-range-cache.cc (temporal_cache::temporal_value): Return a positive int. (temporal_cache::current_p): Check always_current method. (temporal_cache::set_always_current): Add param and set value appropriately. (temporal_cache::always_current_p): New. (ranger_cache::get_global_range): Adjust. (ranger_cache::set_global_range): set always current first.
2023-05-24Choose better initial values for ranger.Andrew MacLeod1-1/+16
Instead of defaulting to VARYING, fold the stmt using just global ranges. PR tree-optimization/109695 * gimple-range-cache.cc (ranger_cache::get_global_range): Call fold_range with global query to choose an initial value.
2023-05-24RISC-V: Add FRM_ prefix to dynamic rounding mode enumJuzhe-Zhong1-1/+1
An obvious fix to make all enum naming consistent. gcc/ChangeLog: * config/riscv/riscv-protos.h (enum frm_field_enum): Add FRM_ prefix. Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai>
2023-05-24tree-optimization/109849 - fix fallout of PRE hoisting changeRichard Biener2-8/+24
The PR109849 fix made us no longer hoist some memory loads because of the expression set intersection. We can still avoid to compute the union by simply taking the first sets expressions and leave the pruning of expressions with values not suitable for hoisting to sorted_array_from_bitmap_set. PR tree-optimization/109849 * tree-ssa-pre.cc (do_hoist_insertion): Do not intersect expressions but take the first sets. * gcc.dg/tree-ssa/ssa-hoist-9.c: New testcase.
2023-05-24PR modula2/109952 Inconsistent HIGH values with 'ARRAY OF CHAR'Gaius Mulley7-49/+216
This patch fixes the case when a single character constant literal is passed as a string actual parameter to an ARRAY OF CHAR formal parameter. To be consistent a single character is promoted to a string and nul terminated (and its high value is 1). Previously a single character string would not be nul terminated and the high value was 0. The documentation now includes a section describing the expected behavior and included in this patch is some regression test code matching the table inside the documentation. gcc/ChangeLog: PR modula2/109952 * doc/gm2.texi (High procedure function): New node. (Using): New menu entry for High procedure function. gcc/m2/ChangeLog: PR modula2/109952 * Make-maintainer.in: Change header to include emacs file mode. * gm2-compiler/M2GenGCC.mod (BuildHighFromChar): Check whether operand is a constant string and is nul terminated then return one. * gm2-compiler/PCSymBuild.mod (WalkFunction): Add default return TRUE. Static analysis missing return path fix. * gm2-libs/IO.mod (Init): Rewrite to help static analysis. * target-independent/m2/gm2-libs.texi: Rebuild. gcc/testsuite/ChangeLog: PR modula2/109952 * gm2/pim/run/pass/hightests.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-05-24early-remat: Resync with new DF postorders [PR109940]Richard Sandiford2-14/+32
When I wrote early-remat, the DF_FORWARD block order was a postorder of a reverse/backward walk (i.e. of the inverted cfg), rather than a reverse postorder of a forward walk. A postorder of a backward walk lacked the important property that dominators come before the blocks they dominate; instead it ensures that postdominators come after the blocks that they postdominate. The DF_BACKWARD block order was similarly a postorder of a forward walk. Since early-remat wanted a standard postorder and reverse postorder with normal dominator properties, it used the DF_BACKWARD order instead of the DF_FORWARD order. g:53dddbfeb213ac4ec39f fixed the DF orders so that DF_FORWARD was an RPO of a forward walk and so that DF_BACKWARD was an RPO of a backward walk. This meant that iterating backwards over the DF_BACKWARD order had the exact problem that the original DF_FORWARD order had, triggering a flurry of ICEs for SVE. This fixes the build with SVE enabled. It also fixes an ICE in g++.target/aarch64/sve/pr99766.C with normal builds. I've included the test from the PR as well, for extra coverage. gcc/ PR rtl-optimization/109940 * early-remat.cc (postorder_index): Rename to... (rpo_index): ...this. (compare_candidates): Sort by decreasing rpo_index rather than increasing postorder_index. (early_remat::sort_candidates): Calculate the forward RPO from DF_FORWARD. (early_remat::local_phase): Follow forward RPO using DF_FORWARD, rather than DF_BACKWARD in reverse. gcc/testsuite/ * gcc.dg/torture/pr109940.c: New test.
2023-05-24arm: PR target/109939 Correct signedness of return type of __ssat intrinsicsKyrylo Tkachov2-1/+15
As the PR says we shouldn't be using qualifier_unsigned for the return type of the __ssat intrinsics. UNSIGNED_SAT_BINOP_UNSIGNED_IMM_QUALIFIERS already exists for that. This was just a thinko. This patch fixes this and the warning with -Wconversion goes away. Bootstrapped and tested on arm-none-linux-gnueabihf. gcc/ChangeLog: PR target/109939 * config/arm/arm-builtins.cc (SAT_BINOP_UNSIGNED_IMM_QUALIFIERS): Use qualifier_none for the return operand. gcc/testsuite/ChangeLog: PR target/109939 * gcc.target/arm/pr109939.c: New test.
2023-05-24RISC-V: Add RVV mask logic auto-vectorizationJuzhe-Zhong4-3/+191
This patch is adding mask logic auto-vectorization, define the pattern as "define_insn_and_split" to allow combine PASS easily combine series instructions. For example: combine vmxor.mm + vmnot.m into vmxnor.mm Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai> gcc/ChangeLog: * config/riscv/autovec.md (<optab><mode>3): New pattern. (one_cmpl<mode>2): Ditto. (*<optab>not<mode>): Ditto. (*n<optab><mode>): Ditto. * config/riscv/riscv-v.cc (expand_vec_cmp_float): Change to one_cmpl. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/cmp/vcond-4.c: New test. * gcc.target/riscv/rvv/autovec/cmp/vcond_run-4.c: New test.
2023-05-24[testsuite] [ppc] xfail uninit-pred-9_b bogus warn on ppc32 tooAlexandre Oliva1-1/+1
The bogus warning is present on 32-bit ppc-vx7r2 too, so drop the 64 from the powerpc xfail triplet. for gcc/testsuite/ChangeLog * gcc.dg/uninit-pred-9_b.c: Xfail bogus warning on 32-bit ppc as well.
2023-05-24[testsuite] [i386] enable sse2 for signbit-2.cAlexandre Oliva1-1/+1
The expected results for signbit-2 only arise on x86 with avx512f disabled and sse2 enabled. The patch already disables avx512f explicitly, but it fails to enable sse2. for gcc/testsuite/ChangeLog * gcc.dg/signbit-2.c: Add -msse2 on x86.
2023-05-24Check for sysconf decl on vxworksAlexandre Oliva1-0/+11
The sysconf function is only available in rtp mode on vxworks. In kernel mode, it is not even declared, but the feature test macro in the testsuite doesn't notice its absence because it's a link test, and vxworks kernel mode uses partial linking. This patch introduces an alternate test on vxworks targets to check for a declaration and for an often-used sysconf parameter. for gcc/testsuite/ChangeLog * lib/target-supports.exp (check_effective_target_sysconf): Check for declaration and _SC_PAGESIZE on vxworks.
2023-05-24vect: Enhance cost evaluation in vect_transform_slp_perm_load_1Kewen Lin2-32/+57
Following Richi's suggestion in [1], I'm working on deferring cost evaluation next to the transformation, this patch is to enhance function vect_transform_slp_perm_load_1 which could under-cost for vector permutation, since the costing doesn't try to consider nvectors_per_build, it's inconsistent with the transformation part. Basically it changes the below if (index == count) { if (!noop_p) { // A ... // ++*n_perms; if (!analyze_only) { // B1 ... // B2 ... for ... // B3 building VEC_PERM_EXPR } } else if (!analyze_only) { // no B2 since no any further uses here. for ... // B4 building nothing } // B5 ... } to: if (index == count) { if (!noop_p) { // A ... if (!analyze_only) // B1 ... // B2 ... (trivial computations during analyze_only or not) for ... { // now n_perms is consistent with building VEC_PERM_EXPR // ++*n_perms; if (analyze_only) continue; // B3 building VEC_PERM_EXPR } } else if (!analyze_only) { // no B2 since no any further uses here. for ... // B4 building nothing } // B5 ... } [1] https://gcc.gnu.org/pipermail/gcc-patches/2021-January/563624.html gcc/ChangeLog: * tree-vect-slp.cc (vect_transform_slp_perm_load_1): Adjust the calculation on n_perms by considering nvectors_per_build. gcc/testsuite/ChangeLog: * gcc.dg/vect/costmodel/ppc/costmodel-slp-perm.c: New test.
2023-05-24RISC-V: Add RVV comparison autovectorizationJuzhe-Zhong10-0/+754
This patch enable RVV auto-vectorization including floating-point unorder and order comparison. The testcases are leveraged from Richard. So include Richard as co-author. And this patch is the prerequisite patch for my current middle-end work. Without this patch, I can't support len_mask_xxx middle-end pattern since the mask is generated by comparison. For example, for (int i...; i < n.) if (cond[i]) a[i] = b[i] We need len_mask_load/len_mask_store for such code and I am gonna support them in the middle-end after this patch is merged. Both integer && floating (order and unorder) are tested. built && regression passed. Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai> Co-Authored-By: Richard Sandiford <richard.sandiford@arm.com> gcc/ChangeLog: * config/riscv/autovec.md (@vcond_mask_<mode><vm>): New pattern. (vec_cmp<mode><vm>): New pattern. (vec_cmpu<mode><vm>): New pattern. (vcond<V:mode><VI:mode>): New pattern. (vcondu<V:mode><VI:mode>): New pattern. * config/riscv/riscv-protos.h (enum insn_type): Add new enum. (emit_vlmax_merge_insn): New function. (emit_vlmax_cmp_insn): Ditto. (emit_vlmax_cmp_mu_insn): Ditto. (expand_vec_cmp): Ditto. (expand_vec_cmp_float): Ditto. (expand_vcond): Ditto. * config/riscv/riscv-v.cc (emit_vlmax_merge_insn): Ditto. (emit_vlmax_cmp_insn): Ditto. (emit_vlmax_cmp_mu_insn): Ditto. (get_cmp_insn_code): Ditto. (expand_vec_cmp): Ditto. (expand_vec_cmp_float): Ditto. (expand_vcond): Ditto. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/rvv.exp: * gcc.target/riscv/rvv/autovec/cmp/vcond-1.c: New test. * gcc.target/riscv/rvv/autovec/cmp/vcond-2.c: New test. * gcc.target/riscv/rvv/autovec/cmp/vcond-3.c: New test. * gcc.target/riscv/rvv/autovec/cmp/vcond_run-1.c: New test. * gcc.target/riscv/rvv/autovec/cmp/vcond_run-2.c: New test. * gcc.target/riscv/rvv/autovec/cmp/vcond_run-3.c: New test.
2023-05-24RISC-V: Support RVV VREINTERPRET from vbool*_t to vuint*m1_tPan Li6-2/+174
This patch support the RVV VREINTERPRET from the vbool*_t to the vuint*m1_t. Aka: vuint*m1_t __riscv_vreinterpret_x_x(vbool*_t); These APIs help the users to convert vector the vbool*_t to the LMUL=1 unsigned integer vint*_t. According to the RVV intrinsic SPEC as below, the reinterpret intrinsics only change the types of the underlying contents. https://github.com/riscv-non-isa/rvv-intrinsic-doc/blob/master/rvv-intrinsic-rfc.md#reinterpret-vbool-o-vintm1 For example, given below code. vuint8m1_t test_vreinterpret_v_b1_vuint8m1 (vbool1_t src) { return __riscv_vreinterpret_v_b1_u8m1 (src); } It will generate the assembly code similar as below: vsetvli a5,zero,e8,m8,ta,ma vlm.v v1,0(a1) vs1r.v v1,0(a0) ret Please NOTE the test files doesn't cover all the possible combinations of the intrinsic APIs introduced by this PATCH due to too many. This is the last PATCH for the reinterpret between the signed/unsigned and the bool vector types. Signed-off-by: Pan Li <pan2.li@intel.com> gcc/ChangeLog: * config/riscv/genrvv-type-indexer.cc (main): Add unsigned_eew*_lmul1_interpret for indexer. * config/riscv/riscv-vector-builtins-functions.def (vreinterpret): Register vuint*m1_t interpret function. * config/riscv/riscv-vector-builtins-types.def (DEF_RVV_UNSIGNED_EEW8_LMUL1_INTERPRET_OPS): New macro for vuint8m1_t. (DEF_RVV_UNSIGNED_EEW16_LMUL1_INTERPRET_OPS): Likewise. (DEF_RVV_UNSIGNED_EEW32_LMUL1_INTERPRET_OPS): Likewise. (DEF_RVV_UNSIGNED_EEW64_LMUL1_INTERPRET_OPS): Likewise. (vbool1_t): Add to unsigned_eew*_interpret_ops. (vbool2_t): Likewise. (vbool4_t): Likewise. (vbool8_t): Likewise. (vbool16_t): Likewise. (vbool32_t): Likewise. (vbool64_t): Likewise. * config/riscv/riscv-vector-builtins.cc (DEF_RVV_UNSIGNED_EEW8_LMUL1_INTERPRET_OPS): New macro for vuint*m1_t. (DEF_RVV_UNSIGNED_EEW16_LMUL1_INTERPRET_OPS): Likewise. (DEF_RVV_UNSIGNED_EEW32_LMUL1_INTERPRET_OPS): Likewise. (DEF_RVV_UNSIGNED_EEW64_LMUL1_INTERPRET_OPS): Likewise. (required_extensions_p): Add vuint*m1_t interpret case. * config/riscv/riscv-vector-builtins.def (unsigned_eew8_lmul1_interpret): Add vuint*m1_t interpret to base type. (unsigned_eew16_lmul1_interpret): Likewise. (unsigned_eew32_lmul1_interpret): Likewise. (unsigned_eew64_lmul1_interpret): Likewise. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/misc_vreinterpret_vbool_vint.c: Enrich test cases.
2023-05-24RISC-V: Support RVV VREINTERPRET from vbool*_t to vint*m1_tPan Li6-1/+175
This patch support the RVV VREINTERPRET from the vbool*_t to the vint*m1_t. Aka: vint*m1_t __riscv_vreinterpret_x_x(vbool*_t); These APIs help the users to convert vector the vbool*_t to the LMUL=1 signed integer vint*_t. According to the RVV intrinsic SPEC as below, the reinterpret intrinsics only change the types of the underlying contents. https://github.com/riscv-non-isa/rvv-intrinsic-doc/blob/master/rvv-intrinsic-rfc.md#reinterpret-vbool-o-vintm1 For example, given below code. vint8m1_t test_vreinterpret_v_b1_vint8m1 (vbool1_t src) { return __riscv_vreinterpret_v_b1_i8m1 (src); } It will generate the assembly code similar as below: vsetvli a5,zero,e8,m8,ta,ma vlm.v v1,0(a1) vs1r.v v1,0(a0) ret Please NOTE the test files doesn't cover all the possible combinations of the intrinsic APIs introduced by this PATCH due to too many. The reinterpret from vbool*_t to vuint*m1_t with lmul=1 will be coverred in another PATCH. Signed-off-by: Pan Li <pan2.li@intel.com> gcc/ChangeLog: * config/riscv/genrvv-type-indexer.cc (EEW_SIZE_LIST): New macro for the eew size list. (LMUL1_LOG2): New macro for the log2 value of lmul=1. (main): Add signed_eew*_lmul1_interpret for indexer. * config/riscv/riscv-vector-builtins-functions.def (vreinterpret): Register vint*m1_t interpret function. * config/riscv/riscv-vector-builtins-types.def (DEF_RVV_SIGNED_EEW8_LMUL1_INTERPRET_OPS): New macro for vint8m1_t. (DEF_RVV_SIGNED_EEW16_LMUL1_INTERPRET_OPS): Likewise. (DEF_RVV_SIGNED_EEW32_LMUL1_INTERPRET_OPS): Likewise. (DEF_RVV_SIGNED_EEW64_LMUL1_INTERPRET_OPS): Likewise. (vbool1_t): Add to signed_eew*_interpret_ops. (vbool2_t): Likewise. (vbool4_t): Likewise. (vbool8_t): Likewise. (vbool16_t): Likewise. (vbool32_t): Likewise. (vbool64_t): Likewise. * config/riscv/riscv-vector-builtins.cc (DEF_RVV_SIGNED_EEW8_LMUL1_INTERPRET_OPS): New macro for vint*m1_t. (DEF_RVV_SIGNED_EEW16_LMUL1_INTERPRET_OPS): Likewise. (DEF_RVV_SIGNED_EEW32_LMUL1_INTERPRET_OPS): Likewise. (DEF_RVV_SIGNED_EEW64_LMUL1_INTERPRET_OPS): Likewise. (required_extensions_p): Add vint8m1_t interpret case. * config/riscv/riscv-vector-builtins.def (signed_eew8_lmul1_interpret): Add vint*m1_t interpret to base type. (signed_eew16_lmul1_interpret): Likewise. (signed_eew32_lmul1_interpret): Likewise. (signed_eew64_lmul1_interpret): Likewise. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/misc_vreinterpret_vbool_vint.c: Enrich the test cases.
2023-05-24RISC-V: Fix incorrect code of reaching inaccessible memory addressJuzhe-Zhong4-17/+25
To fix this issue, we seperate Vl operand and normal operands. gcc/ChangeLog: * config/riscv/autovec.md: Adjust for new interface. * config/riscv/riscv-protos.h (emit_vlmax_insn): Add VL operand. (emit_nonvlmax_insn): Add AVL operand. * config/riscv/riscv-v.cc (emit_vlmax_insn): Add VL operand. (emit_nonvlmax_insn): Add AVL operand. (sew64_scalar_helper): Adjust for new interface. (expand_tuple_move): Ditto. * config/riscv/vector.md: Ditto. Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai>
2023-05-24RISC-V: Fix magic number of RVV auto-vectorization expanderJuzhe-Zhong2-29/+26
This simple patch fixes the magic number, remove magic number make codes more reasonable. gcc/ChangeLog: * config/riscv/riscv-v.cc (expand_vec_series): Remove magic number. (expand_const_vector): Ditto. (legitimize_move): Ditto. (sew64_scalar_helper): Ditto. (expand_tuple_move): Ditto. (expand_vector_init_insert_elems): Ditto. * config/riscv/riscv.cc (vector_zero_call_used_regs): Ditto. Signed-off-by: Juzhe-Zhong <juzhe.zhong@rivai.ai>