Commit Graph

199697 Commits

Author SHA1 Message Date
Jakub Jelinek
1719fa40c4 libiberty: Make strstr.c in libiberty ANSI compliant
On Fri, Nov 13, 2020 at 11:53:43AM -0700, Jeff Law via Gcc-patches wrote:
>
> On 5/1/20 6:06 PM, Seija Kijin via Gcc-patches wrote:
> > The original code in libiberty says "FIXME" and then says it has not been
> > validated to be ANSI compliant. However, this patch changes the function to
> > match implementations that ARE compliant, and such code is in the public
> > domain.
> >
> > I ran the test results, and there are no test failures.
>
> Thanks.  This seems to be the standard "simple" strstr implementation. 
> There's significantly faster implementations available, but I doubt it's
> worth the effort as the version in this file only gets used if there is
> no system strstr.c.

Except that PR109306 says the new version is non-compliant and
is certainly slower than what we used to have.  The only problem I see
on the old version (sure, it is not very fast version) is that for
strstr ("abcd", "") it returned "abcd"+4 rather than "abcd" because
strchr in that case changed p to point to the last character and then
strncmp returned 0.

The question reported in PR109306 is whether memcmp is required not to
access characters beyond the first difference or not.
For all of memcmp/strcmp/strncmp, C17 says:
"The sign of a nonzero value returned by the comparison functions memcmp, strcmp, and strncmp
is determined by the sign of the difference between the values of the first pair of characters (both
interpreted as unsigned char) that differ in the objects being compared."
but then in memcmp description says:
"The memcmp function compares the first n characters of the object pointed to by s1 to the first n
characters of the object pointed to by s2."
rather than something similar to strncmp wording:
"The strncmp function compares not more than n characters (characters that follow a null character
are not compared) from the array pointed to by s1 to the array pointed to by
s2."
So, while for strncmp it seems clearly well defined when there is zero
terminator before reaching the n, for memcmp it is unclear if say
int
memcmp (const void *s1, const void *s2, size_t n)
{
  int ret = 0;
  size_t i;
  const unsigned char *p1 = (const unsigned char *) s1;
  const unsigned char *p2 = (const unsigned char *) s2;

  for (i = n; i; i--)
    if (p1[i - 1] != p2[i - 1])
      ret = p1[i - 1] < p2[i - 1] ? -1 : 1;
  return ret;
}
wouldn't be valid implementation (one which always compares all characters
and just returns non-zero from the first one that differs).

So, shouldn't we just revert and handle the len == 0 case correctly?

I think almost nothing really uses it, but still, the old version
at least worked nicer with a fast strchr.
Could as well strncmp (p + 1, s2 + 1, len - 1) if that is preferred
because strchr already compared the first character.

2023-04-02  Jakub Jelinek  <jakub@redhat.com>

	PR other/109306
	* strstr.c: Revert the 2020-11-13 changes.
	(strstr): Return s1 if len is 0.
2023-04-02 20:05:31 +02:00
Juzhe-Zhong
802ab7d0db RISC-V: Fix reload fail issue on vector mac instructions
Vector mac instructions has LRA issue during high register pressure,
It will failed to reload when picked first alternative, because it will
require reload 2 input operands into same register as input operand,
so we adding an extra operand to generate one more move pattern to
relax such restricted constraint.

This path fix ICE of ternary intrinsic:
bug.C:144:2: error: unable to find a register to spill
  144 |  }
      |  ^
bug.C:144:2: error: this is the insn:
(insn 462 972 919 24 (set (reg/v:VNx8DI 546 [orig:192 var_10 ] [192])
        (if_then_else:VNx8DI (unspec:VNx8BI [
                    (reg/v:VNx8BI 603 [orig:179 var_13 ] [179])
                    (const_int 13 [0xd])
                    (const_int 2 [0x2])
                    (const_int 0 [0]) repeated x2
                    (reg:SI 66 vl)
                    (reg:SI 67 vtype)
                ] UNSPEC_VPREDICATE)
            (plus:VNx8DI (mult:VNx8DI (reg/v:VNx8DI 605 [orig:190 var_6 ] [190])
                    (reg/v:VNx8DI 547 [orig:160 var_51 ] [160]))
                (reg/v:VNx8DI 548 [orig:161 var_52 ] [161]))
            (reg/v:VNx8DI 605 [orig:190 var_6 ] [190]))) "bug.C":131:48 4171 {*pred_maddvnx8di}
     (expr_list:REG_DEAD (reg/v:VNx8DI 605 [orig:190 var_6 ] [190])
        (expr_list:REG_DEAD (reg/v:VNx8BI 603 [orig:179 var_13 ] [179])
            (expr_list:REG_DEAD (reg/v:VNx8DI 547 [orig:160 var_51 ] [160])
                (expr_list:REG_DEAD (reg/v:VNx8DI 548 [orig:161 var_52 ] [161])
                    (nil))))))

gcc/ChangeLog:

	* config/riscv/vector.md: Fix RA constraint.

gcc/testsuite/ChangeLog:

	* g++.target/riscv/rvv/base/bug-19.C: New test.
	* g++.target/riscv/rvv/base/bug-20.C: New test.
	* g++.target/riscv/rvv/base/bug-21.C: New test.
	* g++.target/riscv/rvv/base/bug-22.C: New test.

Signed-off-by: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
Co-authored-by: kito-cheng <kito.cheng@sifive.com>
2023-04-02 16:31:22 +08:00
Juzhe-Zhong
db4f7a9b47 RISC-V: Fix ICE and codegen error of scalar move in RV32 system.
We need to reset the AVL to 0 or 1 for scalar move for RV32 system,
For any non-zero AVL input, we set that to 1, and zero will keep as zero.

We are using wrong way (by andi with 1) before to achieve that, and it
will cause ICE with const_int, and also wrong behavior, so now we have
two code path, one for const_int and one for non-const_int.

bug.C:144:2: error: unrecognizable insn:
  144 |  }
      |  ^
(insn 684 683 685 26 (set (reg:SI 513)
        (and:SI (const_int 4 [0x4])
            (const_int 1 [0x1]))) "bug.C":115:47 -1
     (nil))

andi a4,a4,1 ===> sgtu a4,a4,zero
vsetlvi tu        vsetvli tu
vlse              vlse

gcc/ChangeLog:

	* config/riscv/riscv-protos.h (gen_avl_for_scalar_move): New function.
	* config/riscv/riscv-v.cc (gen_avl_for_scalar_move): New function.
	* config/riscv/vector.md: Fix scalar move bug.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/scalar_move-6.c: Adapt test.
	* gcc.target/riscv/rvv/base/scalar_move-9.c: New test.
2023-04-02 16:27:32 +08:00
GCC Administrator
236cde7202 Daily bump. 2023-04-02 00:16:59 +00:00
Patrick Palka
a5de246535 c++: NTTP constraint depending on outer parms [PR109160]
Here we're crashing during satisfaction for the NTTP 'C<B> auto V'
ultimately because convert_template_argument / unify don't pass all
outer template arguments to do_auto_deduction, and during satisfaction
we need to know all arguments.  While these callers do pass some outer
arguments, they are only sufficient to properly substitute the
(level-lowered) 'auto' and are not necessarily the entire set.

Fortunately it seems these callers have access to the full set of outer
arguments via convert_template_argument's 'in_decl' parameter and
unify's 'tparms' parameter.  So this patch adds a new parameter to
do_auto_deduction, used only during adc_unify deduction, through which
these callers can pass the enclosing (partially instantiated) template
and from which do_auto_deduction can obtain _all_ outer template
arguments for sake of satisfaction.

This patch also ensures that the 'in_decl' argument passed to
coerce_template_parms is always a TEMPLATE_DECL, which in turn allows us
to pass it as-is to do_auto_deduction; the only coerce_template_parms
caller that needed adjustment was tsubst_decl it seems.

	PR c++/109160

gcc/cp/ChangeLog:

	* cp-tree.h (do_auto_deduction): Add defaulted tmpl parameter.
	* pt.cc (convert_template_argument): Pass 'in_decl' as 'tmpl' to
	do_auto_deduction.
	(tsubst_decl) <case VAR_/TYPE_DECL>: Pass 'tmpl' instead of 't' as
	'in_decl' to coerce_template_parms.
	(unify) <case TEMPLATE_PARM_INDEX>: Pass TPARMS_PRIMARY_TEMPLATE
	as 'tmpl' to do_auto_deduction.
	(do_auto_deduction): Document default arguments.  Rename local
	variable 'tmpl' to 'ctmpl'.  Use 'tmpl' to obtain a full set of
	template arguments for satisfaction in the adc_unify case.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-placeholder12.C: New test.
2023-04-01 12:01:30 -04:00
Patrick Palka
b5e38b1c16 c++: improve "NTTP argument considered unused" fix [PR53164, PR105848]
r13-995-g733a792a2b2e16 worked around the problem of (pointer to)
function NTTP arguments not always getting marked as odr-used, by
redundantly calling mark_used on the substituted ADDR_EXPR callee of a
CALL_EXPR.  That is just a narrow workaround however, since it assumes
the function is later called, but the use as a template argument alone
should constitute an odr-use of the function (since template arguments
are an evaluated context, and we're really passing its address); we
shouldn't need to subsequently call or otherwise use the function NTTP
argument.

This patch fixes this in a more general way by walking the template
arguments of each specialization that's about to be instantiated and
redundantly calling mark_used on all entities used within.  As before,
the call to mark_used as it worst a no-op, but it compensates for the
situation where the specialization was first formed in a template context
in which mark_used is inhibited.

Another approach would be to call mark_used whenever we substitute a
TEMPLATE_PARM_INDEX, but that would result in many more redundant calls
to mark_used compared to this approach.  And as the second testcase
below illustrates, we also need to walk C++20 class NTTP arguments which
can be large and thus expensive to walk repeatedly.  The change to
invalid_tparm_referent_p is needed to avoid incorrectly rejecting class
NTTP arguments containing function pointers as in the testcase.

(The third testcase is unrelated to this fix, but it helped rule out an
earlier approach I was considering and it seems we don't have existing
test coverage for this situation.)

	PR c++/53164
	PR c++/105848

gcc/cp/ChangeLog:

	* pt.cc (invalid_tparm_referent_p): Accept ADDR_EXPR of
	FUNCTION_DECL.
	(instantiate_class_template): Call mark_template_arguments_used.
	(tsubst_copy_and_build) <case CALL_EXPR>: Revert r13-995 change.
	(mark_template_arguments_used): Define.
	(instantiate_body): Call mark_template_arguments_used.

gcc/testsuite/ChangeLog:

	* g++.dg/template/fn-ptr3a.C: New test.
	* g++.dg/template/fn-ptr3b.C: New test.
	* g++.dg/template/fn-ptr4.C: New test.
2023-04-01 10:19:08 -04:00
Thomas Koenig
b06464c7fb Change "long_double" into "long double" for C prototypes from Fortran.
gcc/fortran/ChangeLog:

	* dump-parse-tree.cc (get_c_type_name): Fix "long_long"
	type name to be "long long".
2023-04-01 10:22:58 +02:00
Jakub Jelinek
69044e11ac range-op-float: Further foperator_{,not_}equal::fold_range fix
On Fri, Mar 31, 2023 at 12:45:10PM +0200, Jakub Jelinek via Gcc-patches wrote:
>    - there is a missing case (not handled in this patch) where both operands
>      are known to be zeros, but not singleton zeros

This patch adds those cases.

2023-04-01  Jakub Jelinek  <jakub@redhat.com>

	* range-op-float.cc (foperator_equal::fold_range): If at least
	one of the op ranges is not singleton and neither is NaN and all
	4 bounds are zero, return [1, 1].
	(foperator_not_equal::fold_range): In the same case return [0, 0].
2023-04-01 09:32:20 +02:00
Jakub Jelinek
5fe05ffefd range-op-float: Further comparison fixes
On Fri, Mar 31, 2023 at 09:57:54AM +0200, Jakub Jelinek via Gcc-patches wrote:
> and so if maybe_isnan, they always return [0, 1].  Now, thinking about it,
> this is unnecessary pessimization, for the case where the ... block
> returns range_false (type) we actually could do it also if maybe_isnan (op1,
> op2), because if one or both operands are NAN, the comparison will be false,
> and if neither is NAN, the comparison will be also false.  Will fix
> incrementally today.

Here it is.
1) the foperator_{,not_}equal::fold_range cases
   - we have correctly first a case handling known_isnan on either operand,
     return there range_false (type) - EQ, resp. range_true (type) - NE
   - next we handle the singleton cases, maybe_isnan + singleton isn't
     singleton, so these are ok
   - there is a missing case (not handled in this patch) where both operands
     are known to be zeros, but not singleton zeros
   - there is some !maybe_isnan (op1, op2) handling which tries to prove
     when the operands are certainly not equal and results in
     range_false (type) - EQ, resp. range_true (type) - NE
   - otherwise range_true_and_false (type)
   Now, I think (and this patch implements it) that the !maybe_isnan (op1, op2)
   check is unnecessary.  If we prove that when ignoring maybe NANs, the
   ranges don't intersect and so the comparison is always false for EQ or
   always true for NE, if NANs can appear, it doesn't change anything on
   that either, for EQ if NAN appears, the result is false like what we
   proved for the finite ranges, for NE if NAN appears, the result is true
   like what we proved for the finite ranges
2) foperator_{lt,le,gt,ge}::fold_range cases
   - these have correctly known_isnan on either operand first and return
     there range_false (type)
   - then !maybe_isnan (op1, op2) condition guarded checks
   - finally range_true_and_false (type) - so do that for
     maybe_isnan (op1, op2)
   Here in the !maybe_isnan (op1, op2) guarded code we have some condition
   which results in range_true (type), another condition which results in
   range_false (type) and otherwise range_true_and_false (type).
   Now, the condition which results in range_false (type) can be IMHO done
   also for the maybe_isnan (op1, op2) cases, because it is [0, 0]
   if both operands are finite or [0, 0] if either operand is NAN.
3) finally, LTGT_EXPR wasn't handled at all.  LTGT_EXPR is the inverse
   comparision to UNEQ_EXPR, I believe both raise exceptions only if
   either operand is sNaN, UNEQ_EXPR is true if both operands are
   either equal or either of the operands is NAN, while LTGT_EXPR is
   true if the operands compare either smaller or larger and is false if
   either of the operands is NAN.

2023-04-01  Jakub Jelinek  <jakub@redhat.com>

	* range-op-float.cc (foperator_equal::fold_range): Perform the
	non-singleton handling regardless of maybe_isnan (op1, op2).
	(foperator_not_equal::fold_range): Likewise.
	(foperator_lt::fold_range, foperator_le::fold_range,
	foperator_gt::fold_range, foperator_ge::fold_range): Perform the
	real_* comparison check which results in range_false (type)
	even if maybe_isnan (op1, op2).  Simplify.
	(foperator_ltgt): New class.
	(fop_ltgt): New variable.
	(floating_op_table::floating_op_table): Handle LTGT_EXPR using
	fop_ltgt.

	* gcc.dg/torture/inf-compare-1.c: Add dg-additional-options
	-fno-tree-dominator-opts -fno-tree-vrp.
	* gcc.dg/torture/inf-compare-1-float.c: Likewise.
	* gcc.dg/torture/inf-compare-2.c: Likewise.
	* gcc.dg/torture/inf-compare-2-float.c: Likewise.
2023-04-01 09:30:31 +02:00
Jakub Jelinek
87d3bc53b1 testsuite: Add testcase for already fixed PR [PR109362]
This PR got fixed with r13-137.
Add a testcase to make sure it doesn't reappear.

2023-04-01  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/109362
	* gcc.target/i386/pr109362.c: New test.
2023-04-01 09:00:22 +02:00
Jakub Jelinek
b1f6cb2cc3 aarch64, builtins: Include PR registers in FUNCTION_ARG_REGNO_P etc. [PR109254]
The following testcase is miscompiled on aarch64-linux in the regname pass,
because while the function takes arguments in the p0 register,
FUNCTION_ARG_REGNO_P doesn't reflect that, so DF doesn't know the register is
used in register passing. It sees 2 chains with p1 register and wants to
replace the second one and as DF doesn't know p0 is live at the start of the
function, it will happily use p0 register even when it is used in subsequent
instructions.

The following patch fixes that.  FUNCTION_ARG_REGNO_P returns non-zero
for p0-p3 (unconditionally, seems for the floating/vector registers it
doesn't conditionalize them on TARGET_FLOAT either, but if you want,
I can conditionalize p0-p3 on TARGET_SVE), similarly
targetm.calls.function_value_regno_p returns true for p0-p3 registers
if TARGET_SVE (again for consistency, that function conditionalizes
the float/vector on TARGET_FLOAT).

Now, that change broke bootstrap in libobjc and some
__builtin_apply_args/__builtin_apply/__builtin_return tests.  The
aarch64_get_reg_raw_mode hook already documents that SVE scalable arg/return
passing is fundamentally incompatible with those builtins, but unlike
the floating/vector regs where it forces a fixed vector mode, I think
there is no fixed mode which could be used for p0-p3.  So, I have tweaked
the generic code so that it uses VOIDmode return from that hook to signal
that a register shouldn't be touched by
__builtin_apply_args/__builtin_apply/__builtin_return
despite being mentioned in FUNCTION_ARG_REGNO_P or
targetm.calls.function_value_regno_p.

gcc/
2023-04-01  Jakub Jelinek  <jakub@redhat.com>

	PR target/109254
	* builtins.cc (apply_args_size): If targetm.calls.get_raw_arg_mode
	returns VOIDmode, handle it like if the register isn't used for
	passing arguments at all.
	(apply_result_size): If targetm.calls.get_raw_result_mode returns
	VOIDmode, handle it like if the register isn't used for returning
	results at all.
	* target.def (get_raw_result_mode, get_raw_arg_mode): Document what it
	means to return VOIDmode.
	* doc/tm.texi: Regenerated.
	* config/aarch64/aarch64.cc (aarch64_function_value_regno_p): Return
	TARGET_SVE for P0_REGNUM.
	(aarch64_function_arg_regno_p): Also return true for p0-p3.
	(aarch64_get_reg_raw_mode): Return VOIDmode for PR_REGNUM_P regs.

gcc/testsuite/
2023-04-01  Jakub Jelinek  <jakub@redhat.com>
	    Richard Sandiford  <richard.sandiford@arm.com>

	PR target/109254
	* gcc.target/aarch64/sve/pr109254.c: New test.
2023-04-01 08:55:55 +02:00
Iain Sandoe
fc4cde2e6a c++,coroutines: Stabilize names of promoted slot vars [PR101118].
When we need to 'promote' a value (i.e. store it in the coroutine frame) it
is given a frame entry name.  This was based on the DECL_UID for slot vars.
However, when LTO is used, the names from multiple TUs become visible at the
same time, and the DECL_UIDs usually differ between units.  This leads to a
"ODR mismatch" warning for the frame type.

The fix here is to use the current promoted temporaries count to produce
the name, this is stable between TUs and computed per coroutine.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

	PR c++/101118

gcc/cp/ChangeLog:

	* coroutines.cc (flatten_await_stmt): Use the current count of
	promoted temporaries to build a unique name for the frame entries.
2023-04-01 09:27:15 +05:30
GCC Administrator
e11cde0381 Daily bump. 2023-04-01 00:17:38 +00:00
Jonathan Wakely
4969dcd2b7 libstdc++: Teach optimizer that empty COW strings are empty [PR107087]
The compiler doesn't know about the invariant that the _S_empty_rep()
object is immutable and so _M_length and _M_refcount are always zero.
This means that we get warnings about writing possibly-non-zero length
strings into buffers that can't hold them. If we teach the compiler that
the empty rep is always zero length, it knows it can be copied into any
buffer.

For Stage 1 we might want to also consider adding this to capacity():

	if (_S_empty_rep()._M_capacity != 0)
	  __builtin_unreachable();

And this to _Rep::_M_is_leaked() and _Rep::_M_is_shared():

	  if (_S_empty_rep()._M_refcount != 0)
	    __builtin_unreachable();

libstdc++-v3/ChangeLog:

	PR tree-optimization/107087
	* include/bits/cow_string.h (basic_string::size()): Add
	optimizer hint that _S_empty_rep()._M_length is always zero.
	(basic_string::length()): Call size().
2023-03-31 23:45:13 +01:00
Jakub Jelinek
92f02e754c testsuite, analyzer: Fix up pipe-glibc.c testcase [PR107396]
The gcc.dg/analyzer/pipe-glibc.c test FAILs when using recent glibc headers
and succeeds with older headers.
The important change is that
https://sourceware.org/git/?p=glibc.git;a=commit;h=c1760eaf3b575ad174fd88b252fd16bd525fa818
in 2021 added __attribute__ ((__malloc__ (fclose, 1))) attribute to fdopen,
so in write_to_pipe there is an excess warning:
.../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c: In function 'write_to_pipe':
.../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c:28:3: warning: use of possibly-NULL 'stream' where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument]
.../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c:27:12: note: (1) this call could return NULL
.../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c:28:3: note: (2) argument 4 ('stream') from (1) could be NULL where non-null expected
<built-in>: note: argument 4 of '__builtin_fwrite' must be non-null
Strangely, nothing is reported on the read_from_pipe function, seems
fwrite/fprintf/fputc etc. are builtins in GCC and we mark the FILE *
arguments as nonnull there on the builtin declarations, while fgetc/fread
etc. aren't builtins and glibc doesn't mark any of those using nonnull.
Shall we change that on the glibc side?

Anyway, because this differs based on glibc version and I think the
above warning is not the primary intention of the test, I think it is
best to tweak it so that this warning isn't reported.
Another option would be avoid using glibc headers and use our own
declarations, or make sure we add the malloc with fclose attribute ourselves
(but fdopen in the libc headers could be a macro, so not sure
__typeof (fdopen) fdopen __attribute__ ((__malloc__, __malloc__ (fclose, 1)));
would work).  Or use -Wno-analyzer-possible-null-arguments in
dg-additional-options?

2023-03-31  Jakub Jelinek  <jakub@redhat.com>

	PR analyzer/107396
	* gcc.dg/analyzer/pipe-glibc.c (read_from_pie, write_to_pipe): Exit
	if fdopen returns NULL.
2023-03-31 22:48:44 +02:00
Andrew MacLeod
1e1b30a6a4 Adjust testcases to not produce errors..
tree-optimization/109363
	gcc/testsuite/
	* g++.dg/warn/Wstringop-overflow-4.C: Always check bogus message.
	* gcc.dg/tree-ssa/pr23109.c: Disable better recomputations.
2023-03-31 16:15:39 -04:00
Vladimir N. Makarov
e9910e002d LRA: Implement commutative operands exchange for combining secondary memory reload and original insn
The patch implements trying commutative operands exchange for
combining secondary memory reload and original insn.

        PR rtl-optimization/109052

gcc/ChangeLog:

	* lra-constraints.cc: (combine_reload_insn): New function.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr109052-2.c: New.
2023-03-31 11:05:45 -04:00
Jonathan Wakely
a35e8042fb libstdc++: Avoid -Wmaybe-uninitialized warning in std::stop_source [PR109339]
We pass a const-reference to *this before it's constructed, and GCC
assumes that all const-references are accessed. Add the access attribute
to say it's not accessed.

libstdc++-v3/ChangeLog:

	PR libstdc++/109339
	* include/std/stop_token (_Stop_state_ptr(const stop_source&)):
	Add attribute access with access-mode 'none'.
	* testsuite/30_threads/stop_token/stop_source/109339.cc: New test.
2023-03-31 14:20:52 +01:00
Jonathan Wakely
10e573e86c libstdc++: Revert addition of boolean flag to net::ip::basic_endpoint
As pointed out in P2641R1, we can use GCC's __builtin_constant_p to
emulate the proposed std::is_active_member. This allows us to detect
which of the union members is active during constant evaluation, so we
don't need the extra bool data member. We still can't support constexpr
until C++20 though, as we need to change the active member during
constant evaluation.

libstdc++-v3/ChangeLog:

	* include/experimental/internet (ip::basic_endpoint::_M_if_v6):
	Revert change from member function to data member. Fix for
	constant evaluation by detecting which union member is active.
	(ip::basic_endpoint::resize): Revert changes to update _M_is_v6
	flag.
2023-03-31 14:20:51 +01:00
Jakub Jelinek
e02c9d9116 range-op-float, value-range: Fix up handling of UN{LT,LE,GT,GE,EQ}_EXPR and handle comparisons in get_tree_range [PR91645]
When looking into PR91645, I've noticed we handle UN{LT,LE,GT,GE,EQ}_EXPR
comparisons incorrectly.
All those are unordered or ..., we correctly return [1, 1] if one or
both operands are known NANs, and correctly ask the non-UN prefixed
op to fold_range if neither operand may be NAN.
But for the case where one or both operands may be NAN, we always
return [0, 1].  The UN* fold_range tries to handle it by asking
the non-UN prefixed fold_range and if it returns [1, 1] return that,
if it returns [0, 0] or [0, 1] return [0, 1], which makes sense,
because the maybe NAN means that it is the non-UN prefixed fold_range
unioned with [1, 1] in case the maybe NAN is actually NAN at runtime.
The problem is that the non-UN prefixed fold_range always returns [0, 1]
because those fold_range implementations are like:
  if (op1.known_isnan () || op2.known_isnan ())
    r = range_false (type);
  else if (!maybe_isnan (op1, op2))
    {
...
    }
  else
    r = range_true_and_false (type);
and so if maybe_isnan, they always return [0, 1].  Now, thinking about it,
this is unnecessary pessimization, for the case where the ... block
returns range_false (type) we actually could do it also if maybe_isnan (op1,
op2), because if one or both operands are NAN, the comparison will be false,
and if neither is NAN, the comparison will be also false.  Will fix
incrementally today.
Anyway, the following patch fixes it by asking the non-UN prefixed
fold_range on ranges with NAN cleared, which I think does the right
thing in all cases.

Another change in the patch is that range_query::get_tree_range
always returned VARYING for comparisons, this patch allows to ask about
those as well (they are very much like binary ops, except they take
the important type from the types of the operands rather than result).

Initially I've developed this patch together with changes to tree-call-cdce.cc,
but those result in one regression and apparently aren't actually needed to
fix this bug, the range-op-float.cc changes are enough.

2023-03-31  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/91645
	* range-op-float.cc (foperator_unordered_lt::fold_range,
	foperator_unordered_le::fold_range,
	foperator_unordered_gt::fold_range,
	foperator_unordered_ge::fold_range,
	foperator_unordered_equal::fold_range): Call the ordered
	fold_range on ranges with cleared NaNs.
	* value-query.cc (range_query::get_tree_range): Handle also
	COMPARISON_CLASS_P trees.

	* gcc.target/i386/pr103559-1.c: New test.
	* gcc.target/i386/pr103559-2.c: New test.
	* gcc.target/i386/pr103559-3.c: New test.
	* gcc.target/i386/pr103559-4.c: New test.
2023-03-31 13:41:34 +02:00
Jonathan Wakely
79d1e0b2c2 c++tools: Fix Makefile to properly clean and rebuild [PR101834]
The c++tools makefile doesn't remove progressively more files in each of
mostlyclean, clean, and distclean. Instead, each removes a different set
of files (and some files are not removed by any target). Use
prerequisites so that everything is removed.

Also, building in the $objdir/c++tools directory doesn't work, because
the INSTALL variable is never set. It works when building from the
top-level because INSTALL is set in the environment when recursively
invoking make for sub-directories.

c++tools/ChangeLog:

	PR bootstrap/101834
	* Makefile.in (INSTALL): Set variable.
	(mostlyclean): Mark as a phony target.
	(clean): Add mostlyclean as a prerequisite.
	(distclean): Add clean as a prerequisite and remove more files.
	(maintainer-clean): Add distclean as a prerequisite.
2023-03-31 10:38:18 +01:00
Kito Cheng
608388486a RISC-V: Fix missing file dependency in RISC-V back-end [PR109328]
gcc/ChangeLog:

	PR target/109328
	* config/riscv/t-riscv: Add missing dependencies.

Co-authored-by: Andrew Pinski <pinskia@gmail.com>
2023-03-31 15:18:07 +08:00
liuhongt
5de5e977aa Adjust memory_move_cost for MASK_REGS when MODE_SIZE > 8.
It's impossible to put modes whose size > 8 into MASK_REGS.

gcc/ChangeLog:

	* config/i386/i386.cc (inline_memory_move_cost): Return 100
	for MASK_REGS when MODE_SIZE > 8.
2023-03-31 14:15:57 +08:00
Jonathan Yong
65dd42d2c3 c-c++-common/Warray-bounds.c: Fix excess warnings on LLP64
Excess errors on x86_64-w64-mingw32:
/home/user/p/gcc/src/gcc-git/gcc/testsuite/c-c++-common/Warray-bounds.c:50:3: warning: array subscript 4611686018427387902 is above array bounds of 'struct S16[]' [-Warray-bounds=]
/home/user/p/gcc/src/gcc-git/gcc/testsuite/c-c++-common/Warray-bounds.c:55:3: warning: array subscript 4611686018427387902 is above array bounds of 'struct S16[]' [-Warray-bounds=]
/home/user/p/gcc/src/gcc-git/gcc/testsuite/c-c++-common/Warray-bounds.c:90:3: warning: array subscript 658812288346769699 is above array bounds of 'struct S16[][7]' [-Warray-bounds=]

gcc/testsuite/ChangeLog:

	* c-c++-common/Warray-bounds.c: Fix excess warnings on
	LLP64.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
2023-03-31 04:08:25 +00:00
liuhongt
fe42e7fe11 Rename ufix_trunc/ufloat* patterns to fixuns_trunc/floatuns* to align with standard pattern name.
There's some typo for the standard pattern name for unsigned_{float,fix},
it should be floatunsmn2/fixuns_truncmn2, not ufloatmn2/ufix_truncmn2
in current trunk, the patch fix the typo, also change all though
ufix_trunc/ufloat patterns.

Also vcvttps2udq is available under AVX512VL, so it can be generated
directly instead of being emulated via vcvttps2dq.

gcc/ChangeLog:

	PR target/85048
	* config/i386/i386-builtin.def (BDESC): Adjust icode name from
	ufloat/ufix to floatuns/fixuns.
	* config/i386/i386-expand.cc
	(ix86_expand_vector_convert_uns_vsivsf): Adjust comments.
	* config/i386/sse.md
	(ufloat<sseintvecmodelower><mode>2<mask_name><round_name>):
	Renamed	to ..
	(<mask_codefor>floatuns<sseintvecmodelower><mode>2<mask_name><round_name>):.. this.
	(<mask_codefor><avx512>_ufix_notrunc<sf2simodelower><mode><mask_name><round_name>):
	Renamed to ..
	(<mask_codefor><avx512>_fixuns_notrunc<sf2simodelower><mode><mask_name><round_name>):
	.. this.
	(<fixsuffix>fix_truncv16sfv16si2<mask_name><round_saeonly_name>):
	Renamed to ..
	(fix<fixunssuffix>_truncv16sfv16si2<mask_name><round_saeonly_name>):.. this.
	(ufloat<si2dfmodelower><mode>2<mask_name>): Renamed to ..
	(floatuns<si2dfmodelower><mode>2<mask_name>): .. this.
	(ufloatv2siv2df2<mask_name>): Renamed to ..
	(<mask_codefor>floatunsv2siv2df2<mask_name>): .. this.
	(ufix_notrunc<mode><si2dfmodelower>2<mask_name><round_name>):
	Renamed to ..
	(fixuns_notrunc<mode><si2dfmodelower>2<mask_name><round_name>):
	.. this.
	(ufix_notruncv2dfv2si2): Renamed to ..
	(fixuns_notruncv2dfv2si2):.. this.
	(ufix_notruncv2dfv2si2_mask): Renamed to ..
	(fixuns_notruncv2dfv2si2_mask): .. this.
	(*ufix_notruncv2dfv2si2_mask_1): Renamed to ..
	(*fixuns_notruncv2dfv2si2_mask_1): .. this.
	(ufix_truncv2dfv2si2): Renamed to ..
	(*fixuns_truncv2dfv2si2): .. this.
	(ufix_truncv2dfv2si2_mask): Renamed to ..
	(fixuns_truncv2dfv2si2_mask): .. this.
	(*ufix_truncv2dfv2si2_mask_1): Renamed to ..
	(*fixuns_truncv2dfv2si2_mask_1): .. this.
	(ufix_truncv4dfv4si2<mask_name>): Renamed to ..
	(fixuns_truncv4dfv4si2<mask_name>): .. this.
	(ufix_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>):
	Renamed to ..
	(fixuns_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>):
	.. this.
	(ufix_trunc<mode><sseintvecmodelower>2<mask_name>): Renamed to ..
	(<mask_codefor>fixuns_trunc<mode><sseintvecmodelower>2<mask_name>):
	.. this.

gcc/testsuite/ChangeLog:

	* g++.target/i386/pr85048.C: New test.
2023-03-31 09:02:56 +08:00
GCC Administrator
d20a6a3311 Daily bump. 2023-03-31 00:17:02 +00:00
Jason Merrill
58df535075 c++: anonymous union member reference [PR105452]
While parsing the anonymous union, we don't yet know that it's an anonymous
union, so we build the reference to 'v' in the static_assert relative to the
union type.  But at instantiation time we know it's an anonymous union, so
we need to avoid trying to check access for 'v' in the union again; the
simplest approach seemed to be to make accessible_p step out to the
containing class.

While looking at this I also noticed that we were having trouble with DMI in
an anonymous union referring to members of the containing class; there
we just need to give current_class_ptr the right type.

	PR c++/105452

gcc/cp/ChangeLog:

	* search.cc (type_context_for_name_lookup): New.
	(accessible_p): Handle anonymous union.
	* init.cc (maybe_instantiate_nsdmi_init): Use
	type_context_for_name_lookup.
	* parser.cc (cp_parser_class_specifier): Likewise.
	* cp-tree.h (type_context_for_name_lookup): Declare.

gcc/testsuite/ChangeLog:

	* g++.dg/lookup/anon8.C: New test.
2023-03-30 18:25:58 -04:00
Jason Merrill
85131af060 c++: generic lambda and function ptr conv [PR105221]
We weren't properly considering the function pointer conversions in
deduction between FUNCTION_TYPE; we just hardcoded the
UNIFY_ALLOW_MORE_CV_QUAL semantics, which are backwards when deducing for a
template conversion function like the one in a generic lambda.  And when I
started checking the ALLOW flags, I needed to make sure they stay set to
avoid breaking trailing13.C.

	PR c++/105221

gcc/cp/ChangeLog:

	* pt.cc (unify) [FUNCTION_TYPE]: Handle function pointer
	conversions.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/noexcept-type27.C: New test.
2023-03-30 18:25:04 -04:00
Gerald Pfeifer
83d2b1ccd1 libiberty: Remove a reference to the Glibc manual
longjmp is not specific to Glibc, and GCC supports lots of systems
that do not use Glibc. Plus this link has been broken in the web
version for ages without a good way to fix.

libiberty/ChangeLog:

	* obstacks.texi (Preparing for Obstacks): Remove a (broken)
	reference to the Glibc manual.
2023-03-30 23:41:24 +02:00
Jakub Jelinek
c016887c91 c++: Fix up ICE in build_min_non_dep_op_overload [PR109319]
The following testcase ICEs, because grok_array_decl during
processing_template_decl handling of a non-dependent subscript
emits a -Wcomma-subscript pedwarn, we decide to pass to the
single index argument the index expressions as if it was wrapped
with () around it, but then when preparing it for later instantiation
we don't actually take that into account and ICE on a mismatch of
number of index arguments (the overload expects a single index,
testcase has two index expressions in this case).
For non-dependent subscript which are builtin subscripts we also
emit the same pedwarn and don't ICE, but emit the same pedwarn
again whenever we instantiate it, which is also IMHO undesirable,
it is enough to warn once during parsing the template.

The following patch fixes it by turning even the original index expressions
(those which didn't go through make_args_non_dependent) into a single
index using comma expression(s).

2023-03-30  Jakub Jelinek  <jakub@redhat.com>

	PR c++/109319
	* decl2.cc (grok_array_decl): After emitting a pedwarn for
	-Wcomma-subscript, if processing_template_decl set orig_index_exp
	to compound expr from orig_index_exp_list.

	* g++.dg/cpp23/subscript14.C: New test.
2023-03-30 23:08:25 +02:00
Andrew MacLeod
429a7a8843 Add recursive GORI recompuations with a depth limit.
PR tree-optimization/109154
	gcc/
	* gimple-range-gori.cc (gori_compute::may_recompute_p): Add depth limit.
	* gimple-range-gori.h (may_recompute_p): Add depth param.
	* params.opt (ranger-recompute-depth): New param.

	gcc/testsuite/
	* gcc.dg/Walloca-13.c: Remove bogus warning that is now fixed.
2023-03-30 14:17:10 -04:00
Jason Merrill
a23b33a1bd c++: lambda mangling alias issues [PR107897]
In 107897, by the time we are looking at the mangling clash, the
alias has already been removed from the symbol table by analyze_functions,
so we can't look at n->cpp_implicit_alias.  So just assume that it's an
alias if it's internal.

In 108887 the problem is that removing the mangling alias from the symbol
table confuses analyze_functions, because it ended up as first_analyzed
somehow, so it becomes a dangling pointer.  So instead we call reset()
to neutralize the alias.  To make this work for variables, I needed to move
reset() from cgraph_node to symtab_node.

	PR c++/107897
	PR c++/108887

gcc/ChangeLog:

	* cgraph.h: Move reset() from cgraph_node to symtab_node.
	* cgraphunit.cc (symtab_node::reset): Adjust.  Also call
	remove_from_same_comdat_group.

gcc/cp/ChangeLog:

	* decl2.cc (record_mangling): Use symtab_node::reset.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-lambda3.C: Use -flto if supported.
	* g++.dg/cpp0x/lambda/lambda-mangle7.C: New test.
2023-03-30 07:23:03 -04:00
Richard Biener
04b0a7b1a6 tree-optimization/107561 - reduce -Wstringop-overflow false positives
The following tells pointer-query to prefer a zero size when we
are querying for the size range for a write into an object we've
determined is of zero size.  That avoids diagnostics about really
varying size arguments that just get a meaningful range for example
because they are multiplied by an element size.

I've adjusted only one call to get_size_range since that's what
I have a testcase for.

	PR tree-optimization/107561
	* gimple-ssa-warn-access.cc (get_size_range): Add flags
	argument and pass it on.
	(check_access): When querying for the size range pass
	SR_ALLOW_ZERO when the known destination size is zero.

	* g++.dg/pr71488.C: Remove XFAILed bogus diagnostic again.
	* g++.dg/warn/Warray-bounds-16.C: Likewise.
2023-03-30 13:15:52 +02:00
Richard Biener
1d0ba4467d tree-optimization/109342 - wrong code with edge equivalences in VN
The following testcase shows a problem in how we query valitity for
equivalences on edges when the edge is a backedge and thus refering
to a block thats later in the iteration order we use for VN.  That
causes the dominated_by_p_w_unex helper to look at edge executable
state that's not yet computed and thus still at optimistic not
executable state.

The following makes sure to use a plain dominance check in these cases.

	PR tree-optimization/109342
	* tree-ssa-sccvn.cc (vn_nary_op_get_predicated_value): New
	overload for edge.  When that edge is a backedge use
	dominated_by_p directly.

	* g++.dg/torture/pr109342.C: New testcase.
2023-03-30 13:02:19 +02:00
Jakub Jelinek
ee6ae8cb47 c++: Avoid informs without a warning [PR109278]
On the following testcase we emit notes in
maybe_inform_about_fndecl_for_bogus_argument_init
despite no warning/error being printed before it.
This is for the extended floating point type conversions where pedwarn
is used, and complained is used there for 2 different purposes,
one is whether an unspecific error should be emitted if we haven't
complained otherwise, and one whether
maybe_inform_about_fndecl_for_bogus_argument_init should be called.
For the 2 pedwarns, currently it sets complained to true regardless of
whether pedwarn succeeded, which results in the undesirable notes printed
with -w.  If complained is initialized to result of pedwarn, we would
emit an error later on.

So, the following patch makes complained a tristate, the additional
error isn't printed if complained != 0, and
maybe_inform_about_fndecl_for_bogus_argument_init is called only if
complained == 1, so if pedwarn returns false, we can use complained = -1
to tell later code not to emit an error and not to call
maybe_inform_about_fndecl_for_bogus_argument_init.

2023-03-30  Jakub Jelinek  <jakub@redhat.com>

	PR c++/109278
	* call.cc (convert_like_internal): If pedwarn for extended float
	type conversions doesn't report anything, avoid calling
	maybe_inform_about_fndecl_for_bogus_argument_init.

	* g++.dg/cpp23/ext-floating15.C: New test.
2023-03-30 09:34:12 +02:00
Andrew Pinski
a7df3bea9c Fix fc-prototypes usage with C_INT64_T and non LP64 Targets.
The problem here is we were outputing long_long instead of
"long long". This was just an oversight and a missing check.

Committed as obvious after a bootstrap/test on x86_64-linux-gnu.

gcc/fortran/ChangeLog:

	* dump-parse-tree.cc (get_c_type_name): Fix "long_long"
	type name to be "long long". Add a comment on why adding
	2 to the name too.
2023-03-29 20:49:14 -07:00
liuhongt
3588c8cbc1 Generate vpblendd instead of vpblendw for V4SI under AVX2.
gcc/ChangeLog:

	* config/i386/i386-expand.cc (expand_vec_perm_blend): Generate
	vpblendd instead of vpblendw for V4SI under avx2.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr88828-0.c: Adjust testcase.
2023-03-30 09:20:12 +08:00
GCC Administrator
0090888656 Daily bump. 2023-03-30 00:17:02 +00:00
Jonathan Wakely
ee122a2eea libstdc++: Fix filename of new test [PR109242]
libstdc++-v3/ChangeLog:

	PR libstdc++/109242
	* testsuite/20_util/optional/monadic/pr109340.cc: Moved to...
	* testsuite/20_util/optional/monadic/pr109242.cc: ...here.
2023-03-30 00:42:11 +01:00
Jonathan Wakely
e0d77144aa libstdc++: Fix constexpr functions in <experimental/internet>
Change ip::basic_endpoint to work in constant expressions, but only for
C++20 and later (due to the use of a union, which cannot change active
member in constexpr evaluation until C++20).

During constant evaluation we cannot inspect the common initial sequence
of basic_endpoint's union members to check whether sin_family == AF_INET
or AF_INET6.  This means we need to store an additional boolean member
that remembers whether we have a v4 or v6 address. The address type can
change behind our backs if a user copies an address to the data()
pointer and then calls resize(n), so we need to inspect the sa_family_t
member in the union after a resize and update the boolean. POSIX only
guarantees that the sa_family_t member of each protocol-specific address
structure is at the same offset and of the same type, not that there is
a common initial sequence. The check in resize is done using memcmp, so
that we avoid accessing an inactive member of the union if the
sockaddr_in and sockaddr_in6 structures do not have a common initial
sequence that includes the sa_family_t member.

libstdc++-v3/ChangeLog:

	* include/experimental/internet (ip::make_address): Implement
	missing overload.
	(ip::address_v4::broadcast()): Avoid undefined shift.
	(ip::basic_endpoint): Fix member functions for constexpr.
	(ip::basic_endpoint::_M_is_v6): Replace member function with
	data member, adjust member functions using it.
	(ip::basic_endpoint::resize): Update _M_is_v6 based on sockaddr
	content.
	* testsuite/experimental/net/internet/address/v4/cons.cc: Fix
	constexpr checks to work in C++14.
	* testsuite/experimental/net/internet/address/v4/creation.cc:
	Likewise.
	* testsuite/experimental/net/internet/endpoint/cons.cc:
	Likewise.
	* testsuite/experimental/net/internet/network/v4/cons.cc:
	Likewise.
	* testsuite/experimental/net/internet/network/v4/members.cc:
	Likewise.
	* testsuite/experimental/net/internet/endpoint/extensible.cc: New test.
2023-03-30 00:36:08 +01:00
Jonathan Wakely
ce39714a1c libstdc++: Apply small fix from LWG 3843 to std::expected
LWG 3843 adds some type requirements to std::expected::value to ensure
that it can correctly copy the error value if it needs to throw an
exception. We don't need to do anything to enforce that, because it will
already be ill-formed if the type can't be copied. The issue also makes
a small drive-by fix to ensure that a const E& is copied from the
non-const value()& overload, which this change implements.

libstdc++-v3/ChangeLog:

	* include/std/expected (expected::value() &): Use const lvalue
	for unex member passed to bad_expected_access constructor, as
	per LWG 3843.
2023-03-30 00:06:25 +01:00
Jonathan Wakely
31a9097120 libstdc++: Use std::remove_cv_t in std::optional::transform [PR109340]
We need to strip cv-qualifiers from the result of the callable passed to
std::optional::transform.

For std::expected::transform and std::expected::transform_error I
noticed we were stripping cv-qualifiers but were also incorrectly
stripping references.

libstdc++-v3/ChangeLog:

	PR libstdc++/109340
	* include/std/expected (expected::transform): Use
	std::remove_cv_t instead of std::remove_cvref_t.
	(expected::transform_error): Likewise.
	(expected<cv void, E>::transform): Likewise.
	(expected<cv void, E>::transform_error): Likewise.
	* include/std/optional (transform): Use std::remove_cv_t.
	* testsuite/20_util/optional/monadic/pr109340.cc: New test.
2023-03-30 00:06:25 +01:00
Jonathan Wakely
14f50ba054 libstdc++: Enforce requirements on template argument of std::optional
The standard does not allow std::optional<T&>, std::optional<T[1]>,
std::optional<T()> etc. and although we do give errors, they come from
down inside the internals of std::optional. We could improve the static
assertions at the top of the class so that users get a more precise
diagnostic:

optional:721:21: error: static assertion failed
721 |       static_assert(is_object_v<_Tp> && !is_array_v<_Tp>);

libstdc++-v3/ChangeLog:

	* include/std/optional (optional): Adjust static assertion to
	reject arrays and functions as well as references.
	* testsuite/20_util/optional/requirements_neg.cc: New test.
2023-03-30 00:06:25 +01:00
Hans-Peter Nilsson
68982b98d2 CRIS: Make rtx-cost 0 for many CONST_INT "quick" operands
Stepping through a gdb session inspecting costs that cause
gcc.dg/tree-ssa/slsr-13.c to fail, exposed that before this
patch, cris_rtx_costs told that a shift of 1 of a register
costs 5, while adding two registers costs 4.

Making the cost of a quick-immediate constant equal to using
a register (default 0) reflects actual performance and
size-cost better.  It also happens to make
gcc.dg/tree-ssa/slsr-13.c pass with what looks like better
code being generated, and improves coremark performance by
0.4%.

But, blindly doing this for *all* valid operands that fit
the "quick-immediate" addressing mode, trips interaction
with other factors*, with the end result mixed at best.  So,
do this only for MINUS and logical operations for the time
being, and only for modes that fit in one register.

*) Examples of "other factors":

- A bad default implementation of insn_cost or actually,
pattern_cost, that looks only at the set_src_cost and
furthermore sees such a cost of 0 as invalid.  (Compare to
the more sane set_rtx_cost.)  This naturally tripped up
combine and ifcvt, causing all sorts of changes, good and
bad.

- Having the same cost, to compare a register with 0 as with
-31..31, means a compare insn of an eliminable form no
longer looks preferable.

	* config/cris/cris.cc (cris_rtx_costs) [CONST_INT]: Return 0
	for many quick operands, for register-sized modes.
2023-03-30 00:56:13 +02:00
Gaius Mulley
3be4e43a6a PR modula2/109336 - The -fmod= and -fdef= options do not work
The -fmod= and -fdef= options do not work.  After the linking
re-implementation and subsequent restructuring the -fmod= amd -fdef= are
now broken.  This patch adds -fmod= and -fdef= processing into gm2spec.cc.
It also reduces the complexity of extension handling within M2Search
by storing the preceeding "." in the extension.

gcc/m2/ChangeLog:

	PR modula2/109336
	PR modula2/109315
	* gm2-compiler/M2FileName.mod (CalculateFileName): Simplified by
	ensuring the extension contains the ".".
	(CalculateStemName): Re-formatted.
	(ExtractExtension): Re-formatted.
	(ExtractModule): Re-formatted.
	* gm2-compiler/M2Options.def (setdefextension): Add block comment.
	(setmodextension): Add block comment.  Re-formatted.
	* gm2-compiler/M2Options.mod (setdefextension): Add block comment.
	(setmodextension): Add block comment.  Re-formatted.
	* gm2-compiler/M2Search.mod (FindSourceDefFile): Use
	DefaultDefExt.
	(DefaultDefExt): New constant.
	(DefaultModExt): New constant.
	(FindSourceModFile): Use DefaultModExt.
	* gm2-gcc/m2decl.cc (m2decl_DeclareKnownVariable): Correct
	spelling.
	* gm2spec.cc (M2SOURCE): New constant.
	(LANGSPEC): New value.
	(MATHLIB): New value.
	(WITHLIBC): New value.
	(SKIPOPT): New value.
	(lang_specific_driver): Replace seen_module_extension bool with
	module_extension char *.  Detect -fmod= and remember extension.
	Use the extension to detect modula-2 source and mark it as such.

gcc/testsuite/ChangeLog:

	PR modula2/109336
	* gm2/link/nondefaultext/pass/hello.md: New test.
	* gm2/link/nondefaultext/pass/liba.dm: New test.
	* gm2/link/nondefaultext/pass/liba.md: New test.
	* gm2/link/nondefaultext/pass/link-nondefaultext-pass.exp: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-03-29 17:38:22 +01:00
Jiawei
b2f327b9be RISC-V: Add Z*inx imcompatible check in gcc
Z*inx is conflict with float extensions, add incompatible check when
z*inx and f extension both enabled.

Since all float extension imply f extension and all z*inx extension
imply zfinx extension, so we just need to check f with zfinx extension
as the base case.

Co-Authored by: Kito Cheng <kito.cheng@gmail.com>

gcc/ChangeLog:

	* common/config/riscv/riscv-common.cc (riscv_subset_list::parse):
	New check.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/arch-19.c: New test.
2023-03-29 21:48:19 +08:00
Martin Liska
8b2766e87d configure: deprecate --enable-link-mutex option
PR bootstrap/109310

gcc/ChangeLog:

	* configure.ac: Emit a warning for deprecated option
	--enable-link-mutex.
	* configure: Regenerate.
2023-03-29 15:04:55 +02:00
Richard Biener
86efc490ab tree-optimization/109331 - make sure to clean up the CFG after forwprop
When forwprop discovers unreachable code or makes decisions based
on unreachable edges make sure to cleanup the CFG since otherwise
SSA form can become invalid.

	PR tree-optimization/109331
	* tree-ssa-forwprop.cc (pass_forwprop::execute): When we
	discover a taken edge make sure to cleanup the CFG.

	* gcc.dg/torture/pr109331.c: New testcase.
2023-03-29 13:55:47 +02:00
Richard Biener
ad32fcb8e9 scan generic vector tests before lowering
The g++.dg/pr94920.C testcase looks for a specific number of
ABS_EXPRs but the vector example is prone to vector lowering so
the following instead of scanning the optimized dump scans the
forwprop1 dump which is before vector lowering and the point the
transforms should have happened.

	* g++.dg/pr94920.C: Scan forwprop1 instead of optimized.
2023-03-29 10:47:32 +02:00
Richard Biener
7fd1d28d24 tree-optimization/109327 - forwprop stmt removal issue
There's interfering between the to_removed queue and other mechanisms
removing stmts, in this case remove_prop_source_from_use.  The following
makes the to_remove queue draining more permissive.

	PR tree-optimization/109327
	* tree-ssa-forwprop.cc (pass_forwprop::execute): Deal with
	already removed stmts when draining to_remove.

	* gcc.dg/pr109327.c: New testcase.
2023-03-29 10:34:22 +02:00