Skip to content
Snippets Groups Projects
  1. Sep 19, 2023
    • Gaius Mulley's avatar
      PR 108143/modula2 LONGREAL and powerpc64le-linux · 81d5ca0b
      Gaius Mulley authored
      
      This patch introduces a configure for LONGREAL as float128 when
      targetting or hosting cc1gm2 on ppc64le.  It fixes calls to builtins
      and fixes the -fdebug-builtins option.
      
      gcc/ChangeLog:
      
      	* doc/gm2.texi (fdebug-builtins): Correct description.
      
      gcc/m2/ChangeLog:
      
      	* Make-lang.in (host_mc_longreal): Detect hosting on powerpc64le
      	and if so use __float128 for longreal in mc.
      	(MC_ARGS): Append host_mc_longreal.
      	* config-make.in (TEST_TARGET_CPU_DEFAULT): New variable.
      	(TEST_HOST_CPU_DEFAULT): New variable.
      	* configure: Regenerate.
      	* configure.ac (M2C_LONGREAL_FLOAT128): New define set if target
      	is powerpc64le.
      	(M2C_LONGREAL_PPC64LE): New define set if target is powerpc64le.
      	* gm2-compiler/M2GCCDeclare.mod: Correct comment case.
      	* gm2-compiler/M2GenGCC.mod (MaybeDebugBuiltinAlloca): Call
      	SetLastFunction for the builtin function call.
      	(MaybeDebugBuiltinMemcpy): Call SetLastFunction for the builtin
      	function call.
      	(MaybeDebugBuiltinMemset): New procedure function.
      	(MakeCopyUse): Use GNU formatting.
      	(UseBuiltin): Rewrite to check BuiltinExists.
      	(CodeDirectCall): Rewrite to check BuiltinExists and call
      	SetLastFunction.
      	(CodeMakeAdr): Re-format.
      	* gm2-compiler/M2Options.def (SetDebugBuiltins): New procedure.
      	* gm2-compiler/M2Options.mod (SetUninitVariableChecking): Allow
      	"cond" to switch UninitVariableConditionalChecking separately.
      	(SetDebugBuiltins): New procedure.
      	* gm2-compiler/M2Quads.def (BuildFunctionCall): Add parameter
      	ConstExpr.
      	* gm2-compiler/M2Quads.mod (BuildRealProcedureCall): Add parameter
      	to BuildRealFuncProcCall.
      	(BuildRealFuncProcCall): Add ConstExpr parameter.  Pass ConstExpr
      	to BuildFunctionCall.
      	(BuildFunctionCall): Add parameter ConstExpr.  Pass ConstExpr to
      	BuildRealFunctionCall.
      	(BuildConstFunctionCall): Add parameter ConstExpr.  Pass ConstExpr to
      	BuildFunctionCall.
      	(BuildRealFunctionCall): Add parameter ConstExpr.  Pass ConstExpr to
      	BuildRealFuncProcCall.
      	* gm2-compiler/P3Build.bnf (SetOrDesignatorOrFunction): Pass FALSE
      	to BuildFunctionCall.
      	(AssignmentOrProcedureCall): Pass FALSE to BuildFunctionCall.
      	* gm2-compiler/SymbolTable.def (IsProcedureBuiltinAvailable): New
      	procedure function.
      	* gm2-compiler/SymbolTable.mod (CanUseBuiltin): New procedure
      	function.
      	(IsProcedureBuiltinAvailable): New procedure function.
      	* gm2-gcc/m2builtins.cc (DEBUGGING): Undef.
      	(bf_category): New enum type.
      	(struct builtin_function_entry): New field function_avail.
      	(m2builtins_BuiltInMemCopy): Rename from ...
      	(m2builtins_BuiltinMemCopy): ... this.
      	(DoBuiltinMemSet): New function.
      	(m2builtins_BuiltinMemSet): New function.
      	(do_target_support_exists): New function.
      	(target_support_exists): New function.
      	(m2builtins_BuiltinExists): Return true or false.
      	(m2builtins_BuildBuiltinTree): Rename local variables.
      	Replace long_double_type_node with GetM2LongRealType.
      	(m2builtins_init): Use GetM2LongRealType rather than
      	long_double_type_node.
      	* gm2-gcc/m2builtins.def (BuiltInMemCopy): Rename to ...
      	(BuiltinMemCopy): ... this.
      	(BuiltinMemSet): New procedure function.
      	* gm2-gcc/m2builtins.h (m2builtins_BuiltInMemCopy): Rename to ...
      	(m2builtins_BuiltinMemCopy): ... this.
      	(m2builtins_BuiltinMemSet): New procedure function.
      	* gm2-gcc/m2configure.cc (m2configure_M2CLongRealFloat128): New
      	procedure function.
      	(m2configure_M2CLongRealIBM128): New procedure function.
      	(m2configure_M2CLongRealLongDouble): New procedure function.
      	(m2configure_M2CLongRealLongDoublePPC64LE): New procedure function.
      	* gm2-gcc/m2configure.def (M2CLongRealFloat128): New procedure function.
      	(M2CLongRealIBM128): New procedure function.
      	(M2CLongRealLongDouble): New procedure function.
      	(M2CLongRealLongDoublePPC64LE): New procedure function.
      	* gm2-gcc/m2configure.h (m2configure_FullPathCPP): New procedure function.
      	(m2configure_M2CLongRealFloat128): New procedure function.
      	(m2configure_M2CLongRealIBM128): New procedure function.
      	(m2configure_M2CLongRealLongDouble): New procedure function.
      	(m2configure_M2CLongRealLongDoublePPC64LE): New procedure function.
      	* gm2-gcc/m2convert.cc (m2convert_BuildConvert): Use convert_loc.
      	* gm2-gcc/m2options.h (M2Options_SetDebugBuiltins): New function.
      	* gm2-gcc/m2statement.cc (m2statement_BuildAssignmentTree): Set
      	TREE_USED to true.
      	(m2statement_BuildGoto):Set TREE_USED to true.
      	(m2statement_BuildParam): Set TREE_USED to true.
      	(m2statement_BuildBuiltinCallTree): New function.
      	(m2statement_BuildFunctValue): Set TREE_USED to true.
      	* gm2-gcc/m2statement.def (BuildBuiltinCallTree): New procedure function.
      	* gm2-gcc/m2statement.h (m2statement_BuildBuiltinCallTree): New
      	procedure function.
      	* gm2-gcc/m2treelib.cc (m2treelib_DoCall0): Remove spacing.
      	(m2treelib_DoCall1): Remove spacing.
      	(m2treelib_DoCall2): Remove spacing.
      	(m2treelib_DoCall3): Remove spacing.
      	(add_stmt): Rename parameter.
      	* gm2-gcc/m2type.cc (build_set_type): Remove spacing.
      	(build_m2_specific_size_type): Remove spacing.
      	(finish_build_pointer_type): Remove spacing.
      	(m2type_BuildVariableArrayAndDeclare): Remove spacing.
      	(build_m2_short_real_node): Remove spacing.
      	(build_m2_real_node): Remove spacing.
      	(build_m2_long_real_node): Use float128_type_node if
      	M2CLongRealFloat128 is set.
      	(build_m2_ztype_node): Remove spacing.
      	(build_m2_long_int_node): Remove spacing.
      	(build_m2_long_card_node): Remove spacing.
      	(build_m2_short_int_node): Remove spacing.
      	(build_m2_short_card_node): Remove spacing.
      	(build_m2_iso_loc_node): Remove spacing.
      	(m2type_SameRealType): New function.
      	(m2type_InitBaseTypes): Create m2_c_type_node using
      	m2_long_complex_type_node.
      	(m2type_SetAlignment): Tidy up comment.
      	* gm2-gcc/m2type.def (SameRealType):  New procedure function.
      	* gm2-gcc/m2type.h (m2type_SameRealType): New procedure function.
      	* gm2-lang.cc (gm2_langhook_type_for_mode): Build long complex
      	node from m2 language specific long double node.
      	* gm2-libs-log/RealConversions.mod (IsNan): New procedure
      	function.
      	(doPowerOfTen): Re-implement.
      	* gm2-libs/Builtins.mod: Add newline.
      	* gm2-libs/DynamicStrings.def (ReplaceChar): New procedure function.
      	* gm2-libs/DynamicStrings.mod (ReplaceChar): New procedure function.
      	* gm2config.aci.in (M2C_LONGREAL_FLOAT128): New config value.
      	(M2C_LONGREAL_PPC64LE): New config value.
      	* gm2spec.cc (lang_specific_driver): New local variable
      	need_default_mabi set to default value depending upon
      	M2C_LONGREAL_PPC64LE and M2C_LONGREAL_FLOAT128.
      	* lang.opt (Wcase-enum): Moved to correct section.
      	* m2pp.cc (m2pp_real_type): New function.
      	(m2pp_type): Call m2pp_real_type.
      	(m2pp_print_mode): New function.
      	(m2pp_simple_type): Call m2pp_simple_type.
      	(m2pp_float): New function.
      	(m2pp_expression): Call m2pp_float.
      	* mc-boot/GDynamicStrings.cc: Rebuild.
      	* mc-boot/GDynamicStrings.h: Rebuild.
      	* mc-boot/GFIO.cc: Rebuild.
      	* mc-boot/GFIO.h: Rebuild.
      	* mc-boot/GIO.cc: Rebuild.
      	* mc-boot/GRTint.cc: Rebuild.
      	* mc-boot/Gdecl.cc: Rebuild.
      	* mc-boot/GmcOptions.cc: Rebuild.
      	* mc-boot/GmcOptions.h: Rebuild.
      	* mc/decl.mod: Rebuild.
      	* mc/mcOptions.def (getCRealType): New procedure function.
      	(getCLongRealType): New procedure function.
      	(getCShortRealType): New procedure function.
      	* mc/mcOptions.mod (getCRealType): New procedure function.
      	(getCLongRealType): New procedure function.
      	(getCShortRealType): New procedure function.
      
      libgm2/ChangeLog:
      
      	* Makefile.am (TARGET_LONGDOUBLE_ABI): New variable set to
      	-mabi=ieeelongdouble if the target is powerpc64le.
      	(AM_MAKEFLAGS): Append TARGET_LONGDOUBLE_ABI.
      	* Makefile.in: Rebuild.
      	* libm2cor/Makefile.am (AM_MAKEFLAGS): Add CFLAGS_LONGDOUBLE and
      	TARGET_LONGDOUBLE_ABI.
      	(libm2cor_la_CFLAGS): Add TARGET_LONGDOUBLE_ABI.
      	(libm2cor_la_M2FLAGS): Add TARGET_LONGDOUBLE_ABI.
      	* libm2cor/Makefile.in: Rebuild.
      	* libm2iso/Makefile.am (AM_MAKEFLAGS): Add CFLAGS_LONGDOUBLE and
      	TARGET_LONGDOUBLE_ABI.
      	(libm2iso_la_CFLAGS): Add TARGET_LONGDOUBLE_ABI.
      	(libm2iso_la_M2FLAGS): Add TARGET_LONGDOUBLE_ABI.
      	* libm2iso/Makefile.in: Rebuild.
      	* libm2log/Makefile.am (AM_MAKEFLAGS): Add CFLAGS_LONGDOUBLE and
      	TARGET_LONGDOUBLE_ABI.
      	(libm2log_la_CFLAGS): Add TARGET_LONGDOUBLE_ABI.
      	(libm2log_la_M2FLAGS): Add TARGET_LONGDOUBLE_ABI.
      	* libm2log/Makefile.in: Rebuild.
      	* libm2min/Makefile.am (AM_MAKEFLAGS): Add CFLAGS_LONGDOUBLE and
      	TARGET_LONGDOUBLE_ABI.
      	(libm2min_la_CFLAGS): Add TARGET_LONGDOUBLE_ABI.
      	(libm2min_la_M2FLAGS): Add TARGET_LONGDOUBLE_ABI.
      	* libm2min/Makefile.in: Rebuild.
      	* libm2pim/Makefile.am (AM_MAKEFLAGS): Add CFLAGS_LONGDOUBLE and
      	TARGET_LONGDOUBLE_ABI.
      	(libm2pim_la_CFLAGS): Add TARGET_LONGDOUBLE_ABI.
      	(libm2pim_la_M2FLAGS): Add TARGET_LONGDOUBLE_ABI.
      	* libm2pim/Makefile.in: Rebuild.
      
      gcc/testsuite/ChangeLog:
      
      	* gm2/extensions/pass/libc.def: Add spacing.
      	* gm2/pimlib/logitech/run/pass/realconv.mod: Add debugging print.
      	* gm2/switches/uninit-variable-checking/cascade/fail/switches-uninit-variable-checking-cascade-fail.exp:
      	Add -fdebug-builtins flag.
      	* lib/gm2.exp (gm2_target_compile_default): Add
      	-mabi=ieeelongdouble if the target is powerpc.
      	(gm2_link_flags): Add
      	-mabi=ieeelongdouble if the target is powerpc.
      	* gm2/pim/intrinsic/run/pass/cstub.c: New test.
      	* gm2/pim/intrinsic/run/pass/cstub.def: New test.
      	* gm2/pim/intrinsic/run/pass/pim-intrinsic-run-pass.exp: New test.
      	* gm2/pim/intrinsic/run/pass/test.mod: New test.
      	* gm2/pim/run/pass/builtins.mod: New test.
      	* gm2/pim/run/pass/convert1.mod: New test.
      	* gm2/pim/run/pass/longint1.mod: New test.
      	* gm2/pim/run/pass/longint2.mod: New test.
      	* gm2/pim/run/pass/longint3.mod: New test.
      	* gm2/pim/run/pass/longint4.mod: New test.
      	* gm2/pim/run/pass/longint5.mod: New test.
      	* gm2/pim/run/pass/longint6.mod: New test.
      	* gm2/pim/run/pass/longint7.mod: New test.
      	* gm2/pim/run/pass/longint8.mod: New test.
      
      Signed-off-by: default avatarGaius Mulley <gaiusmod2@gmail.com>
      81d5ca0b
    • Jeff Law's avatar
      Fix bogus operand predicate on iq2000 · eec7c373
      Jeff Law authored
      The iq2000-elf port regressed these tests recently:
      
      > iq2000-sim: gcc.c-torture/execute/20040703-1.c   -O2  (test for excess errors)
      > iq2000-sim: gcc.c-torture/execute/20040703-1.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  (test for excess errors)
      > iq2000-sim: gcc.c-torture/execute/20040703-1.c   -O3 -g  (test for excess errors)
      
      It turns out one of the patterns had an operand predicate that allowed REG,
      SUBREG, CONST_INT (with a limited set of CONST_INTs).  Yet the constraint only
      allowed the limited set of immediates.  This naturally triggered an LRA
      constraint failure.
      
      The fix is trivial, create an operand predicate that accurately reflects the
      kinds of operands allowed by the instruction.
      
      It turns out this was a long standing bug -- fixing the pattern resolved 55
      failing tests in the testsuite.
      
      gcc/
      	* config/iq2000/predicates.md (uns_arith_constant): New predicate.
      	* config/iq2000/iq2000.md (rotrsi3): Use it.
      eec7c373
    • Harald Anlauf's avatar
      fortran: fix checking of CHARACTER lengths in array constructors [PR70231] · 15acabb8
      Harald Anlauf authored
      gcc/fortran/ChangeLog:
      
      	PR fortran/70231
      	* trans-array.cc (trans_array_constructor): In absence of a typespec,
      	use string length determined by get_array_ctor_strlen() to reasonably
      	initialize auxiliary variable for bounds-checking.
      
      gcc/testsuite/ChangeLog:
      
      	PR fortran/70231
      	* gfortran.dg/bounds_check_fail_7.f90: New test.
      15acabb8
    • Aldy Hernandez's avatar
      [frange] Remove redundant known_isnan() checks. · 36eec799
      Aldy Hernandez authored
      The known_isnan() method is a subset of maybe_isnan().  This patch
      removes redundant calls to known_isnan().
      
      gcc/ChangeLog:
      
      	* range-op-float.cc (operator_lt::op1_range): Remove known_isnan check.
      	(operator_lt::op2_range): Same.
      	(operator_le::op1_range): Same.
      	(operator_le::op2_range): Same.
      	(operator_gt::op1_range): Same.
      	(operator_gt::op2_range): Same.
      	(operator_ge::op1_range): Same.
      	(operator_ge::op2_range): Same.
      	(foperator_unordered_lt::op1_range): Same.
      	(foperator_unordered_lt::op2_range): Same.
      	(foperator_unordered_le::op1_range): Same.
      	(foperator_unordered_le::op2_range): Same.
      	(foperator_unordered_gt::op1_range): Same.
      	(foperator_unordered_gt::op2_range): Same.
      	(foperator_unordered_ge::op1_range): Same.
      	(foperator_unordered_ge::op2_range): Same.
      36eec799
    • Aldy Hernandez's avatar
      Add frange::update_nan (const nan_state &). · cb3f870f
      Aldy Hernandez authored
      We can set_nan() with a nan_state so it's good form to have the
      analogous form for update_nan().
      
      gcc/ChangeLog:
      
      	* value-range.h (frange::update_nan): New.
      cb3f870f
    • Aldy Hernandez's avatar
      [frange] Add op2_range for operator_not_equal. · 9c739c98
      Aldy Hernandez authored
      We're missing an op2_range entry for operator_not_equal so GORI can
      calculate an outgoing edge.  The false side of != is true and
      guarantees we don't have a NAN, so it's important to get this right.
      We eventually get it through an intersection of various ranges in
      ranger, but it's best to get things correct as early as possible.
      
      gcc/ChangeLog:
      
      	* range-op-float.cc (operator_not_equal::op2_range): New.
      	* range-op-mixed.h: Add operator_not_equal::op2_range.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/tree-ssa/vrp-float-13.c: New test.
      9c739c98
    • Jakub Jelinek's avatar
      testsuite work-around compound-assignment-1.c C++ failures on various targets [PR111377] · d2f53a60
      Jakub Jelinek authored
      On Mon, Sep 11, 2023 at 11:11:30PM +0200, Jakub Jelinek via Gcc-patches wrote:
      > I think the divergence is whether called_by_test_5b returns the struct
      > in registers or in memory.  If in memory (like in the x86_64 -m32 case), we have
      >   [compound-assignment-1.c:71:21] D.3191 = called_by_test_5b (); [return slot optimization]
      >   [compound-assignment-1.c:71:21 discrim 1] D.3191 ={v} {CLOBBER(eol)};
      >   [compound-assignment-1.c:72:1] return;
      > in the IL, while if in registers (like x86_64 -m64 case), just
      >   [compound-assignment-1.c:71:21] D.3591 = called_by_test_5b ();
      >   [compound-assignment-1.c:72:1] return;
      >
      > If you just want to avoid the differences, putting } on the same line as the
      > call might be a usable workaround for that.
      
      Here is the workaround in patch form.
      
      2023-09-19  Jakub Jelinek  <jakub@redhat.com>
      
      	PR testsuite/111377
      	* c-c++-common/analyzer/compound-assignment-1.c (test_5b): Move
      	closing } to the same line as the call to work-around differences in
      	diagnostics line.
      d2f53a60
    • Jason Merrill's avatar
      c++: inherited default constructor [CWG2799] · 1560cc94
      Jason Merrill authored
      In this testcase, it seems clear that B should be trivially
      default-constructible, since the inherited default constructor is trivial
      and there are no other subobjects to initialize.  But we were saying no
      because we don't define triviality of inherited constructors.
      
      CWG discussion suggested that the solution is to implicitly declare a
      default constructor when inheriting a default constructor; that makes sense
      to me.
      
      	DR 2799
      
      gcc/cp/ChangeLog:
      
      	* class.cc (add_implicit_default_ctor): Split out...
      	(add_implicitly_declared_members): ...from here.
      	Also call it when inheriting a default ctor.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp0x/inh-ctor38.C: New test.
      1560cc94
    • Andrew MacLeod's avatar
      New early __builtin_unreachable processing. · bf6b107e
      Andrew MacLeod authored
      in VRP passes before __builtin_unreachable MUST be removed, only remove it
      if all exports affected by the unreachable can have global values updated, and
      do not involve loads from memory.
      
      	PR tree-optimization/110080
      	PR tree-optimization/110249
      	gcc/
      	* tree-vrp.cc (remove_unreachable::final_p): New.
      	(remove_unreachable::maybe_register): Rename from
      	maybe_register_block and call early or final routine.
      	(fully_replaceable): New.
      	(remove_unreachable::handle_early): New.
      	(remove_unreachable::remove_and_update_globals): Remove
      	non-final processing.
      	(rvrp_folder::rvrp_folder): Add final flag to constructor.
      	(rvrp_folder::post_fold_bb): Remove unreachable registration.
      	(rvrp_folder::pre_fold_stmt): Move unreachable processing to here.
      	(execute_ranger_vrp): Adjust some call parameters.
      
      	gcc/testsuite/
      	* g++.dg/pr110249.C: New.
      	* gcc.dg/pr110080.c: New.
      	* gcc.dg/pr93917.c: Adjust.
      bf6b107e
    • Marek Polacek's avatar
      c++: Move consteval folding to cp_fold_r · 6851e342
      Marek Polacek authored
      In the review of P2564:
      <https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628747.html>
      it turned out that in order to correctly handle an example in the paper,
      we should stop doing immediate evaluation in build_over_call and
      bot_replace, and instead do it in cp_fold_r.  This patch does that.
      
      Another benefit is that this is a pretty significant simplification, at
      least in my opinion.  Also, this fixes the c++/110997 ICE (but the test
      doesn't compile yet).
      
      The main drawback seems to be that cp_fold_r doesn't process
      uninstantiated templates.  We still have to handle things like
      "false ? foo () : 1".  To that end, I've added cp_fold_immediate, called
      on dead branches in cxx_eval_conditional_expression.
      
      You'll see that I've reintroduced ADDR_EXPR_DENOTES_CALL_P here.  This
      is to detect
      
        *(&foo)) ()
        (s.*&S::foo) ()
      
      which were deemed ill-formed.
      
      gcc/cp/ChangeLog:
      
      	* call.cc (build_over_call): Set ADDR_EXPR_DENOTES_CALL_P.  Don't handle
      	immediate_invocation_p here.
      	* constexpr.cc (cxx_eval_call_expression): Use mce_true for
      	DECL_IMMEDIATE_FUNCTION_P.
      	(cxx_eval_conditional_expression): Call cp_fold_immediate.
      	* cp-gimplify.cc (enum fold_flags): Add ff_fold_immediate.
      	(maybe_replace_decl): Make static.
      	(cp_fold_r): Expand immediate invocations.
      	(cp_fold_immediate_r): New.
      	(cp_fold_immediate): New.
      	* cp-tree.h (ADDR_EXPR_DENOTES_CALL_P): Define.
      	(cp_fold_immediate): Declare.
      	* tree.cc (bot_replace): Don't handle immediate invocations here.
      
      libstdc++-v3/ChangeLog:
      
      	* testsuite/20_util/allocator/105975.cc: Add dg-error.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp23/consteval-if2.C: Add xfail.
      	* g++.dg/cpp2a/consteval-memfn1.C: Adjust.
      	* g++.dg/cpp2a/consteval11.C: Remove dg-message.
      	* g++.dg/cpp2a/consteval3.C: Remove dg-message and dg-error.
      	* g++.dg/cpp2a/consteval9.C: Remove dg-message.
      	* g++.dg/cpp2a/consteval32.C: New test.
      	* g++.dg/cpp2a/consteval33.C: New test.
      	* g++.dg/cpp2a/consteval34.C: New test.
      	* g++.dg/cpp2a/consteval35.C: New test.
      6851e342
    • Richard Biener's avatar
      c/111468 - dump unordered compare operators in their GIMPLE form with -gimple · f25960b0
      Richard Biener authored
      The following adjusts -gimple dumping to dump the unordered compare ops
      and *h in their GIMPLE form.  It also adds parsing for __LTGT which I
      missed before.
      
      	PR c/111468
      gcc/c/
      	* gimple-parser.cc (c_parser_gimple_binary_expression): Handle __LTGT.
      
      gcc/
      	* tree-pretty-print.h (op_symbol_code): Add defaulted flags
      	argument.
      	* tree-pretty-print.cc (op_symbol): Likewise.
      	(op_symbol_code): Print TDF_GIMPLE variant if requested.
      	* gimple-pretty-print.cc (dump_binary_rhs): Pass flags to
      	op_symbol_code.
      	(dump_gimple_cond): Likewise.
      
      gcc/testsuite/
      	* gcc.dg/gimplefe-50.c: Amend.
      f25960b0
    • Patrick Palka's avatar
      c++: overeager type completion in convert_to_void [PR111419] · b510b83a
      Patrick Palka authored
      Here convert_to_void always completes the type of an indirection or
      id-expression, but according to [expr.context] an lvalue-to-rvalue
      conversion is applied to a discarded-value expression only if "the
      expression is a glvalue of volatile-qualified type".  This patch
      restricts convert_to_void's type completion to match.
      
      	PR c++/111419
      
      gcc/cp/ChangeLog:
      
      	* cvt.cc (convert_to_void) <case INDIRECT_REF>: Only call
      	complete_type if the type is volatile.
      	<case VAR_DECL>: Likewise.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp2a/concepts-requires36.C: New test.
      	* g++.dg/expr/discarded1.C: New test.
      	* g++.dg/expr/discarded1a.C: New test.
      b510b83a
    • Patrick Palka's avatar
      c++: constness of decltype of NTTP object [PR99631] · ddd064e3
      Patrick Palka authored
      This corrects resolving decltype of a (class) NTTP object as per
      [dcl.type.decltype]/1.2 and [temp.param]/6 in the type-dependent case.
      
      Note that in the non-dependent case we resolve the decltype ahead of
      time, in which case finish_decltype_type drops the const VIEW_CONVERT_EXPR
      wrapper around the TEMPLATE_PARM_INDEX, and the latter has the desired
      non-const type.
      
      In the type-dependent case, at instantiation time tsubst drops the
      VIEW_CONVERT_EXPR since the substituted NTTP is the already-const object
      created by get_template_parm_object.  So in this case finish_decltype_type
      sees the const object, which this patch now adds special handling for.
      
      	PR c++/99631
      
      gcc/cp/ChangeLog:
      
      	* semantics.cc (finish_decltype_type): For an NTTP object,
      	return its type modulo cv-quals.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp2a/nontype-class60.C: New test.
      ddd064e3
    • Juzhe-Zhong's avatar
      RISC-V: Add FNMS floating-point VLS tests · 131c1df8
      Juzhe-Zhong authored
      Add tests and committed.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/autovec/vls/def.h: Add FNMS VLS modes tests.
      	* gcc.target/riscv/rvv/autovec/vls/fnms-1.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fnms-2.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fnms-3.c: New test.
      131c1df8
    • Thomas Schwinge's avatar
      LTO: Get rid of 'lto_mode_identity_table' · c81d9b9f
      Thomas Schwinge authored
      
      This, in particular, resolves LTO ICEs with big 'machine_mode's, as for RISC-V.
      ('mode_table' in 'lto_file_decl_data' still is 'unsigned char'; changing that
      is still to be done (for use in offloading compilation), but is not trivial.)
      For now, get rid of 'lto_mode_identity_table' to resolve the RISC-V LTO ICEs;
      we don't need an actual table for a 1-to-1 mapping.
      
      	gcc/lto/
      	* lto-common.cc (lto_mode_identity_table): Remove.
      	(lto_file_finalize) [!ACCEL_COMPILER]: 'NULL'-intialize
      	'file_data->mode_table'.
      	(lto_fe_init): Don't initialize 'lto_mode_identity_table'.
      	* lto-common.h (lto_mode_identity_table): Remove.
      	gcc/
      	* tree-streamer.h (bp_unpack_machine_mode): If
      	'ib->file_data->mode_table' not available, apply 1-to-1 mapping.
      
      Co-authored-by: default avatarPan Li <pan2.li@intel.com>
      c81d9b9f
    • Juzhe-Zhong's avatar
      RISC-V: Fix RVV can change mode class bug · e1817426
      Juzhe-Zhong authored
      After support the VLS mode conversion, current case triggers a latent bug that we are
      lucky we didn't encounter.
      
      This is a real bug in 'cprop_hardreg':
      
      orig:RVVMF8BI,16,16
      new:V32BI,32,0
      during RTL pass: cprop_hardreg
      auto.c: In function 'main':
      auto.c:79:1: internal compiler error: in partial_subreg_p, at rtl.h:3186
         79 | }
            | ^
      0x10979a7 partial_subreg_p(machine_mode, machine_mode)
              ../../../../gcc/gcc/rtl.h:3186
      0x1723eda mode_change_ok
              ../../../../gcc/gcc/regcprop.cc:402
      0x1724007 maybe_mode_change
              ../../../../gcc/gcc/regcprop.cc:436
      0x172445d find_oldest_value_reg
              ../../../../gcc/gcc/regcprop.cc:489
      0x172534d copyprop_hardreg_forward_1
              ../../../../gcc/gcc/regcprop.cc:808
      0x1727017 cprop_hardreg_bb
              ../../../../gcc/gcc/regcprop.cc:1358
      0x17272f7 execute
              ../../../../gcc/gcc/regcprop.cc:1425
      
      When trying to do reg copy propagation between RVVMF8BI (precision = 16,16)
      and V32BI (precision = 32,0).
      
      The assertion failed in partial_subreg_p:
      gcc_checking_assert (ordered_p (outer_prec, inner_prec));
      
      In regcprop.cc:
      
        if (partial_subreg_p (orig_mode, new_mode))
          return false;
      
      If orig_mode (RVVMF8BI) smaller than new_mode (V32BI), we don't do the hard reg propogation.
      However, the 'partial_subreg_p' cause ICE since gcc_checking_assert (ordered_p (outer_prec, inner_prec)).
      
      After analysis in aarch64.cc, they do careful block in 'TARGET_CAN_CHANGE_MODE_CLASS'.
      So it's reasonable block regcprop when old mode size maybe_lt than new mode size since we won't do the
      copy propgation.
      
      gcc/ChangeLog:
      
      	* config/riscv/riscv.cc (riscv_can_change_mode_class): Block unordered VLA and VLS modes.
      e1817426
    • Richard Wai's avatar
      ada: TSS finalize address subprogram generation for constrained... · 00588867
      Richard Wai authored
      
      ...subtypes of unconstrained synchronized private extensions should take
      care to designate the corresponding record of the underlying concurrent
      type.
      
      When generating TSS finalize address subprograms for class-wide types of
      constrained root types, it follows the parent chain looking for the
      first "non-constrained" type. It is possible that such a type is a
      private extension with the “synchronized” keyword, in which case the
      underlying type is a concurrent type. When that happens, the designated
      type of the finalize address subprogram should be the corresponding
      record’s class-wide-type.
      
      gcc/ada/ChangeLog:
      	* exp_ch3.adb (Expand_Freeze_Class_Wide_Type): Expanded comments
      	explaining why TSS Finalize_Address is not generated for
      	concurrent class-wide types.
      	* exp_ch7.adb (Make_Finalize_Address_Stmts): Handle cases where the
      	underlying non-constrained parent type is a concurrent type, and
      	adjust the designated type to be the corresponding record’s
      	class-wide type.
      
      gcc/testsuite/ChangeLog:
      
      	* gnat.dg/sync_tag_finalize.adb: New test.
      
      Signed-off-by: default avatarRichard Wai <richard@annexi-strayline.com>
      00588867
    • Richard Wai's avatar
      ada: Private extensions with the keyword "synchronized" are always limited. · eceb45bb
      Richard Wai authored
      
      GNAT was relying on synchronized private type extensions deriving from a
      concurrent interface to determine its limitedness. This does not cover the case
      where such an extension derives a limited interface. RM-7.6(6/2) makes is clear
      that "synchronized" in a private extension implies the derived type is limited.
      GNAT should explicitly check for the presence of "synchronized" in a private
      extension declaration, and it should have the same effect as the presence of
      “limited”.
      
      gcc/ada/ChangeLog:
      
      	* sem_ch3.adb (Build_Derived_Record_Type): Treat presence of
      	keyword "synchronized" the same as "limited" when determining if a
      	private extension is limited.
      
      gcc/testsuite/ChangeLog:
      
      	* gnat.dg/sync_tag_discriminals.adb: New test.
      	* gnat.dg/sync_tag_limited.adb: New test.
      
      Signed-off-by: default avatarRichard Wai <richard@annexi-strayline.com>
      eceb45bb
    • Juzhe-Zhong's avatar
      RISC-V: Support VLS unary floating-point patterns · 5b945243
      Juzhe-Zhong authored
      Extend current VLA patterns with VLS modes.
      
      Regression all passed.
      
      gcc/ChangeLog:
      
      	* config/riscv/autovec.md: Extend VLS modes.
      	* config/riscv/vector.md: Ditto.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/autovec/vls/def.h: Add unary test.
      	* gcc.target/riscv/rvv/autovec/vls/neg-2.c: New test.
      5b945243
    • Marc Poulhiès's avatar
      ada: Refine upper array bound for bit packed array · 04726932
      Marc Poulhiès authored
      When using bit-packed arrays, the compiler creates new array subtypes of
      1-bit component indexed by integers. The existing routine checks the
      index subtype to find the min/max values. Bit-packed arrays being
      indexed by integers, the routines gives up as returning the maximum
      possible integer carries no useful information.
      
      This change adds a simple max_value routine that can evaluate very
      simple expressions by substituting variables by their min/max value.
      Bit-packed array subtypes are currently declared as:
      
        subtype bp_array is packed_bytes1 (0 .. integer((1 * Var +  7) / 8 - 1));
      
      The simple max_value evaluator handles the bare minimum for this
      expression pattern.
      
      gcc/ada/ChangeLog:
      
      	* gcc-interface/utils.cc (max_value): New.
      	* gcc-interface/gigi.h (max_value): New.
      	* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Array_Subtype>:
      	When computing gnu_min/gnu_max, try to use max_value if there is
      	an initial expression.
      04726932
    • Javier Miranda's avatar
      ada: Crash processing type invariants on child subprogram · 54c16824
      Javier Miranda authored
      gcc/ada/
      
      	* contracts.adb
      	(Has_Public_Visibility_Of_Subprogram): Add missing support for
      	child subprograms.
      54c16824
    • Richard Biener's avatar
      tree-optimization/111465 - bougs jump threading with no-copy src block · 564ecb7d
      Richard Biener authored
      The following avoids to forward thread a path with a EDGE_NO_COPY_SRC_BLOCK
      block that became non-empty due to folding.
      
      	PR tree-optimization/111465
      	* tree-ssa-threadupdate.cc (fwd_jt_path_registry::thread_block_1):
      	Cancel the path when a EDGE_NO_COPY_SRC_BLOCK became non-empty.
      
      	* g++.dg/torture/pr111465.C: New testcase.
      564ecb7d
    • Richard Biener's avatar
      c/111468 - add unordered compare and pointer diff to GIMPLE FE parsing · 836e2cff
      Richard Biener authored
      The following adds __UN{LT,LE,GT,GE,EQ}, __UNORDERED and __ORDERED
      operator parsing support and support for parsing - as POINTER_DIFF_EXPR.
      
      	PR c/111468
      gcc/c/
      	* gimple-parser.cc (c_parser_gimple_binary_expression): Add
      	return type argument.
      	(c_parser_gimple_statement): Adjust.
      	(c_parser_gimple_paren_condition): Likewise.
      	(c_parser_gimple_binary_expression): Use passed in return type,
      	add support for - as POINTER_DIFF_EXPR, __UN{LT,LE,GT,GE,EQ},
      	__UNORDERED and __ORDERED.
      
      gcc/testsuite/
      	* gcc.dg/gimplefe-50.c: New testcase.
      	* gcc.dg/gimplefe-51.c: Likewise.
      836e2cff
    • Juzhe-Zhong's avatar
      RISC-V: Support VLS floating-point FMA/FNMA/FMS auto-vectorization · 28569e79
      Juzhe-Zhong authored
      Support VLS floating-point FMA/FNMA/FMS patterns.
      
      Regression no difference after this patch, Committed.
      
      gcc/ChangeLog:
      
      	* config/riscv/autovec.md: Extend VLS floating-point modes.
      	* config/riscv/vector.md: Ditto.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/autovec/vls/def.h: Add FMS tests.
      	* gcc.target/riscv/rvv/autovec/vls/fma-5.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fma-6.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fma-7.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fms-1.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fms-2.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fms-3.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fnma-5.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fnma-6.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fnma-7.c: New test.
      28569e79
    • Jakub Jelinek's avatar
      match.pd: Some build_nonstandard_integer_type tweaks · 5c5851bd
      Jakub Jelinek authored
      As discussed earlier, using build_nonstandard_integer_type blindly for all
      INTEGRAL_TYPE_Ps is problematic now that we have BITINT_TYPE, because it
      always creates an INTEGRAL_TYPE with some possibly very large precision.
      The following patch attempts to deal with 3 such spots in match.pd, others
      still need looking at.
      
      In the first case, I think it is quite expensive/undesirable to create
      a non-standard INTEGER_TYPE with possibly huge precision and then
      immediately just see type_has_mode_precision_p being false for it, or even
      worse introducing a cast to TImode or OImode or XImode INTEGER_TYPE which
      nothing will be able to actually handle.  128-bit or 64-bit (on 32-bit
      targets) types are the largest supported by the backend, so the following
      patch avoids creating and matching conversions to larger types, it is
      an optimization anyway and so should be used when it is cheap that way.
      
      In the second hunk, I believe the uses of build_nonstandard_integer_type
      aren't useful at all.  It is when matching a ? -1 : 0 and trying to express
      it as say -(type) (bool) a etc., but this is all GIMPLE only, where most of
      integral types with same precision/signedness are compatible and we know
      -1 is representable in that type, so I really don't see any reason not to
      perform the negation of a [0, 1] valued expression in type, rather
      than doing it in
      build_nonstandard_integer_type (TYPE_PRECISION (type), TYPE_UNSIGNED (type))
      (except that it breaks the BITINT_TYPEs).  I don't think we need to do
      something like range_check_type.
      While in there, I've also noticed it was using a (with {
      tree booltrue = constant_boolean_node (true, boolean_type_node);
      } and removed that + replaced uses of booltrue with boolean_true_node
      which the above function always returns.
      
      2023-09-19  Jakub Jelinek  <jakub@redhat.com>
      
      	* match.pd ((x << c) >> c): Don't call build_nonstandard_integer_type
      	nor check type_has_mode_precision_p for width larger than [TD]Imode
      	precision.
      	(a ? CST1 : CST2): Don't use build_nonstandard_type, just convert
      	to type.  Use boolean_true_node instead of
      	constant_boolean_node (true, boolean_type_node).  Formatting fixes.
      5c5851bd
    • Juzhe-Zhong's avatar
      RISC-V: Support integer FMA/FNMA VLS modes autovectorization · 8e094801
      Juzhe-Zhong authored
      Simpily extend the current VLA iterator and patterns.
      
      Regression passed with no difference.
      
      gcc/ChangeLog:
      
      	* config/riscv/autovec.md: Add VLS modes.
      	* config/riscv/vector.md: Ditto.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/autovec/vls/def.h: Add VLS FMA/FNMA test.
      	* gcc.target/riscv/rvv/autovec/vls/fma-1.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fma-2.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fma-3.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fma-4.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fnma-1.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fnma-2.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fnma-3.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/fnma-4.c: New test.
      8e094801
    • Jakub Jelinek's avatar
      small _BitInt tweaks · e16dee6d
      Jakub Jelinek authored
      I think it is undesirable when being asked for signed_type_for
      of unsigned _BitInt(1) (which is valid) to get signed _BitInt(1) (which is
      invalid, the standard only allows signed _BitInt(2) and larger), so the
      patch returns 1-bit signed INTEGER_TYPE for those cases.
      Furthermore it asserts in build_bitint_type that nothing attempts to create
      signed _BitInt(0), unsigned _BitInt(0) or signed _BitInt(1) types.
      
      2023-09-18  Jakub Jelinek  <jakub@redhat.com>
      
      gcc/
      	* tree.cc (build_bitint_type): Assert precision is not 0, or
      	for signed types 1.
      	(signed_or_unsigned_type_for): Return INTEGER_TYPE for signed variant
      	of unsigned _BitInt(1).
      gcc/c-family/
      	* c-common.cc (c_common_signed_or_unsigned_type): Return INTEGER_TYPE
      	for signed variant of unsigned _BitInt(1).
      e16dee6d
    • Jakub Jelinek's avatar
      libgomp: Handle NULL environ like pointer to NULL pointer [PR111413] · 15345980
      Jakub Jelinek authored
      clearenv function just sets environ to NULL (after sometimes freeing it),
      rather than setting it to a pointer to NULL, and our code was assuming
      it is always non-NULL.
      
      Fixed thusly, the change seems to be large but actually is just
      +  if (environ)
           for (env = environ; *env != 0; env++)
      plus reindentation.  I've also noticed the block after this for loop
      was badly indented (too much) and fixed that too.
      
      No testcase added, as it needs clearenv + dlopen.
      
      2023-09-19  Jakub Jelinek  <jakub@redhat.com>
      
      	PR libgomp/111413
      	* env.c (initialize_env): Don't dereference environ if it is NULL.
      	Reindent.
      15345980
    • Prathamesh Kulkarni's avatar
      [testsuite][aarch64] Adjust vect_copy_lane_1.c for new code-gen. · 98c25cfc
      Prathamesh Kulkarni authored
      gcc/testsuite/ChangeLog:
      	* gcc.target/aarch64/vect_copy_lane_1.c: Scan for zip1 instead
      	of ins for float32x2_t, int32x2_t and uint32x2_t tests.
      98c25cfc
    • Lehua Ding's avatar
      RISC-V: Refactor and cleanup fma patterns · 95d2ce05
      Lehua Ding authored
      At present, FMA autovec's patterns do not fully use the corresponding pattern
      in vector.md. The previous reason is that the merge operand of pattern in
      vector.md cannot be VUNDEF. Now allowing it to be VUNDEF, reunify insn used for
      reload pass into vector.md, and the corresponding vlmax pattern in autovec.md
      is used for combine. This patch also refactors the corresponding combine
      pattern inside autovec-opt.md and removes the unused ones.
      
      gcc/ChangeLog:
      
      	* config/riscv/autovec-opt.md (*<optab>_fma<mode>):
      	Removed old combine patterns.
      	(*single_<optab>mult_plus<mode>): Ditto.
      	(*double_<optab>mult_plus<mode>): Ditto.
      	(*sign_zero_extend_fma): Ditto.
      	(*zero_sign_extend_fma): Ditto.
      	(*double_widen_fma<mode>): Ditto.
      	(*single_widen_fma<mode>): Ditto.
      	(*double_widen_fnma<mode>): Ditto.
      	(*single_widen_fnma<mode>): Ditto.
      	(*double_widen_fms<mode>): Ditto.
      	(*single_widen_fms<mode>): Ditto.
      	(*double_widen_fnms<mode>): Ditto.
      	(*single_widen_fnms<mode>): Ditto.
      	(*reduc_plus_scal_<mode>): Adjust name.
      	(*widen_reduc_plus_scal_<mode>): Adjust name.
      	(*dual_widen_fma<mode>): New combine pattern.
      	(*dual_widen_fmasu<mode>): Ditto.
      	(*dual_widen_fmaus<mode>): Ditto.
      	(*dual_fma<mode>): Ditto.
      	(*single_fma<mode>): Ditto.
      	(*dual_fnma<mode>): Ditto.
      	(*single_fnma<mode>): Ditto.
      	(*dual_fms<mode>): Ditto.
      	(*single_fms<mode>): Ditto.
      	(*dual_fnms<mode>): Ditto.
      	(*single_fnms<mode>): Ditto.
      	* config/riscv/autovec.md (fma<mode>4):
      	Reafctor fma pattern.
      	(*fma<VI:mode><P:mode>): Removed.
      	(fnma<mode>4): Reafctor.
      	(*fnma<VI:mode><P:mode>): Removed.
      	(*fma<VF:mode><P:mode>):  Removed.
      	(*fnma<VF:mode><P:mode>):  Removed.
      	(fms<mode>4):  Reafctor.
      	(*fms<VF:mode><P:mode>):  Removed.
      	(fnms<mode>4): Reafctor.
      	(*fnms<VF:mode><P:mode>): Removed.
      	* config/riscv/riscv-protos.h (prepare_ternary_operands):
      	Adjust prototype.
      	* config/riscv/riscv-v.cc (prepare_ternary_operands): Refactor.
      	* config/riscv/vector.md (*pred_mul_plus<mode>_undef): New pattern.
      	(*pred_mul_plus<mode>): Removed.
      	(*pred_mul_plus<mode>_scalar): Removed.
      	(*pred_mul_plus<mode>_extended_scalar): Removed.
      	(*pred_minus_mul<mode>_undef):  New pattern.
      	(*pred_minus_mul<mode>): Removed.
      	(*pred_minus_mul<mode>_scalar): Removed.
      	(*pred_minus_mul<mode>_extended_scalar): Removed.
      	(*pred_mul_<optab><mode>_undef):  New pattern.
      	(*pred_mul_<optab><mode>): Removed.
      	(*pred_mul_<optab><mode>_scalar): Removed.
      	(*pred_mul_neg_<optab><mode>_undef):  New pattern.
      	(*pred_mul_neg_<optab><mode>): Removed.
      	(*pred_mul_neg_<optab><mode>_scalar): Removed.
      95d2ce05
    • Tsukasa OI's avatar
      RISC-V: Fix typos on comments (SVE -> RVV) · 7f4fc870
      Tsukasa OI authored
      We have the 'V' extension (RVV), not SVE from AArch64.
      
      gcc/ChangeLog:
      
      	* config/riscv/riscv-vector-builtins.cc
      	(builtin_decl, expand_builtin): Replace SVE with RVV.
      7f4fc870
    • Tsukasa OI's avatar
      RISC-V: Add builtin .def file dependencies · f45cca26
      Tsukasa OI authored
      riscv-builtins.cc includes riscv-cmo.def and riscv-scalar-crypto.def
      (making dependencies) but their dependencies must be explicitly defined at
      the configuration file, t-riscv.
      
      They were the last two .def files without correct dependency information.
      
      gcc/ChangeLog:
      
      	* config/riscv/t-riscv: Add dependencies for riscv-builtins.cc,
      	riscv-cmo.def and riscv-scalar-crypto.def.
      f45cca26
    • GCC Administrator's avatar
      Daily bump. · 6b78e9a5
      GCC Administrator authored
      6b78e9a5
  2. Sep 18, 2023
    • Pan Li's avatar
      RISC-V: Support VLS mode for vec_set · aad0c3e1
      Pan Li authored
      
      This patch would like to add the VLS support vec_set, both INT
      and FP are included.
      
      Give sample code as below:
      
      typedef long long vl_t \
        __attribute__((vector_size(2 * sizeof (long long))));
      
      vl_t init_vl (vl_t v, unsigned index, unsigned value)
      {
        v[index] = value;
      
        return v;
      }
      
      Before this patch:
      init_vl:
        addi     sp,sp,-16
        vsetivli zero,2,e64,m1,ta,ma
        vle64.v  v1,0(a1)
        vse64.v  v1,0(sp)
        slli     a4,a2,32
        srli     a2,a4,29
        add      a2,sp,a2
        slli     a3,a3,32
        srli     a3,a3,32
        sd       a3,0(a2)
        vle64.v  v1,0(sp)
        vse64.v  v1,0(a0)
        addi     sp,sp,16
        jr       ra
      
      After this patch:
      init_vl:
        vsetivli    zero,2,e64,m1,ta,ma
        vle64.v     v1,0(a1)
        slli        a3,a3,32
        srli        a3,a3,32
        addi        a5,a2,1
        vsetvli     zero,a5,e64,m1,tu,ma
        vmv.v.x     v2,a3
        vslideup.vx v1,v2,a2
        vsetivli    zero,2,e64,m1,ta,ma
        vse64.v     v1,0(a0)
        ret
      
      Please note this patch depends the RVV SCALAR_MOVE_MERGED_OP bugfix.
      
      gcc/ChangeLog:
      
      	* config/riscv/autovec.md: Extend to vls mode.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/autovec/vls/def.h: New macros.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-1.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-10.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-11.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-12.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-13.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-14.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-15.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-16.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-17.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-18.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-19.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-2.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-20.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-21.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-22.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-3.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-4.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-5.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-6.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-7.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-8.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/vec-set-9.c: New test.
      
      Signed-off-by: default avatarPan Li <pan2.li@intel.com>
      aad0c3e1
    • Pan Li's avatar
      RISC-V: Bugfix for scalar move with merged operand · 28f16f6d
      Pan Li authored
      
      Given below example for VLS mode
      
      void
      test (vl_t *u)
      {
        vl_t t;
        long long *p = (long long *)&t;
      
        p[0] = p[1] = 2;
      
        *u = t;
      }
      
      The vec_set will simplify the insn to vmv.s.x when index is 0, without
      merged operand. That will result in some problems in DCE, aka:
      
      1:  137[DI] = a0
      2:  138[V2DI] = 134[V2DI]                              // deleted by DCE
      3:  139[DI] = #2                                       // deleted by DCE
      4:  140[DI] = #2                                       // deleted by DCE
      5:  141[V2DI] = vec_dup:V2DI (139[DI])                 // deleted by DCE
      6:  138[V2DI] = vslideup_imm (138[V2DI], 141[V2DI], 1) // deleted by DCE
      7:  135[V2DI] = 138[V2DI]                              // deleted by DCE
      8:  142[V2DI] = 135[V2DI]                              // deleted by DCE
      9:  143[DI] = #2
      10: 142[V2DI] = vec_dup:V2DI (143[DI])
      11: (137[DI]) = 142[V2DI]
      
      The higher 64 bits of 142[V2DI] is unknown here and it generated incorrect
      code when store back to memory. This patch would like to fix this issue
      by adding a new SCALAR_MOVE_MERGED_OP for vec_set.
      
      Please note this patch doesn't enable VLS for vec_set, the underlying
      patches will support this soon.
      
      gcc/ChangeLog:
      
      	* config/riscv/autovec.md: Bugfix.
      	* config/riscv/riscv-protos.h (SCALAR_MOVE_MERGED_OP): New enum.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/base/scalar-move-merged-run-1.c: New test.
      
      Signed-off-by: default avatarPan Li <pan2.li@intel.com>
      28f16f6d
    • Andrew Pinski's avatar
      MATCH: Make zero_one_valued_p non-recursive fully · 7ea501d3
      Andrew Pinski authored
      So it turns out VN can't handle any kind of recursion for match. In this
      case we have `b = a & -1` and we try to match a as being zero_one_valued_p
      and VN returns b as being the value and we just go into an infinite loop at
      this point.
      
      OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
      
      Note genmatch should warn (or error out) if this gets detected so I filed PR 111446
      which I will be looking into next week or the week after so we don't run into
      this issue again.
      
      	PR tree-optimization/111442
      
      gcc/ChangeLog:
      
      	* match.pd (zero_one_valued_p): Have the bit_and match not be
      	recursive.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.c-torture/compile/pr111442-1.c: New test.
      7ea501d3
    • Andrew Pinski's avatar
      MATCH: Avoid recursive zero_one_valued_p for conversions · 951d3c19
      Andrew Pinski authored
      So when VN finds a name which has a nop conversion, it says
      both names are equivalent to each other and the valuaization
      function for one will return the other. This normally does not
      cause any issues as there is no recursive matches. But after
      r14-4038-gb975c0dc3be285, there was one added. So we would
      do an infinite recursion on the match and never finish.
      This fixes the issue (and adds a comment in match.pd) by
      for converts just handle one level instead of being recursive
      always.
      
      OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
      
      Note the testcase was reduced from tree-ssa-loop-niter.cc and then
      changed slightly into C rather than C++ but it still needs exceptions
      turned on get the IR that VN would produce this equivalence relationship
      going on. Also had to turn off early inline to force put to be inlined later.
      
      	PR tree-optimization/111435
      
      gcc/ChangeLog:
      
      	* match.pd (zero_one_valued_p): Don't do recursion
      	on converts.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.c-torture/compile/pr111435-1.c: New test.
      951d3c19
    • Patrick Palka's avatar
      c++: optimize unifying nested templated classes [PR89231] · 80968d5f
      Patrick Palka authored
      Since the LHS of a qualified-id is a non-deduced context, it effectively
      means we can't deduce from outer template arguments of a class template
      specialization.  And checking for equality between the TI_TEMPLATE of a
      class specialization parm/arg already implies that the outer template
      arguments are the same.  Hence recursing into outer template arguments
      during unification of class specializations is redundant, so this patch
      makes unify recurse only into innermost arguments.
      
      This incidentally fixes the testcase from PR89231 because there
      more_specialized_partial_inst wrongly considers the two partial
      specializations to be unordered ultimately because unify for identical
      parm=arg=A<Ps...>::Collect<N...> gets confused when it recurses into
      parm=arg={Ps...} since Ps is outside the (innermost) level of tparms
      that we're actually deducing.
      
      	PR c++/89231
      
      gcc/cp/ChangeLog:
      
      	* pt.cc (try_class_unification): Strengthen TI_TEMPLATE equality
      	test by not calling most_general_template.  Only unify the
      	innermost levels of template arguments.
      	(unify) <case CLASS_TYPE>: Only unify the innermost levels of
      	template arguments, and only if the template is primary.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp0x/variadic-partial3.C: New test.
      80968d5f
    • Patrick Palka's avatar
      c++: non-dependent assignment checking [PR63198, PR18474] · 6e92a6a2
      Patrick Palka authored
      This patch makes us recognize and check non-dependent simple assigments
      ahead of time, like we already do for compound assignments.  This means
      the templated representation of such assignments will now usually have
      an implicit INDIRECT_REF (due to the reference return type), which the
      -Wparentheses code needs to handle.  As a drive-by improvement, this
      patch also makes maybe_convert_cond issue -Wparentheses warnings ahead
      of time, and removes a seemingly unnecessary suppress_warning call in
      build_x_modify_expr.
      
      On the libstdc++ side, some tests were attempting to modify a data
      member from a uninstantiated const member function, which this patch
      minimally fixes by making the data member mutable.
      
      	PR c++/63198
      	PR c++/18474
      
      gcc/cp/ChangeLog:
      
      	* semantics.cc (maybe_convert_cond): Look through implicit
      	INDIRECT_REF when deciding whether to issue a -Wparentheses
      	warning, and consider templated assignment expressions as well.
      	(finish_parenthesized_expr): Look through implicit INDIRECT_REF
      	when suppressing -Wparentheses warning.
      	* typeck.cc (build_x_modify_expr): Check simple assignments
      	ahead time too, not just compound assignments.  Give the second
      	operand of MODOP_EXPR a non-null type so that it's not considered
      	always instantiation-dependent.  Don't call suppress_warning.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp0x/static_assert15.C: Expect diagnostic for
      	non-constant static_assert condition.
      	* g++.dg/expr/unary2.C: Remove xfails.
      	* g++.dg/template/init7.C: Make initializer type-dependent to
      	preserve intent of test.
      	* g++.dg/template/recurse3.C: Likewise for the erroneous
      	statement.
      	* g++.dg/template/non-dependent26.C: New test.
      	* g++.dg/warn/Wparentheses-32.C: New test.
      
      libstdc++-v3/ChangeLog:
      
      	* testsuite/26_numerics/random/discard_block_engine/cons/seed_seq2.cc:
      	Make data member seed_seq::called mutable.
      	* testsuite/26_numerics/random/independent_bits_engine/cons/seed_seq2.cc:
      	Likewise.
      	* testsuite/26_numerics/random/linear_congruential_engine/cons/seed_seq2.cc:
      	Likewise.
      	* testsuite/26_numerics/random/mersenne_twister_engine/cons/seed_seq2.cc:
      	Likewise.
      	* testsuite/26_numerics/random/shuffle_order_engine/cons/seed_seq2.cc:
      	Likewise.
      	* testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed_seq2.cc:
      	Likewise.
      	* testsuite/ext/random/simd_fast_mersenne_twister_engine/cons/seed_seq2.cc:
      	Likewise.
      6e92a6a2
    • Patrick Palka's avatar
      c++: unifying identical tmpls from current inst [PR108347] · a6ac1fc6
      Patrick Palka authored
      Here more_specialized_partial_spec wrongly considers the two partial
      specializations to be unordered ultimately because unify for identical
      parm=arg=A<T>::C returns failure due to C being dependent.
      
      This patch fixes this by relaxing unify's early-exit identity test to
      also accept dependent decls; we can't deduce anything further from them
      anyway.  In passing this patch removes the CONST_DECL case of unify:
      we should never see the CONST_DECL version of a template parameter here,
      and for other CONST_DECLs (such as enumerators) it seems we can rely on
      them to already have been folded to their DECL_INITIAL.
      
      	PR c++/108347
      
      gcc/cp/ChangeLog:
      
      	* pt.cc (unify): Return unify_success for identical dependent
      	DECL_P 'arg' and 'parm'.
      	<case CONST_DECL>: Remove handling.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/template/ttp41.C: New test.
      a6ac1fc6
Loading