Commit graph

201669 commits

Author SHA1 Message Date
Hans-Peter Nilsson
273a33b285 testsuite: Cut down 27_io/basic_istream/.../94749.cc for simulators
The test wchar_t/94749.cc can take about 10 minutes on some
simulator/host combinations with char/94749.cc at a third of
that time.  The cause is test05 which is quite heavy and
includes wrapping a 32-bit counter.  Run it only for native
setups.

	* testsuite/27_io/basic_istream/ignore/wchar_t/94749.cc (main)
	[! SIMULATOR_TEST]: Also exclude running test05.
	* testsuite/27_io/basic_istream/ignore/char/94749.cc: Ditto.
2023-06-10 23:54:34 +02:00
Nathan Sidwell
80f075b410 c++: Adjust conversion deduction [PR61663][DR976]
Drop the return type's reference before doing cvqual and related decays.

	gcc/cp/
	PR c++/61663
	* pt.cc (maybe_adjust_types_for_deduction): Implement DR976.
	gcc/testsuite/
	* g++.dg/template/pr61663.C: New.
2023-06-10 17:22:21 -04:00
Georg-Johann Lay
30a8771c0f target/109650: Fix wrong code after cc0 -> CCmode transition.
This patch fixes a wrong-code bug in the wake of PR92729, the transition that
turned the AVR backend from cc0 to CCmode.  In cc0, the insn that uses cc0 like
a conditional branch always follows the cc0 setter, which is no more the case
with CCmode where set and use of REG_CC might be in different basic blocks.

This patch removes the machine-dependent reorg pass in avr_reorg entirely.

It is replaced by a new, AVR specific mini-pass that runs prior to split2.
Canonicalization of comparisons away from the "difficult" codes GT[U] and LE[U]
is now mostly performed by implementing TARGET_CANONICALIZE_COMPARISON.

Moreover:

* Text peephole conditions get "dead_or_set_regno_p (*, REG_CC)" as needed.

* RTL peephole conditions get "peep2_regno_dead_p (*, REG_CC)" as needed.

* Conditional branches no more clobber REG_CC.

* insn output for compares looks ahead to determine the branch mode in use.
  This needs also "dead_or_set_regno_p (*, REG_CC)".

* Add RTL peepholes for decrement-and-branch detection.

* Some of the patterns like "*cmphi.zero-extend.0" lost their
  combine-ational part wit PR92729.  Restore them.

Finally, it fixes some of the many indentation glitches left over from PR92729.

gcc/
	PR target/109650
	PR target/92729
	* config/avr/avr-passes.def (avr_pass_ifelse): Insert new pass.
	* config/avr/avr.cc (avr_pass_ifelse): New RTL pass.
	(avr_pass_data_ifelse): New pass_data for it.
	(make_avr_pass_ifelse, avr_redundant_compare, avr_cbranch_cost)
	(avr_canonicalize_comparison, avr_out_plus_set_ZN)
	(avr_out_cmp_ext): New functions.
	(compare_condtition): Make sure REG_CC dies in the branch insn.
	(avr_rtx_costs_1): Add computation of cbranch costs.
	(avr_adjust_insn_length) [ADJUST_LEN_ADD_SET_ZN, ADJUST_LEN_CMP_ZEXT]:
	[ADJUST_LEN_CMP_SEXT]Handle them.
	(TARGET_CANONICALIZE_COMPARISON): New define.
	(avr_simplify_comparison_p, compare_diff_p, avr_compare_pattern)
	(avr_reorg_remove_redundant_compare, avr_reorg): Remove functions.
	(TARGET_MACHINE_DEPENDENT_REORG): Remove define.
	* config/avr/avr-protos.h (avr_simplify_comparison_p): Remove proto.
	(make_avr_pass_ifelse, avr_out_plus_set_ZN, cc_reg_rtx)
	(avr_out_cmp_zext): New Protos
	* config/avr/avr.md (branch, difficult_branch): Don't split insns.
	(*cbranchhi.zero-extend.0", *cbranchhi.zero-extend.1")
	(*swapped_tst<mode>, *add.for.eqne.<mode>): New insns.
	(*cbranch<mode>4): Rename to cbranch<mode>4_insn.
	(define_peephole): Add dead_or_set_regno_p(insn,REG_CC) as needed.
	(define_deephole2): Add peep2_regno_dead_p(*,REG_CC) as needed.
	Add new RTL peepholes for decrement-and-branch and *swapped_tst<mode>.
	Rework signtest-and-branch peepholes for *sbrx_branch<mode>.
	(adjust_len) [add_set_ZN, cmp_zext]: New.
	(QIPSI): New mode iterator.
	(ALLs1, ALLs2, ALLs4, ALLs234): New mode iterators.
	(gelt): New code iterator.
	(gelt_eqne): New code attribute.
	(rvbranch, *rvbranch, difficult_rvbranch, *difficult_rvbranch)
	(branch_unspec, *negated_tst<mode>, *reversed_tst<mode>)
	(*cmpqi_sign_extend): Remove insns.
	(define_c_enum "unspec") [UNSPEC_IDENTITY]: Remove.
	* config/avr/avr-dimode.md (cbranch<mode>4): Canonicalize comparisons.
	* config/avr/predicates.md (scratch_or_d_register_operand): New.
	* config/avr/constraints.md (Yxx): New constraint.

gcc/testsuite/
	PR target/109650
	* gcc.target/avr/torture/pr109650-1.c: New test.
	* gcc.target/avr/torture/pr109650-2.c: New test.
2023-06-10 21:58:32 +02:00
Francois-Xavier Coudert
17bccd1d2c Fortran: add Fortran 2018 IEEE_{MIN,MAX} functions
libgfortran/

	* ieee/ieee_arithmetic.F90: Add IEEE_MIN_NUM, IEEE_MAX_NUM,
	IEEE_MIN_NUM_MAG, and IEEE_MAX_NUM_MAG functions.

gcc/fortran/

	* f95-lang.cc (gfc_init_builtin_functions): Add fmax() and
	fmin() built-ins, and their variants.
	* mathbuiltins.def: Add FMAX and FMIN built-ins.
	* trans-intrinsic.cc (conv_intrinsic_ieee_minmax): New function.
	(gfc_conv_ieee_arithmetic_function): Handle IEEE_MIN_NUM and
	IEEE_MAX_NUM functions.

gcc/testsuite/
	* gfortran.dg/ieee/minmax_1.f90: New test.
2023-06-10 17:39:29 +02:00
Xi Ruoyao
db80262475
libatomic: x86_64: Always try ifunc
We used to skip ifunc check when CX16 is available.  But now we use
CX16+AVX+Intel/AMD for the "perfect" 16b load implementation, so CX16
alone is not a sufficient reason not to use ifunc (see PR104688).

This causes a subtle and annoying issue: when GCC is built with a
higher -march= setting in CFLAGS_FOR_TARGET, ifunc is disabled and
the worst (locked) implementation of __atomic_load_16 is always used.

There seems no good way to check if the CPU is Intel or AMD from
the built-in macros (maybe we can check every known model like __skylake,
__bdver2, ..., but it will be very error-prune and require an update
whenever we add the support for a new x86 model).  The best thing we can
do seems "always try ifunc" here.

libatomic/ChangeLog:

	* configure.tgt: For x86_64, always set try_ifunc=yes.
2023-06-10 21:43:56 +08:00
Tim Lange
39adc5eebd testsuite: Add more allocation size tests for conjured svalues [PR110014]
This patch adds the reproducers reported in PR 110014 as test cases. The
false positives in those cases are already fixed with PR 109577.

2023-06-09  Tim Lange  <mail@tim-lange.me>

	PR analyzer/110014

gcc/testsuite/ChangeLog:

	* gcc.dg/analyzer/realloc-pr110014.c: New tests.
2023-06-10 14:27:11 +02:00
Tim Lange
1d57a22325 analyzer: Fix allocation size false positive on conjured svalue [PR109577]
Currently, the analyzer tries to prove that the allocation size is a
multiple of the pointee's type size.  This patch reverses the behavior
to try to prove that the expression is not a multiple of the pointee's
type size.  With this change, each unhandled case should be gracefully
considered as correct.  This fixes the bug reported in PR 109577 by
Paul Eggert.

Regression-tested on Linux x86-64 with -m32 and -m64.

2023-06-09  Tim Lange  <mail@tim-lange.me>

	PR analyzer/109577

gcc/analyzer/ChangeLog:

	* constraint-manager.cc (class sval_finder): Visitor to find
	childs in svalue trees.
	(constraint_manager::sval_constrained_p): Add new function to
	check whether a sval might be part of an constraint.
	* constraint-manager.h: Add sval_constrained_p function.
	* region-model.cc (class size_visitor): Reverse behavior to not
	emit a warning on not explicitly considered cases.
	(region_model::check_region_size):
	Adapt to size_visitor changes.

gcc/testsuite/ChangeLog:

	* gcc.dg/analyzer/allocation-size-2.c: Change expected output
	and add new test case.
	* gcc.dg/analyzer/pr109577.c: New test.
2023-06-10 14:13:31 +02:00
Pan Li
a53a83b63b RISC-V: Add test cases for RVV FP16 vreinterpret
This patch would like to add more tests for RVV FP16 vreinterpret, aka

vfloat16*_t <==> v{u}int16*_t.

There we allow FP16 vreinterpret in ZVFHMIN consider we have vle FP16 already.
It doesn't break anything in SPEC as there is no such vreinterpret insn.
From the user's perspective, it is reasonable to do some type convert
between vfloat16 and v{u}int16 when only ZVFHMIN is enabled.

This patch would like to add new test cases to make sure the RVV FP16
vreinterpret works well as expected.

Signed-off-by: Pan Li <pan2.li@intel.com>

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/zvfh-over-zvfhmin.c: Add new cases.
	* gcc.target/riscv/rvv/base/zvfhmin-intrinsic.c: Diito.
2023-06-10 11:12:40 +08:00
Juzhe-Zhong
55dcf277b5 RISC-V: Enable select_vl for RVV auto-vectorization
Consider this following example:
void vec_add(int32_t *restrict c, int32_t *restrict a, int32_t *restrict b,
             int N) {
  for (long i = 0; i < N; i++) {
    c[i] = a[i] + b[i];
  }
}

After this patch:
vec_add:
        ble     a3,zero,.L5
.L3:
        vsetvli a5,a3,e32,m1,ta,ma
        vle32.v v2,0(a1)
        vle32.v v1,0(a2)
        vsetvli a6,zero,e32,m1,ta,ma ===> redundant vsetvl.
        slli    a4,a5,2
        vadd.vv v1,v1,v2
        sub     a3,a3,a5
        vsetvli zero,a5,e32,m1,ta,ma ===> redundant vsetvl.
        vse32.v v1,0(a0)
        add     a1,a1,a4
        add     a2,a2,a4
        add     a0,a0,a4
        bne     a3,zero,.L3
.L5:
        ret

We can get close-to-optimal codegen but with some redundant vsetvls.
This is not the big issue which will be easily addressed in RISC-V backend.

I am going to add a standalone PASS "AVL propagation" (avlprop) to addresse
such issue.

gcc/ChangeLog:

	* config/riscv/autovec.md (select_vl<mode>): New pattern.
	* config/riscv/riscv-protos.h (expand_select_vl): New function.
	* config/riscv/riscv-v.cc (expand_select_vl): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/ternop/ternop-2.c: Adapt test.
	* gcc.target/riscv/rvv/autovec/ternop/ternop-5.c: Ditto.
	* gcc.target/riscv/rvv/autovec/partial/select_vl-1.c: New test.
2023-06-10 11:11:12 +08:00
Andrew MacLeod
a13c444094 Unify MULT_EXPR range operator
Move the declaration of the class to the range-op-mixed header, add the
floating point prototypes as well, and use it in the new unified table.

	* range-op-float.cc (foperator_mult_div_base): Delete.
	(foperator_mult_div_base::find_range): Make static local function.
	(foperator_mult): Remove.  Move prototypes to range-op-mixed.h
	(operator_mult::op1_range): Rename from foperator_mult.
	(operator_mult::op2_range): Ditto.
	(operator_mult::rv_fold): Ditto.
	(float_table::float_table): Remove MULT_EXPR.
	(class foperator_div): Inherit from range_operator.
	(float_table::float_table): Delete.
	* range-op-mixed.h (class operator_mult): Combined from integer
	and float files.
	* range-op.cc (float_tree_table): Delete.
	(op_mult): New object.
	(unified_table::unified_table): Add MULT_EXPR.
	(get_op_handler): Do not check float table any longer.
	(class cross_product_operator): Move to range-op-mixed.h.
	(class operator_mult): Move to range-op-mixed.h.
	(integral_table::integral_table): Remove MULT_EXPR.
	(pointer_table::pointer_table): Remove MULT_EXPR.
	* range-op.h (float_table): Remove.
2023-06-09 20:33:03 -04:00
Andrew MacLeod
56518befc2 Unify NEGATE_EXPR range operator
Move the declaration of the class to the range-op-mixed header, add the
floating point prototypes as well, and use it in the new unified table.

	* range-op-float.cc (foperator_negate): Remove.  Move prototypes
	to range-op-mixed.h
	(operator_negate::fold_range): Rename from foperator_negate.
	(operator_negate::op1_range): Ditto.
	(float_table::float_table): Remove NEGATE_EXPR.
	* range-op-mixed.h (class operator_negate): Combined from integer
	and float files.
	* range-op.cc (op_negate): New object.
	(unified_table::unified_table): Add NEGATE_EXPR.
	(class operator_negate): Move to range-op-mixed.h.
	(integral_table::integral_table): Remove NEGATE_EXPR.
	(pointer_table::pointer_table): Remove NEGATE_EXPR.
2023-06-09 20:33:03 -04:00
Andrew MacLeod
d5818a3617 Unify MINUS_EXPR range operator
Move the declaration of the class to the range-op-mixed header, add the
floating point prototypes as well, and use it in the new unified table.

	* range-op-float.cc (foperator_minus): Remove.  Move prototypes
	to range-op-mixed.h
	(operator_minus::fold_range): Rename from foperator_minus.
	(operator_minus::op1_range): Ditto.
	(operator_minus::op2_range): Ditto.
	(operator_minus::rv_fold): Ditto.
	(float_table::float_table): Remove MINUS_EXPR.
	* range-op-mixed.h (class operator_minus): Combined from integer
	and float files.
	* range-op.cc (op_minus): New object.
	(unified_table::unified_table): Add MINUS_EXPR.
	(class operator_minus): Move to range-op-mixed.h.
	(integral_table::integral_table): Remove MINUS_EXPR.
	(pointer_table::pointer_table): Remove MINUS_EXPR.
2023-06-09 20:33:03 -04:00
Andrew MacLeod
a1aaaff33a Unify ABS_EXPR range operator
Move the declaration of the class to the range-op-mixed header, add the
floating point prototypes as well, and use it in the new unified table.

	* range-op-float.cc (foperator_abs): Remove.  Move prototypes
	to range-op-mixed.h
	(operator_abs::fold_range): Rename from foperator_abs.
	(operator_abs::op1_range): Ditto.
	(float_table::float_table): Remove ABS_EXPR.
	* range-op-mixed.h (class operator_abs): Combined from integer
	and float files.
	* range-op.cc (op_abs): New object.
	(unified_table::unified_table): Add ABS_EXPR.
	(class operator_abs): Move to range-op-mixed.h.
	(integral_table::integral_table): Remove ABS_EXPR.
	(pointer_table::pointer_table): Remove ABS_EXPR.
2023-06-09 20:33:03 -04:00
Andrew MacLeod
29dbd7ef69 Unify PLUS_EXPR range operator
Move the declaration of the class to the range-op-mixed header, add the
floating point prototypes as well, and use it in the new unified table.

	* range-op-float.cc (foperator_plus): Remove.  Move prototypes
	to range-op-mixed.h
	(operator_plus::fold_range): Rename from foperator_plus.
	(operator_plus::op1_range): Ditto.
	(operator_plus::op2_range): Ditto.
	(operator_plus::rv_fold): Ditto.
	(float_table::float_table): Remove PLUS_EXPR.
	* range-op-mixed.h (class operator_plus): Combined from integer
	and float files.
	* range-op.cc (op_plus): New object.
	(unified_table::unified_table): Add PLUS_EXPR.
	(class operator_plus): Move to range-op-mixed.h.
	(integral_table::integral_table): Remove PLUS_EXPR.
	(pointer_table::pointer_table): Remove PLUS_EXPR.
2023-06-09 20:33:03 -04:00
Andrew MacLeod
6a4ac393e1 Unify operator_cast range operator
Move the declaration of the class to the range-op-mixed header, and use it
in the new unified table.

	* range-op-mixed.h (class operator_cast): Combined from integer
	and float files.
	* range-op.cc (op_cast): New object.
	(unified_table::unified_table): Add op_cast
	(class operator_cast): Move to range-op-mixed.h.
	(integral_table::integral_table): Remove op_cast
	(pointer_table::pointer_table): Remove op_cast.
2023-06-09 20:33:02 -04:00
Andrew MacLeod
4f0ac5a526 Unify operator_cst range operator
Move the declaration of the class to the range-op-mixed header, add the
floating point prototypes as well, and use it in the new unified table.

	* range-op-float.cc (operator_cst::fold_range): New.
	* range-op-mixed.h (class operator_cst): Move from integer file.
	* range-op.cc (op_cst): New object.
	(unified_table::unified_table): Add op_cst. Also use for REAL_CST.
	(class operator_cst): Move to range-op-mixed.h.
	(integral_table::integral_table): Remove op_cst.
	(pointer_table::pointer_table): Remove op_cst.
2023-06-09 20:33:02 -04:00
Andrew MacLeod
b073d8af94 Unify Identity range operator
Move the declaration of the class to the range-op-mixed header, add the
floating point prototypes as well, and use it in the new unified table.

	* range-op-float.cc (foperator_identity): Remove.  Move prototypes
	to range-op-mixed.h
	(operator_identity::fold_range): Rename from foperator_identity.
	(operator_identity::op1_range): Ditto.
	(float_table::float_table): Remove fop_identity.
	* range-op-mixed.h (class operator_identity): Combined from integer
	and float files.
	* range-op.cc (op_identity): New object.
	(unified_table::unified_table): Add op_identity.
	(class operator_identity): Move to range-op-mixed.h.
	(integral_table::integral_table): Remove identity.
	(pointer_table::pointer_table): Remove identity.
2023-06-09 20:33:02 -04:00
Andrew MacLeod
a0a8f1c735 Unify GE_EXPR range operator
Move the declaration of the class to the range-op-mixed header, add the
floating point prototypes as well, and use it in the new unified table.

	* range-op-float.cc (foperator_ge): Remove.  Move prototypes
	to range-op-mixed.h
	(operator_ge::fold_range): Rename from foperator_ge.
	(operator_ge::op1_range): Ditto.
	(float_table::float_table): Remove GE_EXPR.
	* range-op-mixed.h (class operator_ge): Combined from integer
	and float files.
	* range-op.cc (op_ge): New object.
	(unified_table::unified_table): Add GE_EXPR.
	(class operator_ge): Move to range-op-mixed.h.
	(ge_op1_op2_relation): Fold into
	operator_ge::op1_op2_relation.
	(integral_table::integral_table): Remove GE_EXPR.
	(pointer_table::pointer_table): Remove GE_EXPR.
	* range-op.h (ge_op1_op2_relation): Delete.
2023-06-09 20:33:02 -04:00
Andrew MacLeod
f544e7e8a1 Unify GT_EXPR range operator
Move the declaration of the class to the range-op-mixed header, add the
floating point prototypes as well, and use it in the new unified table.

	* range-op-float.cc (foperator_gt): Remove.  Move prototypes
	to range-op-mixed.h
	(operator_gt::fold_range): Rename from foperator_gt.
	(operator_gt::op1_range): Ditto.
	(float_table::float_table): Remove GT_EXPR.
	* range-op-mixed.h (class operator_gt): Combined from integer
	and float files.
	* range-op.cc (op_gt): New object.
	(unified_table::unified_table): Add GT_EXPR.
	(class operator_gt): Move to range-op-mixed.h.
	(gt_op1_op2_relation): Fold into
	operator_gt::op1_op2_relation.
	(integral_table::integral_table): Remove GT_EXPR.
	(pointer_table::pointer_table): Remove GT_EXPR.
	* range-op.h (gt_op1_op2_relation): Delete.
2023-06-09 20:33:02 -04:00
Andrew MacLeod
d251d14ccd Unify LE_EXPR range operator
Move the declaration of the class to the range-op-mixed header, add the
floating point prototypes as well, and use it in the new unified table.

	* range-op-float.cc (foperator_le): Remove.  Move prototypes
	to range-op-mixed.h
	(operator_le::fold_range): Rename from foperator_le.
	(operator_le::op1_range): Ditto.
	(float_table::float_table): Remove LE_EXPR.
	* range-op-mixed.h (class operator_le): Combined from integer
	and float files.
	* range-op.cc (op_le): New object.
	(unified_table::unified_table): Add LE_EXPR.
	(class operator_le): Move to range-op-mixed.h.
	(le_op1_op2_relation): Fold into
	operator_le::op1_op2_relation.
	(integral_table::integral_table): Remove LE_EXPR.
	(pointer_table::pointer_table): Remove LE_EXPR.
	* range-op.h (le_op1_op2_relation): Delete.
2023-06-09 20:33:02 -04:00
Andrew MacLeod
5b07954100 Unify LT_EXPR range operator
Move the declaration of the class to the range-op-mixed header, add the
floating point prototypes as well, and use it in the new unified table.

	* range-op-float.cc (foperator_lt): Remove.  Move prototypes
	to range-op-mixed.h
	(operator_lt::fold_range): Rename from foperator_lt.
	(operator_lt::op1_range): Ditto.
	(float_table::float_table): Remove LT_EXPR.
	* range-op-mixed.h (class operator_lt): Combined from integer
	and float files.
	* range-op.cc (op_lt): New object.
	(unified_table::unified_table): Add LT_EXPR.
	(class operator_lt): Move to range-op-mixed.h.
	(lt_op1_op2_relation): Fold into
	operator_lt::op1_op2_relation.
	(integral_table::integral_table): Remove LT_EXPR.
	(pointer_table::pointer_table): Remove LT_EXPR.
	* range-op.h (lt_op1_op2_relation): Delete.
2023-06-09 20:33:02 -04:00
Andrew MacLeod
eb29c3e1fa Unify NE_EXPR range operator
Move the declaration of the class to the range-op-mixed header, add the
floating point prototypes as well, and use it in the new unified table.

	* range-op-float.cc (foperator_not_equal): Remove.  Move prototypes
	to range-op-mixed.h
	(operator_equal::fold_range): Rename from foperator_not_equal.
	(operator_equal::op1_range): Ditto.
	(float_table::float_table): Remove NE_EXPR.
	* range-op-mixed.h (class operator_not_equal): Combined from integer
	and float files.
	* range-op.cc (op_equal): New object.
	(unified_table::unified_table): Add NE_EXPR.
	(class operator_not_equal): Move to range-op-mixed.h.
	(not_equal_op1_op2_relation): Fold into
	operator_not_equal::op1_op2_relation.
	(integral_table::integral_table): Remove NE_EXPR.
	(pointer_table::pointer_table): Remove NE_EXPR.
	* range-op.h (not_equal_op1_op2_relation): Delete.
2023-06-09 20:33:02 -04:00
Andrew MacLeod
2dbf1e6146 Unify EQ_EXPR range operator
Move the declaration of the class to the range-op-mixed header, add the
floating point prototypes as well, and use it in the new unified table.

	* range-op-float.cc (foperator_equal): Remove.  Move prototypes
	to range-op-mixed.h
	(operator_equal::fold_range): Rename from foperator_equal.
	(operator_equal::op1_range): Ditto.
	(float_table::float_table): Remove EQ_EXPR.
	* range-op-mixed.h (class operator_equal): Combined from integer
	and float files.
	* range-op.cc (op_equal): New object.
	(unified_table::unified_table): Add EQ_EXPR.
	(class operator_equal): Move to range-op-mixed.h.
	(equal_op1_op2_relation): Fold into
	operator_equal::op1_op2_relation.
	(integral_table::integral_table): Remove EQ_EXPR.
	(pointer_table::pointer_table): Remove EQ_EXPR.
	* range-op.h (equal_op1_op2_relation): Delete.
2023-06-09 20:33:02 -04:00
Andrew MacLeod
07767389fb Provide a unified range-op table.
Create a table to prepare for unifying all operations into a single table.
Move any operators which only occur in one table to the approriate
initialization routine.
Provide a mixed header file for range-ops with multiple categories.

	* range-op-float.cc (class float_table): Move to header.
	(float_table::float_table): Move float only operators to...
	(range_op_table::initialize_float_ops): Here.
	* range-op-mixed.h: New.
	* range-op.cc (integral_tree_table, pointer_tree_table): Moved
	to top of file.
	(float_tree_table): Moved from range-op-float.cc.
	(unified_tree_table): New.
	(unified_table::unified_table): New.  Call initialize routines.
	(get_op_handler): Check unified table first.
	(range_op_handler::range_op_handler): Handle no type constructor.
	(integral_table::integral_table): Move integral only operators to...
	(range_op_table::initialize_integral_ops): Here.
	(pointer_table::pointer_table): Move pointer only operators to...
	(range_op_table::initialize_pointer_ops): Here.
	* range-op.h (enum bool_range_state): Move to range-op-mixed.h.
	(get_bool_state): Ditto.
	(empty_range_varying): Ditto.
	(relop_early_resolve): Ditto.
	(class range_op_table): Add new init methods for range types.
	(class integral_table): Move declaration to here.
	(class pointer_table): Move declaration to here.
	(class float_table): Move declaration to here.
2023-06-09 20:33:02 -04:00
GCC Administrator
a2c019e27d Daily bump. 2023-06-10 00:17:41 +00:00
Ju-Zhe Zhong
47203d89a0 VECT: Add SELECT_VL support
This patch address comments from Richard && Richi and rebase to trunk.

This patch is adding SELECT_VL middle-end support
allow target have target dependent optimization in case of
length calculation.

This patch is inspired by RVV ISA and LLVM:
https://reviews.llvm.org/D99750

The SELECT_VL is same behavior as LLVM "get_vector_length" with
these following properties:

1. Only apply on single-rgroup.
2. non SLP.
3. adjust loop control IV.
4. adjust data reference IV.
5. allow non-vf elements processing in non-final iteration

Code
   # void vvaddint32(size_t n, const int*x, const int*y, int*z)
   # { for (size_t i=0; i<n; i++) { z[i]=x[i]+y[i]; } }

Take RVV codegen for example:

Before this patch:
vvaddint32:
        ble     a0,zero,.L6
        csrr    a4,vlenb
        srli    a6,a4,2
.L4:
        mv      a5,a0
        bleu    a0,a6,.L3
        mv      a5,a6
.L3:
        vsetvli zero,a5,e32,m1,ta,ma
        vle32.v v2,0(a1)
        vle32.v v1,0(a2)
        vsetvli a7,zero,e32,m1,ta,ma
        sub     a0,a0,a5
        vadd.vv v1,v1,v2
        vsetvli zero,a5,e32,m1,ta,ma
        vse32.v v1,0(a3)
        add     a2,a2,a4
        add     a3,a3,a4
        add     a1,a1,a4
        bne     a0,zero,.L4
.L6:
        ret

After this patch:

vvaddint32:
    vsetvli t0, a0, e32, ta, ma  # Set vector length based on 32-bit vectors
    vle32.v v0, (a1)         # Get first vector
      sub a0, a0, t0         # Decrement number done
      slli t0, t0, 2         # Multiply number done by 4 bytes
      add a1, a1, t0         # Bump pointer
    vle32.v v1, (a2)         # Get second vector
      add a2, a2, t0         # Bump pointer
    vadd.vv v2, v0, v1       # Sum vectors
    vse32.v v2, (a3)         # Store result
      add a3, a3, t0         # Bump pointer
      bnez a0, vvaddint32    # Loop back
      ret                    # Finished

Co-authored-by: Richard Sandiford<richard.sandiford@arm.com>
Co-authored-by: Richard Biener <rguenther@suse.de>

gcc/ChangeLog:

	* doc/md.texi: Add SELECT_VL support.
	* internal-fn.def (SELECT_VL): Ditto.
	* optabs.def (OPTAB_D): Ditto.
	* tree-vect-loop-manip.cc (vect_set_loop_controls_directly): Ditto.
	* tree-vect-loop.cc (_loop_vec_info::_loop_vec_info): Ditto.
	* tree-vect-stmts.cc (get_select_vl_data_ref_ptr): Ditto.
	(vectorizable_store): Ditto.
	(vectorizable_load): Ditto.
	* tree-vectorizer.h (LOOP_VINFO_USING_SELECT_VL_P): Ditto.
2023-06-10 07:52:46 +08:00
David Malcolm
fe9771b59f analyzer: add caching to globals with initializers [PR110112]
PR analyzer/110112 notes that -fanalyzer is extremely slow on a source
file with large read-only static arrays, repeatedly building the
same compound_svalue representing the full initializer, and repeatedly
building svalues representing parts of the the full initialiazer.

This patch adds caches for both of these; together they reduce the time
taken by -fanalyzer -O2 on the testcase in the bug for an optimized
build:
  91.2s : no caches (status quo)
  32.4s : cache in decl_region::get_svalue_for_constructor
   3.7s : cache in region::get_initial_value_at_main
   3.1s : both caches (this patch)

gcc/analyzer/ChangeLog:
	PR analyzer/110112
	* region-model.cc (region_model::get_initial_value_for_global):
	Move code to region::calc_initial_value_at_main.
	* region.cc (region::get_initial_value_at_main): New function.
	(region::calc_initial_value_at_main): New function, based on code
	in region_model::get_initial_value_for_global.
	(region::region): Initialize m_cached_init_sval_at_main.
	(decl_region::get_svalue_for_constructor): Add a cache, splitting
	out body to...
	(decl_region::calc_svalue_for_constructor): ...this new function.
	* region.h (region::get_initial_value_at_main): New decl.
	(region::calc_initial_value_at_main): New decl.
	(region::m_cached_init_sval_at_main): New field.
	(decl_region::decl_region): Initialize m_ctor_svalue.
	(decl_region::calc_svalue_for_constructor): New decl.
	(decl_region::m_ctor_svalue): New field.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-06-09 17:58:33 -04:00
Ken Matsui
067a8c7cb8 libstdc++: use using instead of typedef for type_traits
Since the type_traits header is a C++11 header file, using can be used instead
of typedef. This patch provides more readability, especially for long type
names.

libstdc++-v3/ChangeLog:

	* include/std/type_traits: Use using instead of typedef

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2023-06-09 13:30:39 -04:00
Andrew MacLeod
5612aa4d06 Also check type being cast to
before casting into an irange, make sure the type being cast into
is also supported.

	PR ipa/109886
	* ipa-prop.cc (ipa_compute_jump_functions_for_edge): Check param
	type as well.
2023-06-09 12:31:20 -04:00
Andrew MacLeod
c570818b43 Relocate range_cast to header, and add a generic version.
Make range_cast inlinable by moving it to the header file.
Also trap if the destination is not capable of representing the cast type.
Add a generic version which can change range classes.. ie float to int.

	* range-op.cc (range_cast): Move to...
	* range-op.h (range_cast): Here and add generic a version.
2023-06-09 12:31:20 -04:00
Jason Merrill
953bbeaeff c++: fix 32-bit spaceship failures [PR110185]
Various spaceship tests failed after r14-1624.  This turned out to be
because the comparison category classes return in memory on 32-bit targets,
and the synthesized operator<=> looks something like

if (auto v = a.x <=> b.x, v == 0); else return v;
if (auto v = a.y <=> b.y, v == 0); else return v;
etc.

so check_return_expr was trying to do NRVO for all the 'v' variables, and
now on subsequent returns we check to see if the previous NRV is still in
scope.  But the NRVs didn't have names, so looking up name bindings crashed.
Fixed both by giving 'v' a name so we can NRVO the first one, and fixing the
test to give up if the old NRV has no name.

	PR c++/110185
	PR c++/58487

gcc/cp/ChangeLog:

	* method.cc (build_comparison_op): Give retval a name.
	* typeck.cc (check_return_expr): Fix for nameless variables.
2023-06-09 11:41:42 -04:00
Jason Merrill
d3e2a174b1 c++: diagnose auto in template arg
We were failing to diagnose this Concepts TS feature that didn't make it
into C++20 because the 'auto' was getting converted to a template parameter
before we checked for it.  So also check in cp_parser_simple_type_specifier.

The code in cp_parser_template_type_arg that I initially expected to
diagnose this seems unreachable because cp_parser_type_id_1 already checks
auto.

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_simple_type_specifier): Check for auto
	in template argument.
	(cp_parser_template_type_arg): Remove auto checking.

gcc/testsuite/ChangeLog:

	* g++.dg/concepts/auto7.C: New test.
	* g++.dg/concepts/auto7a.C: New test.
2023-06-09 11:41:42 -04:00
Jason Merrill
35d2c40e4a c++: init-list of uncopyable type [PR110102]
The maybe_init_list_as_range optimization is a form of copy elision, but we
can only elide well-formed copies.

	PR c++/110102

gcc/cp/ChangeLog:

	* call.cc (maybe_init_list_as_array): Check that the element type is
	copyable.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/initlist-opt1.C: New test.
2023-06-09 11:41:42 -04:00
Marek Polacek
0f8f1dee85 doc: Clarification for -Wmissing-field-initializers
The manual is incorrect in saying that the option does not warn
about designated initializers, which it does in C++.  Whether the
divergence in behavior is desirable is another thing, but let's
at least make the manual match the reality.

	PR c/39589
	PR c++/96868

gcc/ChangeLog:

	* doc/invoke.texi: Clarify that -Wmissing-field-initializers doesn't
	warn about designated initializers in C only.
2023-06-09 10:22:42 -04:00
Andrew Pinski
55fcaa9a8b Add Plus to the op list of (zero_one == 0) ? y : z <op> y pattern
This adds plus to the op list of `(zero_one == 0) ? y : z <op> y` patterns
which currently has bit_ior and bit_xor.
This shows up now in GCC after the boolization work that Uroš has been doing.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

	PR tree-optimization/97711
	PR tree-optimization/110155

gcc/ChangeLog:

	* match.pd ((zero_one == 0) ? y : z <op> y): Add plus to the op.
	((zero_one != 0) ? z <op> y : y): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/branchless-cond-add-2.c: New test.
	* gcc.dg/tree-ssa/branchless-cond-add.c: New test.
2023-06-09 07:15:22 -07:00
Andrew Pinski
52c92fb3f4 Change the (zero_one ==/!= 0) ? y : z <op> y patterns to use multiply rather than (-zero_one) & z
Since there is a pattern to convert `(-zero_one) & z` into `zero_one * z` already,
it is better if we don't do a secondary transformation. This reduces the extra
statements produced by match-and-simplify on the gimple level too.

gcc/ChangeLog:

	* match.pd ((zero_one ==/!= 0) ? y : z <op> y): Use
	multiply rather than negation/bit_and.
2023-06-09 07:14:53 -07:00
Andrew Pinski
7ceed7e3e2 MATCH: Allow unsigned types for X & -Y -> X * Y pattern
This allows unsigned types if the inner type where the negation is
located has greater than or equal to precision than the outer type.

branchless-cond.c needs to be updated since now we change it to
use a multiply rather than still having (-a)&c in there.

OK? Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

	* match.pd (`X & -Y -> X * Y`): Allow for truncation
	and the same type for unsigned types.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/branchless-cond.c: Update testcase.
2023-06-09 07:09:15 -07:00
Andrew Pinski
72e652f342 MATCH: Fix zero_one_valued_p not to match signed 1 bit integers
So for the attached testcase, we assumed that zero_one_valued_p would
be the value [0,1] but currently zero_one_valued_p matches also
signed 1 bit integers.
This changes that not to match that and fixes the 2 new testcases at
all optimization levels.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Note the GCC 13 patch will be slightly different due to the changes
made to zero_one_valued_p.

	PR tree-optimization/110165
	PR tree-optimization/110166

gcc/ChangeLog:

	* match.pd (zero_one_valued_p): Don't accept
	signed 1-bit integers.

gcc/testsuite/ChangeLog:

	* gcc.c-torture/execute/pr110165-1.c: New test.
	* gcc.c-torture/execute/pr110166-1.c: New test.
2023-06-09 07:09:15 -07:00
Lehua Ding
45b7da5f49 testsuite: fix the condition bug in tsvc s176
This patch fixes the problem that the loop in the tsvc s176 function is
optimized and removed because `iterations/LEN_1D` is 0 (where iterations
is set to 10000, LEN_1D is set to 32000 in tsvc.h).

This testcase passed on x86 and AArch64 system.

Best,
Lehua

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/tsvc/vect-tsvc-s176.c: Adjust iterations.
	* gcc.dg/vect/tsvc/tsvc.h: Adjust expected rsult for s176.
2023-06-09 07:29:14 -06:00
Jonathan Wakely
00da6bcfcc libstdc++: Remove duplicate definition of _Float128 std::from_chars [PR110077]
When long double uses IEEE binary128 representation we define the
_Float128 overload of std::from_chars inline in <charconv>. My changes
in r14-1431-g7037e7b6e4ac41 cause it to also be defined non-inline in
the library, leading to an abi-check failure for (at least) sparc and
aarch64.

Suppress the definition in the library if long double and _Float128 have
are both IEEE binary128.

libstdc++-v3/ChangeLog:

	PR libstdc++/110077
	* src/c++17/floating_from_chars.cc (from_chars) <_Float128>:
	Only define if _Float128 and long double have different
	representations.
2023-06-09 13:15:39 +01:00
Jonathan Wakely
793ed718b5 libstdc++: Add preprocessor checks to <experimental/internet> [PR100285]
We can't define endpoints and resolvers without the relevant OS support.
If IPPROTO_TCP and IPPROTO_UDP are both udnefined then we won't need
basic_endpoint and basic_resovler anyway, so make them depend on those
macros.

libstdc++-v3/ChangeLog:

	PR libstdc++/100285
	* include/experimental/internet [IPPROTO_TCP || IPPROTO_UDP]
	(basic_endpoint, basic_resolver_entry, resolver_base)
	(basic_resolver_results, basic_resolver): Only define if the tcp
	or udp protocols will be defined.
2023-06-09 13:15:39 +01:00
Jonathan Wakely
9a3558cf1f libstdc++: Bump library version to libstdc++.so.6.0.33
The addition of __cxa_call_terminate@@CXXABI_1.3.15 on trunk means we
need a new version.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (libtool_VERSION): Update to 6.0.33.
	* configure: Regenerate.
	* doc/xml/manual/abi.xml: Add libstdc++.so.6.0.33.
	* doc/html/manual/abi.html: Regenerate.
2023-06-09 13:08:26 +01:00
Jonathan Wakely
628ba410b9 libstdc++: Fix P2510R3 "Formatting pointers" [PR110149]
I had intended to support the P2510R3 proposal unconditionally in C++20
mode, but I left it half implemented. The parse function supported the
new extensions, but the format function didn't.

This adds the missing pieces, and makes it only enabled for C++26 and
non-strict modes.

libstdc++-v3/ChangeLog:

	PR libstdc++/110149
	* include/std/format (formatter<const void*, charT>::parse):
	Only alow 0 and P for C++26 and non-strict modes.
	(formatter<const void*, charT>::format): Use toupper for P
	type, and insert zero-fill characters for 0 option.
	* testsuite/std/format/functions/format.cc: Check pointer
	formatting. Only check P2510R3 extensions conditionally.
	* testsuite/std/format/parse_ctx.cc: Only check P2510R3
	extensions conditionally.
2023-06-09 13:08:25 +01:00
Jonathan Wakely
960de5dd88 libstdc++: Optimize std::to_array for trivial types [PR110167]
As reported in PR libstdc++/110167, std::to_array compiles extremely
slowly for very large arrays. It needs to instantiate a very large
specialization of std::index_sequence<N...> and then create a very large
aggregate initializer from the pack expansion. For trivial types we can
simply default-initialize the std::array and then use memcpy to copy the
values. For non-trivial types we need to use the existing
implementation, despite the compilation cost.

As also noted in the PR, using a generic lambda instead of the
__to_array helper compiles faster since gcc-13. It also produces
slightly smaller code at -O1, due to additional inlining. The code at
-Os, -O2 and -O3 seems to be the same. This new implementation requires
__cpp_generic_lambdas >= 201707L (i.e. P0428R2) but that is supported
since Clang 10 and since Intel icc 2021.5.0 (and since GCC 10.1).

libstdc++-v3/ChangeLog:

	PR libstdc++/110167
	* include/std/array (to_array): Initialize arrays of trivial
	types using memcpy. For non-trivial types, use lambda
	expressions instead of a separate helper function.
	(__to_array): Remove.
	* testsuite/23_containers/array/creation/110167.cc: New test.
2023-06-09 13:08:25 +01:00
Richard Biener
3e12669a0e middle-end/110182 - TYPE_PRECISION on VECTOR_TYPE causes wrong-code
When folding two conversions in a row we use TYPE_PRECISION but
that's invalid for VECTOR_TYPE.  The following fixes this by
using element_precision instead.

	* match.pd (two conversions in a row): Use element_precision
	to DTRT for VECTOR_TYPE.
2023-06-09 11:07:08 +02:00
Jonathan Wakely
3ec1d76a35 libstdc++: Improve tests for emplace member of sequence containers
Our existing tests for std::deque::emplace, std::list::emplace and
std::vector::emplace are poor. We only have compile tests for PR 52799
and the equivalent for a const_iterator as the insertion point. This
fails to check that the value is actually inserted correctly and the
right iterator is returned.

Add new tests that cover the existing 52799.cc and const_iterator.cc
compile-only tests, as well as verifying the effects are correct.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/deque/modifiers/emplace/52799.cc:
	Removed.
	* testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc:
	Removed.
	* testsuite/23_containers/list/modifiers/emplace/52799.cc:
	Removed.
	* testsuite/23_containers/list/modifiers/emplace/const_iterator.cc:
	Removed.
	* testsuite/23_containers/vector/modifiers/emplace/52799.cc:
	Removed.
	* testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc:
	Removed.
	* testsuite/23_containers/deque/modifiers/emplace/1.cc: New
	test.
	* testsuite/23_containers/list/modifiers/emplace/1.cc: New
	test.
	* testsuite/23_containers/vector/modifiers/emplace/1.cc: New
	test.
2023-06-09 09:55:42 +01:00
Pan Li
cb33116afc RISC-V: Refactor requirement of ZVFH and ZVFHMIN.
This patch would like to refactor the requirement of both the ZVFH
and ZVFHMIN. By default, the ZVFHMIN will enable FP16 for all the
iterators of RVV. And then the ZVFH will leverage one define attr as
the gate for FP16 supported or not.

Please note the ZVFH will cover the ZVFHMIN instructions. This patch
add one test for this.

Signed-off-by: Pan Li <pan2.li@intel.com>
Co-Authored by: Juzhe-Zhong <juzhe.zhong@rivai.ai>
Co-Authored by: Kito Cheng <kito.cheng@sifive.com>

gcc/ChangeLog:

	* config/riscv/riscv.md (enabled): Move to another place, and
	add fp_vector_disabled to the cond.
	(fp_vector_disabled): New attr defined for disabling fp.
	* config/riscv/vector-iterators.md: Fix V_WHOLE and V_FRACT.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/zvfhmin-intrinsic.c: Add vle16 test
	for ZVFHMIN.
2023-06-09 16:30:05 +08:00
Pan Li
7f4644f8c6 RISC-V: Fix one warning of frm enum.
This patch would like to fix one warning similar as below, and add the
link for where the values comes from.

./gcc/config/riscv/riscv-protos.h:260:13: warning: binary constants are
a C++14 feature or GCC extension
	FRM_RNE = 0b000,
	          ^~~~~

Signed-off-by: Pan Li <pan2.li@intel.com>

gcc/ChangeLog:

	* config/riscv/riscv-protos.h (enum frm_field_enum): Adjust
	literal to int.
2023-06-09 16:13:27 +08:00
Jakub Jelinek
4cf6e322ad fortran: Fix ICE on pr96024.f90 on big-endian hosts [PR96024]
The pr96024.f90 testcase ICEs on big-endian hosts.  The problem is
that length->val.integer is accessed after checking
length->expr_type == EXPR_CONSTANT, but it is a CHARACTER constant
which uses length->val.character union member instead and on big-endian
we end up reading constant 0x100000000 rather than some small number
on little-endian and if target doesn't have enough memory for 4 times
that (i.e. 16GB allocation), it ICEs.

2023-06-09  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/96024
	* primary.cc (gfc_convert_to_structure_constructor): Only do
	constant string ctor length verification and truncation/padding
	if constant length has INTEGER type.
2023-06-09 09:10:29 +02:00
liuhongt
dac73e4c64 Explicitly view_convert_expr mask to signed type when folding pblendvb builtins.
Since mask < 0 will be always false for vector char when
-funsigned-char, but vpblendvb needs to check the most significant
bit. The patch explicitly VCE to vector signed char.

gcc/ChangeLog:

	PR target/110108
	* config/i386/i386.cc (ix86_gimple_fold_builtin): Explicitly
	view_convert_expr mask to signed type when folding pblendvb
	builtins.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr110108-2.c: New test.
2023-06-09 09:41:47 +08:00