191912 Commits

Author SHA1 Message Date
Andrew MacLeod
e15425e899 Use GORI to evaluate arguments of a COND_EXPR.
Provide an API into gori to perform a basic evaluation of the arguments of a
COND_EXPR if they are in the dependency chain of the condition.

	PR tree-optimization/104526
	gcc/
	* gimple-range-fold.cc (fold_using_range::range_of_cond_expr): Call
	new routine.
	* gimple-range-gori.cc (range_def_chain::get_def_chain): Force a build
	of dependency chain if there isn't one.
	(gori_compute::condexpr_adjust): New.
	* gimple-range-gori.h (class gori_compute): New prototype.

	gcc/testsuite/
	* gcc.dg/pr104526.c: New.
2022-02-15 17:03:27 -05:00
David Malcolm
84832cab6e analyzer: fix ICE on cast to NULL type [PR104524]
gcc/analyzer/ChangeLog:
	PR analyzer/104524
	* region-model-manager.cc
	(region_model_manager::maybe_fold_sub_svalue): Only call
	get_or_create_cast if type is non-NULL.

gcc/testsuite/ChangeLog:
	PR analyzer/104524
	* gcc.dg/analyzer/pr104524.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-02-15 16:34:33 -05:00
David Malcolm
1e2fe6715a analyzer: fix uninit false +ve due to optimized conditionals [PR102692]
There is false positive from -Wanalyzer-use-of-uninitialized-value on
gcc.dg/analyzer/pr102692.c here:

  ‘fix_overlays_before’: events 1-3
    |
    |   75 |   while (tail
    |      |          ~~~~
    |   76 |          && (tem = make_lisp_ptr (tail, 5),
    |      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |          |
    |      |          (1) following ‘false’ branch (when ‘tail’ is NULL)...
    |   77 |              (end = marker_position (XOVERLAY (tem)->end)) >= pos))
    |      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |......
    |   82 |   if (!tail || end < prev || !tail->next)
    |      |       ~~~~~    ~~~~~~~~~~
    |      |       |            |
    |      |       |            (3) use of uninitialized value ‘end’ here
    |      |       (2) ...to here
    |

The issue is that inner || of the conditionals have been folded within the
frontend from a chain of control flow:

   5   │   if (tail == 0B) goto <D.1986>; else goto <D.1988>;
   6   │   <D.1988>:
   7   │   if (end < prev) goto <D.1986>; else goto <D.1989>;
   8   │   <D.1989>:
   9   │   _1 = tail->next;
  10   │   if (_1 == 0B) goto <D.1986>; else goto <D.1987>;
  11   │   <D.1986>:

to an OR expr (and then to a bitwise-or by the gimplifier):

   5   │   _1 = tail == 0B;
   6   │   _2 = end < prev;
   7   │   _3 = _1 | _2;
   8   │   if (_3 != 0) goto <D.1986>; else goto <D.1988>;
   9   │   <D.1988>:
  10   │   _4 = tail->next;
  11   │   if (_4 == 0B) goto <D.1986>; else goto <D.1987>;

This happens for sufficiently simple conditionals in fold_truth_andor.
In particular, the (end < prev) is short-circuited without optimization,
but is evaluated with optimization, leading to the false positive.

Given how early this folding occurs, it seems the simplest fix is to
try to detect places where this optimization appears to have happened,
and suppress uninit warnings within the statement that would have
been short-circuited.

gcc/analyzer/ChangeLog:
	PR analyzer/102692
	* exploded-graph.h (impl_region_model_context::get_stmt): New.
	* region-model.cc: Include "gimple-ssa.h", "tree-phinodes.h",
	"tree-ssa-operands.h", and "ssa-iterators.h".
	(within_short_circuited_stmt_p): New.
	(region_model::check_for_poison): Don't warn about uninit values
	if within_short_circuited_stmt_p.
	* region-model.h (region_model_context::get_stmt): New vfunc.
	(noop_region_model_context::get_stmt): New.

gcc/testsuite/ChangeLog:
	PR analyzer/102692
	* gcc.dg/analyzer/pr102692-2.c: New test.
	* gcc.dg/analyzer/pr102692.c: Remove xfail.  Remove -O2 from
	options and move to...
	* gcc.dg/analyzer/torture/pr102692.c: ...here.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-02-15 16:33:29 -05:00
Tobias Burnus
4d74ea5517 Fortran/OpenMP: Fix depend-clause handling for c_ptr
gcc/fortran/ChangeLog:

	* trans-openmp.cc (gfc_trans_omp_depobj): Fix to alloc/ptr dummy
	and for c_ptr.

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/depend-4.f90: Add VALUE test, update scan test.
	* gfortran.dg/gomp/depend-5.f90: Fix scan tree for -m32.
	* gfortran.dg/gomp/depend-6.f90: New test.
2022-02-15 21:42:33 +01:00
Richard Sandiford
8e84b2b37a aarch64: Fix subs_compare_2.c regression [PR100874]
subs_compare_2.c tests that we can use a SUBS+CSEL sequence for:

unsigned int
foo (unsigned int a, unsigned int b)
{
  unsigned int x = a - 4;
  if (a < 4)
    return x;
  else
    return 0;
}

As Andrew notes in the PR, this is effectively MIN (x, 4) - 4,
and it is now recognised as such by phiopt.  Previously it was
if-converted in RTL instead.

I tried to look for ways to generalise this to other situations
and to other ?:-style operations, not just max and min.  However,
for general ?: we tend to push an outer “- CST” into the arms of
the ?: -- at least if one of them simplifies -- so I didn't find
any useful abstraction.

This patch therefore adds a pattern specifically for
max/min(a,cst)-cst.  I'm not thrilled at having to do this,
but it seems like the least worst fix in the circumstances.
Also, max(a,cst)-cst for unsigned a is a useful saturating
subtraction idiom and so is arguably worth its own code
for that reason.

gcc/
	PR target/100874
	* config/aarch64/aarch64-protos.h (aarch64_maxmin_plus_const):
	Declare.
	* config/aarch64/aarch64.cc (aarch64_maxmin_plus_const): New function.
	* config/aarch64/aarch64.md (*aarch64_minmax_plus): New pattern.

gcc/testsuite/
	* gcc.target/aarch64/max_plus_1.c: New test.
	* gcc.target/aarch64/max_plus_2.c: Likewise.
	* gcc.target/aarch64/max_plus_3.c: Likewise.
	* gcc.target/aarch64/max_plus_4.c: Likewise.
	* gcc.target/aarch64/max_plus_5.c: Likewise.
	* gcc.target/aarch64/max_plus_6.c: Likewise.
	* gcc.target/aarch64/max_plus_7.c: Likewise.
	* gcc.target/aarch64/min_plus_1.c: Likewise.
	* gcc.target/aarch64/min_plus_2.c: Likewise.
	* gcc.target/aarch64/min_plus_3.c: Likewise.
	* gcc.target/aarch64/min_plus_4.c: Likewise.
	* gcc.target/aarch64/min_plus_5.c: Likewise.
	* gcc.target/aarch64/min_plus_6.c: Likewise.
	* gcc.target/aarch64/min_plus_7.c: Likewise.
2022-02-15 18:09:35 +00:00
Richard Sandiford
65df3aefaa aarch64: Fix store_v2vec_lanes.c failure
store_v2vec_lanes.c started failing after SLP was enabled at -O2.
The test is specifically checking what happens for unvectorised code,
with the vectors being constructed from individal addition results.

gcc/testsuite/
	* gcc.target/aarch64/store_v2vec_lanes.c: Add -fno-tree-vectorize.
2022-02-15 18:09:34 +00:00
Richard Sandiford
fd77b1208d aarch64: Add +nosve to tests
This patch adds +nosve to various Advanced SIMD-only tests.

gcc/testsuite/
	* gcc.target/aarch64/shl-combine-2.c: New test.
	* gcc.target/aarch64/shl-combine-3.c: Likewise.
	* gcc.target/aarch64/shl-combine-4.c: Likewise.
	* gcc.target/aarch64/shl-combine-5.c: Likewise.
	* gcc.target/aarch64/xtn-combine-1.c: Likewise.
	* gcc.target/aarch64/xtn-combine-2.c: Likewise.
	* gcc.target/aarch64/xtn-combine-3.c: Likewise.
	* gcc.target/aarch64/xtn-combine-4.c: Likewise.
	* gcc.target/aarch64/xtn-combine-5.c: Likewise.
	* gcc.target/aarch64/xtn-combine-6.c: Likewise.
2022-02-15 18:09:34 +00:00
Richard Sandiford
4963079769 vect+aarch64: Fix ldp_stp_* regressions
ldp_stp_1.c, ldp_stp_4.c and ldp_stp_5.c have been failing since
vectorisation was enabled at -O2.  In all three cases SLP is
generating vector code when scalar code would be better.

The problem is that the target costs do not model whether STP could
be used for the scalar or vector code, so the normal latency-based
costs for store-heavy code can be way off.  It would be good to fix
that “properly” at some point, but it isn't easy; see the existing
discussion in aarch64_sve_adjust_stmt_cost for more details.

This patch therefore adds an on-the-side check for whether the
code is doing nothing more than set-up+stores.  It then applies
STP-based costs to those cases only, in addition to the normal
latency-based costs.  (That is, the vector code has to win on
both counts rather than on one count individually.)

However, at the moment, SLP costs one vector set-up instruction
for every vector in an SLP node, even if the contents are the
same as a previous vector in the same node.  Fixing the STP costs
without fixing that would regress other cases, tested in the patch.

The patch therefore makes the SLP costing code check for duplicates
within a node.  Ideally we'd check for duplicates more globally,
but that would require a more global approach to costs: the cost
of an initialisation should be amoritised across all trees that
use the initialisation, rather than fully counted against one
arbitrarily-chosen subtree.

Back on aarch64: an earlier version of the patch tried to apply
the new heuristic to constant stores.  However, that didn't work
too well in practice; see the comments for details.  The patch
therefore just tests the status quo for constant cases, leaving out
a match if the current choice is dubious.

ldp_stp_5.c was affected by the same thing.  The test would be
worth vectorising if we generated better vector code, but:

(1) We do a bad job of moving the { -1, 1 } constant, given that
    we have { -1, -1 } and { 1, 1 } to hand.

(2) The vector code has 6 pairable stores to misaligned offsets.
    We have peephole patterns to handle such misalignment for
    4 pairable stores, but not 6.

So the SLP decision isn't wrong as such.  It's just being let
down by later codegen.

The patch therefore adds -mstrict-align to preserve the original
intention of the test while adding ldp_stp_19.c to check for the
preferred vector code (XFAILed for now).

gcc/
	* tree-vectorizer.h (vect_scalar_ops_slice): New struct.
	(vect_scalar_ops_slice_hash): Likewise.
	(vect_scalar_ops_slice::op): New function.
	* tree-vect-slp.cc (vect_scalar_ops_slice::all_same_p): New function.
	(vect_scalar_ops_slice_hash::hash): Likewise.
	(vect_scalar_ops_slice_hash::equal): Likewise.
	(vect_prologue_cost_for_slp): Check for duplicate vectors.
	* config/aarch64/aarch64.cc
	(aarch64_vector_costs::m_stp_sequence_cost): New member variable.
	(aarch64_aligned_constant_offset_p): New function.
	(aarch64_stp_sequence_cost): Likewise.
	(aarch64_vector_costs::add_stmt_cost): Handle new STP heuristic.
	(aarch64_vector_costs::finish_cost): Likewise.

gcc/testsuite/
	* gcc.target/aarch64/ldp_stp_5.c: Require -mstrict-align.
	* gcc.target/aarch64/ldp_stp_14.h,
	* gcc.target/aarch64/ldp_stp_14.c: New test.
	* gcc.target/aarch64/ldp_stp_15.c: Likewise.
	* gcc.target/aarch64/ldp_stp_16.c: Likewise.
	* gcc.target/aarch64/ldp_stp_17.c: Likewise.
	* gcc.target/aarch64/ldp_stp_18.c: Likewise.
	* gcc.target/aarch64/ldp_stp_19.c: Likewise.
2022-02-15 18:09:33 +00:00
Richard Sandiford
63a9328cb8 vect: Fix early free
When updating the target costs interface, I failed to move the
free of the scalar costs beyond the new last use.

gcc/
	* tree-vect-slp.cc (vect_bb_vectorization_profitable_p): Fix
	use after free.
2022-02-15 18:09:33 +00:00
Jonathan Wakely
6cfb7ffb65 libstdc++: Add missing constexpr to uses-allocator construction utilities [PR104542]
libstdc++-v3/ChangeLog:

	PR libstdc++/104542
	* include/bits/uses_allocator_args.h (make_obj_using_allocator)
	(uninitialized_construct_using_allocator): Add constexpr.
	* testsuite/20_util/uses_allocator/make_obj.cc: Check constexpr.
	* testsuite/20_util/uses_allocator/uninitialized_construct.cc: New test.
2022-02-15 12:49:34 +00:00
Richard Biener
d03a67dc69 tree-optimization/104543 - fix unroll-and-jam precondition
We have to make sure that outer loop exits come after the inner
loop since we otherwise will put it into the fused loop body.

2022-02-15  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/104543
	* gimple-loop-jam.cc (unroll_jam_possible_p): Check outer loop exits
	come after the inner loop.

	* gcc.dg/torture/pr104543.c: New testcase.
2022-02-15 13:22:15 +01:00
Tobias Burnus
3939c1b112 Fortran/OpenMP: Fix depend-clause handling
gcc/fortran/ChangeLog:

	* trans-openmp.cc (gfc_trans_omp_clauses, gfc_trans_omp_depobj):
	Depend on the proper addr, for ptr/alloc depend on pointee.

libgomp/ChangeLog:

	* testsuite/libgomp.fortran/depend-4.f90: New test.

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/depend-4.f90: New test.
	* gfortran.dg/gomp/depend-5.f90: New test.
2022-02-15 12:26:48 +01:00
Jakub Jelinek
0863d0ede3 cygwin: Fix up -Werror=format-diag errors [PR104536]
As the testcase reports, cygwin has 3 can%'t contractions in diagnostics,
we use cannot everywhere else instead and -Wformat-diag enforces that.

2022-02-15  Jakub Jelinek  <jakub@redhat.com>

	PR target/104536
	* config/i386/host-cygwin.cc (cygwin_gt_pch_get_address): Use
	cannot instead of can%'t in diagnostics.  Formatting fixes.
2022-02-15 12:17:41 +01:00
Jakub Jelinek
2801f23fb8 fold, simplify-rtx: Punt on non-representable floating point constants [PR104522]
For IBM double double I've added in PR95450 and PR99648 verification that
when we at the tree/GIMPLE or RTL level interpret target bytes as a REAL_CST
or CONST_DOUBLE constant, we try to encode it back to target bytes and
verify it is the same.
This is because our real.c support isn't able to represent all valid values
of IBM double double which has variable precision.
In PR104522, it has been noted that we have similar problem with the
Intel/Motorola extended XFmode formats, our internal representation isn't
able to record pseudo denormals, pseudo infinities, pseudo NaNs and unnormal
values.
So, the following patch is an attempt to extend that verification to all
floats.
Unfortunately, it wasn't that straightforward, because the
__builtin_clear_padding code exactly for the XFmode long doubles needs to
discover what bits are padding and does that by interpreting memory of
all 1s.  That is actually a valid supported value, a qNaN with negative
sign with all mantissa bits set, but the verification includes also the
padding bits (exactly what __builtin_clear_padding wants to figure out)
and so fails the comparison check and so we ICE.
The patch fixes that case by moving that verification from
native_interpret_real to its caller, so that clear_padding_type can
call native_interpret_real and avoid that extra check.

With this, the only thing that regresses in the testsuite is
+FAIL: gcc.target/i386/auto-init-4.c scan-assembler-times long\\t-16843010 5
because it decides to use a pattern that has non-zero bits in the padding
bits of the long double, so the simplify-rtx.cc change prevents folding
a SUBREG into a constant.  We emit (the testcase is -O0 but we emit worse
code at all opt levels) something like:
        movabsq $-72340172838076674, %rax
        movabsq $-72340172838076674, %rdx
        movq    %rax, -48(%rbp)
        movq    %rdx, -40(%rbp)
        fldt    -48(%rbp)
        fstpt   -32(%rbp)
instead of
        fldt    .LC2(%rip)
        fstpt   -32(%rbp)
...
.LC2:
        .long   -16843010
        .long   -16843010
        .long   65278
        .long   0
Note, neither of those sequences actually stores the padding bits, fstpt
simply doesn't touch them.
For vars with clear_padding_real_needs_padding_p types that are allocated
to memory at expansion time, I'd say much better would be to do the stores
using integral modes rather than XFmode, so do that:
        movabsq $-72340172838076674, %rax
        movq    %rax, -32(%rbp)
        movq    %rax, -24(%rbp)
directly.  That is the only way to ensure the padding bits are initialized
(or expand __builtin_clear_padding, but then you initialize separately the
value bits and padding bits).

2022-02-15  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/104522
	* fold-const.h (native_interpret_real): Declare.
	* fold-const.cc (native_interpret_real): No longer static.  Don't
	perform MODE_COMPOSITE_P verification here.
	(native_interpret_expr) <case REAL_TYPE>: But perform it here instead
	for all modes.
	* gimple-fold.cc (clear_padding_type): Call native_interpret_real
	instead of native_interpret_expr.
	* simplify-rtx.cc (simplify_immed_subreg): Perform the native_encode_rtx
	and comparison verification for all FLOAT_MODE_P modes, not just
	MODE_COMPOSITE_P.

	* gcc.dg/pr104522.c: New test.
2022-02-15 12:12:16 +01:00
Richard Biener
d8b6da8dd1 tree-optimization/104519 - adjust PR100499 niter fix
The following adjusts the PR100499 niter fix to use the appropriate
types when checking whether the difference between the final and base
values of the IV are a multiple of the step.  It also gets rid of
an always false condition in multiple_of_p which lead me to a
wrong solution first.

2022-02-15  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/104519
	* fold-const.cc (multiple_of_p): Remove never true condition.
	* tree-ssa-loop-niter.cc (number_of_iterations_ne): Use
	the appropriate types for determining whether the difference
	of final and base is a multiple of the step.

	* gcc.dg/torture/pr104519.c: New testcase.
2022-02-15 11:41:42 +01:00
Jakub Jelinek
c4c0aa6089 sanitizer: Use glibc _thread_db_sizeof_pthread symbol if present
I've cherry-picked following fix from llvm-project.  Recent glibcs
have _thread_db_sizeof_pthread symbol variable which contains the
size of struct pthread, so that sanitizers don't need to guess that
and risk that it will change again.

2022-02-15  Jakub Jelinek  <jakub@redhat.com>

	* sanitizer_common/sanitizer_linux_libcdep.cpp: Cherry-pick
	llvm-project revision ef14b78d9a144ba81ba02083fe21eb286a88732b.
2022-02-15 11:18:56 +01:00
Jakub Jelinek
6a0d6e7ca9 openmp: Make finalize_task_copyfn order reproduceable [PR104517]
The following testcase fails -fcompare-debug, because finalize_task_copyfn
was invoked from splay tree destruction, whose order can in some cases
depend on -g/-g0.  The fix is to queue the task stmts that need copyfn
in a vector and run finalize_task_copyfn on elements of that vector.

2022-02-15  Jakub Jelinek  <jakub@redhat.com>

	PR debug/104517
	* omp-low.cc (task_cpyfns): New variable.
	(delete_omp_context): Don't call finalize_task_copyfn from here.
	(create_task_copyfn): Push task_stmt into task_cpyfns.
	(execute_lower_omp): Call finalize_task_copyfn here on entries from
	task_cpyfns vector and release the vector.

	* gcc.dg/gomp/pr104517.c: New test.
2022-02-15 10:22:30 +01:00
Jason Merrill
2c3309e3d0 c++: TTP in member alias template [PR104107]
In the first testcase, coerce_template_template_parms was adding too much of
outer_args when coercing to match P's template parameters, so that when
substituting into the 'const T&' parameter we got an unrelated template
argument for T.  We should only add outer_args when the argument template is
a nested template.

	PR c++/104107
	PR c++/95036

gcc/cp/ChangeLog:

	* pt.cc (coerce_template_template_parms): Take full parms.
	Avoid adding too much of outer_args.
	(coerce_template_template_parm): Adjust.
	(template_template_parm_bindings_ok_p): Adjust.
	(convert_template_argument): Adjust.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/alias-decl-ttp2.C: New test.
	* g++.dg/cpp1z/ttp2.C: New test.
2022-02-15 00:06:38 -05:00
GCC Administrator
1f8a09d2f3 Daily bump. 2022-02-15 00:16:41 +00:00
Martin Sebor
7a1b179b08 Update -Warray-bounds documentation [PR104355].
Resolves:
PR middle-end/104355 - Misleading and outdated -Warray-bounds documentation

gcc/ChangeLog:
	PR middle-end/104355
	* doc/invoke.texi (-Warray-bounds): Update documentation.
2022-02-14 15:54:13 -07:00
Michael Meissner
16b65b0848 Use correct names for __ibm128 if long double is IEEE 128-bit.
If you are on a PowerPC system where the default long double is IEEE
128-bit (either through the compiler option -mabi=ieeelongdouble or via
the configure option --with-long-double-format=ieee), GCC used the wrong
names for some of the conversion functions for the __ibm128 type.

Internally, GCC uses IFmode for __ibm128 if long double is IEEE 128-bit,
instead of TFmode when long double is IBM 128-bit.  This patch adds the
missing conversions to prevent the 'if' name from being used.

In particular, before the patch, the conversions used were:

    IFmode to DImode signed:	__fixifdi	instead of __fixtfdi
    IFmode to DImode unsigned	__fixunsifti	instead of __fixunstfti
    DImode to IFmode signed:	__floatdiif	instead of __floatditf
    DImode to IFmode unsigned:	__floatundiif	instead of __floatunditf

2022-02-14  Michael Meissner  <meissner@the-meissners.org>

gcc/
	PR target/104253
	* config/rs6000/rs6000.cc (init_float128_ibm): Update the
	conversion functions used to convert IFmode types.

gcc/testsuite/
	PR target/104253
	* gcc.target/powerpc/pr104253.c: New test.
2022-02-14 17:42:14 -05:00
Harald Anlauf
19b517dff3 Fortran: improve error recovery on bad array section
gcc/fortran/ChangeLog:

	PR fortran/104211
	* expr.cc (find_array_section): Replace assertion by error
	recovery when encountering bad array constructor.

gcc/testsuite/ChangeLog:

	PR fortran/104211
	* gfortran.dg/pr104211.f90: New test.
2022-02-14 20:31:14 +01:00
Jonathan Wakely
3d50dede07 libstdc++: Fix stream extraction of IEEE128 long double [PR100912]
The std::__convert_from_v helper that formats double and long double
values into a char buffer was not being duplicated for the two long
double ABIs. This resulted in an ODR violation inside the library, where
some callers needed it to use snprintf to format __ibm128 values and
other callers needed it to use __snprintfieee128 to format __ieee128
values. The linker discarded one of the definitions, leaving one set of
callers using the wrong code.

This puts __convert_from_v in the __gnu_cxx_ieee128 inline namespace
when long double is __ieee128, so that there are two different
definitions of the function.

The std::money_put::__do_put overload for __ibm128 values needs a
different fix, because that is defined when long double is __ieee128 and
so would call the one in the inline namespace. That can be fixed by just
inlining the code directly into the function and using an asm alias to
call the right version of snprintf for the __ibm128 format. The code to
do that can be simpler than __convert_from_v because if we're defining
the ALT128_COMPAT symbols we know that we have a recent glibc and so we
can assume that uselocale and snprintf are supported.

libstdc++-v3/ChangeLog:

	PR libstdc++/100912
	* config/locale/gnu/c_locale.h (__convert_from_v): Use inline
	namespace for IEEE128 long double mode.
	* config/os/gnu-linux/ldbl-ieee128-extra.ver: Add new symbol
	version and export __gnu_cxx_ieee128::__convert_from_v.
	* include/bits/locale_facets_nonio.tcc (money_put::__do_put):
	Make __ibm128 overload use snprintf directly
	* testsuite/util/testsuite_abi.cc: Add new symbol version.
	Remove stable IEEE128/LDBL versions.
2022-02-14 17:19:08 +00:00
Jakub Jelinek
02a981a8e5 c++: Don't reject GOTO_EXPRs to cdtor_label in potential_constant_expression_1 [PR104513]
return in ctors on targetm.cxx.cdtor_returns_this () target like arm
is emitted as GOTO_EXPR cdtor_label where at cdtor_label it emits
RETURN_EXPR with the this.
Similarly, in all dtors regardless of targetm.cxx.cdtor_returns_this ()
a return is emitted similarly.

potential_constant_expression_1 was rejecting these gotos and so we
incorrectly rejected these testcases, but actual cxx_eval* is apparently
handling these just fine.  I was a little bit worried that for the
destruction of bases we wouldn't evaluate something we should, but as the
testcase shows, that is evaluated through try ... finally and there is
nothing after the cdtor_label.  For arm there is RETURN_EXPR this; but we
don't really care about the return value from ctors and dtors during the
constexpr evaluation.

I must say I don't see much the point of cdtor_labels at all, I'd think
that with try ... finally around it for non-arm we could just RETURN_EXPR
instead of the GOTO_EXPR and the try/finally gimplification would DTRT,
and we could just add the right return value for the arm case.

2022-02-14  Jakub Jelinek  <jakub@redhat.com>

	PR c++/104513
	* constexpr.cc (potential_constant_expression_1) <case GOTO_EXPR>:
	Don't punt if returns (target).

	* g++.dg/cpp1y/constexpr-104513.C: New test.
	* g++.dg/cpp2a/constexpr-dtor12.C: New test.
2022-02-14 16:56:15 +01:00
Andrew Stubbs
d51cad0b84 amdgcn: Allow vector reductions on constants
Obviously it would be better if these reductions could be evaluated at compile
time, but this will avoid an ICE.

gcc/ChangeLog:

	* config/gcn/gcn.cc (gcn_expand_reduc_scalar): Use force_reg.
2022-02-14 13:39:13 +00:00
Richard Biener
0a1a3afb5f tree-optimization/104528 - free niter estimates after DSE
When DSE removes a trivially dead def we have to reset niter information
on loops since that might refer to it.  The patch also adds verification
to make sure this does not happen.

2022-02-14  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/104528
	* tree-ssa.h (find_released_ssa_name): Declare.
	* tree-ssa.cc (find_released_ssa_name): Export.
	* cfgloop.cc (verify_loop_structure): Look for released
	SSA names in loops nb_iterations.
	* tree-ssa-dse.cc (pass_dse::execute): Release number of iteration
	estimates.

	* gfortran.dg/pr104528.f: New testcase.
2022-02-14 14:31:06 +01:00
Jonathan Wakely
164a761a9f libstdc++: Use __cpp_concepts instead of custom macro [PR103891]
With the new value of __cpp_concepts required by P2493, we can test
whether the compiler supports conditionally trivial special members.
This allows us to remove the workaround that disables fully-constexpr
std::variant for Clang. Now it should work for non-GCC compilers (such
as future releases of Clang) that support conditionally trivial
destructors and define the new value of __cpp_concepts.

libstdc++-v3/ChangeLog:

	PR libstdc++/103891
	* include/bits/c++config (_GLIBCXX_HAVE_COND_TRIVIAL_SPECIAL_MEMBERS):
	Remove.
	* include/std/variant: Check feature test macros instead.
	* include/std/version: Likewise.
2022-02-14 13:03:31 +00:00
Jonathan Wakely
220d85fdf0 libstdc++: Fix typo in pragma
libstdc++-v3/ChangeLog:

	* testsuite/20_util/unsynchronized_pool_resource/allocate.cc:
	Fix typo.
2022-02-14 12:46:04 +00:00
Jonathan Wakely
8134156502 libstdc++: Fix std::to_chars for IEEE128 long double
The preprocessor check for _GLIBCXX_USE_FLOAT128 is the wrong condition,
because when the compiler is built with --with-long-double-format=ieee
configure determines that __float128 is the same as long double, and so
should not be used. But we do want the std::to_chars overloads for
__float128 in that case, because the floating_to_chars.cc file is built
with -mabi=ibmlongdouble and so the __float128 overloads are actually
the 'long double' ones for -mabi=ieeelongdouble code.

This fixes missing definitions of the __float128 overloads of
std::to_chars for --with-long-double-format=ieee builds. Without this,
there are symbols present in the --with-long-double-abi=ibm build which
are missing from the --with-long-double-abi=ieee build.

libstdc++-v3/ChangeLog:

	* src/c++17/floating_to_chars.cc (FLOAT128_TO_CHARS): Depend on
	LONG_DOUBLE_ALT128_COMPAT instead of USE_FLOAT128.
2022-02-14 12:34:21 +00:00
Richard Biener
f320197c8b tree-optimization/104511 - avoid FP to DFP conversion for VEC_PACK_TRUNC
This avoids forwprop from matching DFP <-> FP vector conversions
using VEC_[UN]PACK{_TRUNC,_LO,_HI}.  Maybe DFP vectors shouldn't be
a thing, but they appearantly are.  Re-using CONVERT/NOP_EXPR for
DFP <-> FP conversions was probably a mistake.

2022-02-14  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/104511
	* tree-ssa-forwprop.cc (simplify_vector_constructor): Avoid
	touching DFP <-> FP conversions.

	* gcc.dg/pr104511.c: New testcase.
2022-02-14 11:26:06 +01:00
Richard Biener
f7e2691318 c/104505 - ICE with internal function call in diagnostic expression
The following handles internal function calls similar to how the
C++ frontend does, avoiding ICEing on those.

2022-02-14  Richard Biener  <rguenther@suse.de>

	PR c/104505
gcc/c-family/
	* c-pretty-print.cc (c_pretty_printer::postfix_expression): Handle
	internal function calls.

gcc/testsuite/
	* c-c++-common/pr104505.c: New testcase.
2022-02-14 09:31:17 +01:00
Richard Biener
3f10e0d50b middle-end/104497 - gimplification of vector indexing
The following attempts to address gimplification of

   ... = VIEW_CONVERT_EXPR<int[4]>((i & 1) != 0 ? inv : src)[i];

which is problematic since gimplifying the base object
? inv : src produces a register temporary but GIMPLE does not
really support a register as a base for an ARRAY_REF (even
though that's not strictly validated it seems as can be seen
at -O0).  Interestingly the C++ frontend avoids this issue
by emitting the following GENERIC instead:

   ... = (i & 1) != 0 ? VIEW_CONVERT_EXPR<int[4]>(inv)[i] : VIEW_CONVERT_EXPR<int[4]>(src)[i];

The proposed patch below fixes things up when using an rvalue
as the base is OK by emitting a copy from a register base to a
non-register one.  The ?: as lvalue extension seems to be gone
for C, C++ again unwraps the COND_EXPR in that case.

2022-02-11  Richard Biener  <rguenther@suse.de>

	PR middle-end/104497
	* gimplify.cc (gimplify_compound_lval): Make sure the
	base is a non-register if needed and possible.

	* c-c++-common/torture/pr104497.c: New testcase.
2022-02-14 09:12:36 +01:00
GCC Administrator
0d31c8ec3f Daily bump. 2022-02-14 00:16:23 +00:00
Maciej W. Rozycki
4493c5a203 [Ada] PR ada/98724: Alpha/Linux/libada: Use wraplf for Aux_Long_Long_Float
Use the Long Long Float wrapper in terms of Long Float for Alpha/Linux
targets as well, fixing gnatlib compilation errors:

a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on result [enabledby default]
a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on parameter 1 [enabled by default]
a-nallfl.ads:48:13: warning: profile of "Sin" doesn't match the builtin it binds [enabled by default]

etc. with the `alpha-linux-gnu' target.

	gcc/ada/
	PR ada/98724
	PR ada/97504
	* Makefile.rtl (LIBGNAT_TARGET_PAIRS) <alpha*-*-linux*>: Use
	wraplf version of Aux_Long_Long_Float.
2022-02-13 22:57:21 +00:00
Ian Lance Taylor
58aeb75d40 runtime: call timer functions via syscall
It turns out to be painful to require linking against -lrt on
GNU/Linux, as that makes it harder to link Go code into C programs.
Instead just call the timer syscalls directly.  That is what the
upstream library does anyhow.

gcc/go/
	* gospec.cc: Revert 2022-02-09 change:
	(RTLIB, RT_LIBRARY): Don't define.
	(lang_specific_driver): Don't add -lrt if linking statically
	on GNU/Linux.

gotools/
	* configure.ac: Revert 2022-02-09 change:
	(RT_LIBS): Don't define.
	* Makefile.am (check-runtime): Don't set GOLIBS to $(RT_LIBS).
	* configure, Makefile.in: Regenerate.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/385475
2022-02-13 11:03:45 -08:00
Ian Lance Taylor
033ec967ec compiler: don't set ptrmask bit for pointer to notinheap type
Test case is https://go.dev/cl/385454.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/385474
2022-02-13 10:54:26 -08:00
Mikael Morin
57da349397 fortran: Unshare associate var charlen [PR104228]
PR104228 showed that character lengths were shared between associate
variable and associate targets.  This is problematic when the associate
target is itself a variable and gets a variable to hold the length, as
the length variable is added (and all the variables following it in the chain)
to both the associate variable scope and the target variable scope.
This caused an ICE when compiling with -O0 -fsanitize=address.

This change forces the creation of a separate character length for the
associate variable.  It also forces the initialization of the character
length variable to avoid regressing associate_32 and associate_47 tests.

	PR fortran/104228

gcc/fortran/ChangeLog:

	* resolve.cc (resolve_assoc_var): Also create a new character
	length for non-dummy associate targets.
	* trans-stmt.cc (trans_associate_var): Initialize character length
	even if no temporary is used for the associate variable.

gcc/testsuite/ChangeLog:

	* gfortran.dg/asan/associate_58.f90: New test.
	* gfortran.dg/asan/associate_59.f90: New test.
2022-02-13 16:46:46 +01:00
liuhongt
7e204bd2f1 Add vect_recog_cond_expr_convert_pattern.
The pattern converts (cond (cmp a b) (convert c) (convert d))
to (convert (cond (cmp a b) c d)) when
1) types_match (c, d)
2) single_use for (convert c) and (convert d)
3) TYPE_PRECISION (TREE_TYPE (c)) == TYPE_PRECISION (TREE_TYPE (a))
4) INTEGERAL_TYPE_P (TREE_TYPE (c))

The pattern can save packing of mask and data(partial for data, 2 vs
1).

gcc/ChangeLog:

	PR target/103771
	* match.pd (cond_expr_convert_p): New match.
	* tree-vect-patterns.cc (gimple_cond_expr_convert_p): Declare.
	(vect_recog_cond_expr_convert_pattern): New.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr103771-2.c: New test.
	* gcc.target/i386/pr103771-3.c: New test.
2022-02-13 17:57:38 +08:00
GCC Administrator
23756b7063 Daily bump. 2022-02-13 00:16:20 +00:00
Jakub Jelinek
f0c7367b88 asan: Fix up address sanitizer instrumentation of __builtin_alloca* if it can throw [PR104449]
With -fstack-check* __builtin_alloca* can throw and the asan
instrumentation of this builtin wasn't prepared for that case.
The following patch fixes that by replacing the builtin with the
replacement builtin and emitting any further insns on the fallthru
edge.

I haven't touched the hwasan code which most likely suffers from the
same problem.

2022-02-12  Jakub Jelinek  <jakub@redhat.com>

	PR sanitizer/104449
	* asan.cc: Include tree-eh.h.
	(handle_builtin_alloca): Handle the case when __builtin_alloca or
	__builtin_alloca_with_align can throw.

	* gcc.dg/asan/pr104449.c: New test.
	* g++.dg/asan/pr104449.C: New test.
2022-02-12 19:17:44 +01:00
H.J. Lu
5c4258d7c7 x86: Update PR 35513 tests
1. Require linker with GNU_PROPERTY_1_NEEDED support for PR 35513
run-time tests.
2. Compile pr35513-8.c to scan assembly code.

	PR testsuite/104481
	* g++.target/i386/pr35513-1.C: Require property_1_needed target.
	* g++.target/i386/pr35513-2.C: Likewise.
	* gcc.target/i386/pr35513-8.c: Change to compile.
	* lib/target-supports.exp (check_compile): Support assembly code.
	(check_effective_target_property_1_needed): New proc.
2022-02-12 05:41:09 -08:00
Jakub Jelinek
0538d42cdd i386: Fix up cvtsd2ss splitter [PR104502]
The following testcase ICEs, because AVX512F is enabled, AVX512VL is not,
and the cvtsd2ss insn has %xmm0-15 as output operand and %xmm16-31 as
input operand.  For output operand %xmm16+ the splitter just gives up
in such case, but for such input it just emits vmovddup which requires
AVX512VL if either operand is EXT_REX_SSE_REG_P (when it is 128-bit).

The following patch fixes it by treating that case like the pre-SSE3
output != input case - move the input to output and do everything on
the output reg which is known to be < %xmm16.

2022-02-12  Jakub Jelinek  <jakub@redhat.com>

	PR target/104502
	* config/i386/i386.md (cvtsd2ss splitter): If operands[1] is xmm16+
	and AVX512VL isn't available, move operands[1] to operands[0] first.

	* gcc.target/i386/pr104502.c: New test.
2022-02-12 11:17:41 +01:00
Uros Bizjak
edadc7e051 i386: Skip decimal float vector modes in type_natural_mode [PR79754]
2022-02-12  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

	PR target/79754
	* config/i386/i386.cc (type_natural_mode):
	Skip decimal float vector modes.

gcc/testsuite/ChangeLog:

	PR target/79754
	* gcc.target/i386/pr79754.c: New test.
2022-02-12 10:55:29 +01:00
GCC Administrator
e8d68f0a45 Daily bump. 2022-02-12 00:16:23 +00:00
Iain Sandoe
4c3792d448 LRA, rs6000, Darwin: Amend lo_sum use for forced constants [PR104117].
Two issues resulted in this PR, which manifests when we force a constant into
memory in LRA (in PIC code on Darwin).  The presence of such forced constants
is quite dependent on other RTL optimisations, and it is easy for the issue to
become latent for a specific case.

First, in the Darwin-specific rs6000 backend code, we were not being careful
enough in rejecting invalid symbolic addresses.  Specifically, when generating
PIC code, we require a SYMBOL_REF to be wrapped in an UNSPEC_MACHOPIC_OFFSET.

Second, LRA was attempting to load a register using an invalid lo_sum address.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Co-authored-by: Vladimir Makarov <vmakarov@redhat.com>

	PR target/104117

gcc/ChangeLog:

	* config/rs6000/rs6000.cc (darwin_rs6000_legitimate_lo_sum_const_p):
	Check for UNSPEC_MACHOPIC_OFFSET wrappers on symbolic addresses when
	emitting PIC code.
	(legitimate_lo_sum_address_p): Likewise.
	* lra-constraints.cc (process_address_1): Do not attempt to emit a reg
	load from an invalid lo_sum address.
2022-02-11 23:52:12 +00:00
Joseph Myers
13caa028f9 Regenerate .pot files.
gcc/po/
	* gcc.pot: Regenerate.

libcpp/po/
	* cpplib.pot: Regenerate.
2022-02-11 23:23:48 +00:00
Joseph Myers
becc9a12a5 preprocessor: Extract messages from cpp_*_at calls for translation
The logic in libcpp/Makefile.in listing diagnostic functions in a call
to xgettext was missing cpp_warning_at, cpp_pedwarning_at and
cpp_error_at, so resulting in some messages not being extracted for
translation; add those functions to those for which messages are
extracted.

Tested with "make cpplib.pot".

	* Makefile.in (po/$(PACKAGE).pot): Also handle cpp_warning_at,
	cpp_pedwarning_at and cpp_error_at.
2022-02-11 23:22:07 +00:00
Joseph Myers
434b2caf5d i18n: fix exgettext handling of C++ sources
The move of source files to .cc names broke most message extraction by
exgettext because it processed .c files with --language=GCC-source but
didn't process .cc files that way.  Fix to process files identified as
C++ that way as well.

Tested with "make gcc.pot".

	* exgettext: Also process C++ sources with --language=GCC-source.
2022-02-11 23:17:24 +00:00
Ian Lance Taylor
8dc2499aa6 libgo: update to Go1.18beta2
gotools/
	* Makefile.am (go_cmd_cgo_files): Add ast_go118.go
	(check-go-tool): Copy golang.org/x/tools directories.
	* Makefile.in: Regenerate.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/384695
2022-02-11 15:01:19 -08:00
Jonathan Wakely
9a56779dbc libstdc++: Fix FAIL: 20_util/temporary_buffer.cc for C++14
The std::get_temporary_buffer function is deprecated since C++17, but
the test was expecting a warning for C++14 as well.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/temporary_buffer.cc: Fix dg-warning target
	selector.
2022-02-11 21:42:22 +00:00