Skip to content
Snippets Groups Projects
  1. Jun 11, 2023
  2. Jun 10, 2023
    • Aldy Hernandez's avatar
      Convert ipcp_vr_lattice to type agnostic framework. · bc5a2c2e
      Aldy Hernandez authored
      This converts the lattice to store ranges in Value_Range instead of
      value_range (*) to make it type agnostic, and adjust all users
      accordingly.
      
      I've been careful to make sure Value_Range never ends up on GC, since
      it contains an int_range_max and can expand on-demand onto the heap.
      Longer term storage for ranges should be done with vrange_storage, as
      per the previous patch ("Provide an API for ipa_vr").
      
      gcc/ChangeLog:
      
      	* ipa-cp.cc (ipcp_vr_lattice::init): Take type argument.
      	(ipcp_vr_lattice::print): Call dump method.
      	(ipcp_vr_lattice::meet_with): Adjust for m_vr being a
      	Value_Range.
      	(ipcp_vr_lattice::meet_with_1): Make argument a reference.
      	(ipcp_vr_lattice::set_to_bottom): Set varying for an unsupported
      	range.
      	(initialize_node_lattices): Pass type when appropriate.
      	(ipa_vr_operation_and_type_effects): Make type agnostic.
      	(ipa_value_range_from_jfunc): Same.
      	(propagate_vr_across_jump_function): Same.
      	* ipa-fnsummary.cc (evaluate_conditions_for_known_args): Same.
      	(evaluate_properties_for_edge): Same.
      	* ipa-prop.cc (ipa_vr::get_vrange): Same.
      	(ipcp_update_vr): Same.
      	* ipa-prop.h (ipa_value_range_from_jfunc): Same.
      	(ipa_range_set_and_normalize): Same.
      bc5a2c2e
    • Hans-Peter Nilsson's avatar
      testsuite: Cut down 27_io/basic_istream/.../94749.cc for simulators · 273a33b2
      Hans-Peter Nilsson authored
      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.
      273a33b2
    • Nathan Sidwell's avatar
      c++: Adjust conversion deduction [PR61663][DR976] · 80f075b4
      Nathan Sidwell authored
      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.
      80f075b4
    • Georg-Johann Lay's avatar
      target/109650: Fix wrong code after cc0 -> CCmode transition. · 30a8771c
      Georg-Johann Lay authored
      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.
      30a8771c
    • Francois-Xavier Coudert's avatar
      Fortran: add Fortran 2018 IEEE_{MIN,MAX} functions · 17bccd1d
      Francois-Xavier Coudert authored
      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.
      17bccd1d
    • Xi Ruoyao's avatar
      libatomic: x86_64: Always try ifunc · db802624
      Xi Ruoyao authored
      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.
      db802624
    • Tim Lange's avatar
      testsuite: Add more allocation size tests for conjured svalues [PR110014] · 39adc5ee
      Tim Lange authored
      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.
      39adc5ee
    • Tim Lange's avatar
      analyzer: Fix allocation size false positive on conjured svalue [PR109577] · 1d57a223
      Tim Lange authored
      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.
      1d57a223
    • Pan Li's avatar
      RISC-V: Add test cases for RVV FP16 vreinterpret · a53a83b6
      Pan Li authored
      
      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: default avatarPan 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.
      a53a83b6
    • Juzhe-Zhong's avatar
      RISC-V: Enable select_vl for RVV auto-vectorization · 55dcf277
      Juzhe-Zhong authored
      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.
      55dcf277
    • Andrew MacLeod's avatar
      Unify MULT_EXPR range operator · a13c4440
      Andrew MacLeod authored
      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.
      a13c4440
    • Andrew MacLeod's avatar
      Unify NEGATE_EXPR range operator · 56518bef
      Andrew MacLeod authored
      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.
      56518bef
    • Andrew MacLeod's avatar
      Unify MINUS_EXPR range operator · d5818a36
      Andrew MacLeod authored
      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.
      d5818a36
    • Andrew MacLeod's avatar
      Unify ABS_EXPR range operator · a1aaaff3
      Andrew MacLeod authored
      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.
      a1aaaff3
    • Andrew MacLeod's avatar
      Unify PLUS_EXPR range operator · 29dbd7ef
      Andrew MacLeod authored
      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.
      29dbd7ef
    • Andrew MacLeod's avatar
      Unify operator_cast range operator · 6a4ac393
      Andrew MacLeod authored
      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.
      6a4ac393
    • Andrew MacLeod's avatar
      Unify operator_cst range operator · 4f0ac5a5
      Andrew MacLeod authored
      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.
      4f0ac5a5
    • Andrew MacLeod's avatar
      Unify Identity range operator · b073d8af
      Andrew MacLeod authored
      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.
      b073d8af
    • Andrew MacLeod's avatar
      Unify GE_EXPR range operator · a0a8f1c7
      Andrew MacLeod authored
      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.
      a0a8f1c7
    • Andrew MacLeod's avatar
      Unify GT_EXPR range operator · f544e7e8
      Andrew MacLeod authored
      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.
      f544e7e8
    • Andrew MacLeod's avatar
      Unify LE_EXPR range operator · d251d14c
      Andrew MacLeod authored
      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.
      d251d14c
    • Andrew MacLeod's avatar
      Unify LT_EXPR range operator · 5b079541
      Andrew MacLeod authored
      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.
      5b079541
    • Andrew MacLeod's avatar
      Unify NE_EXPR range operator · eb29c3e1
      Andrew MacLeod authored
      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.
      eb29c3e1
    • Andrew MacLeod's avatar
      Unify EQ_EXPR range operator · 2dbf1e61
      Andrew MacLeod authored
      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.
      2dbf1e61
    • Andrew MacLeod's avatar
      Provide a unified range-op table. · 07767389
      Andrew MacLeod authored
      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.
      07767389
    • GCC Administrator's avatar
      Daily bump. · a2c019e2
      GCC Administrator authored
      a2c019e2
  3. Jun 09, 2023
    • Ju-Zhe Zhong's avatar
      VECT: Add SELECT_VL support · 47203d89
      Ju-Zhe Zhong authored
      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: default avatarRichard <Sandiford&lt;richard.sandiford@arm.com>
      Co-authored-by: default avatarRichard 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.
      47203d89
    • David Malcolm's avatar
      analyzer: add caching to globals with initializers [PR110112] · fe9771b5
      David Malcolm authored
      
      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: default avatarDavid Malcolm <dmalcolm@redhat.com>
      fe9771b5
    • Ken Matsui's avatar
      libstdc++: use using instead of typedef for type_traits · 067a8c7c
      Ken Matsui authored
      
      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: default avatarPatrick Palka <ppalka@redhat.com>
      Reviewed-by: default avatarJonathan Wakely <jwakely@redhat.com>
      067a8c7c
    • Andrew MacLeod's avatar
      Also check type being cast to · 5612aa4d
      Andrew MacLeod authored
      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.
      5612aa4d
    • Andrew MacLeod's avatar
      Relocate range_cast to header, and add a generic version. · c570818b
      Andrew MacLeod authored
      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.
      c570818b
    • Jason Merrill's avatar
      c++: fix 32-bit spaceship failures [PR110185] · 953bbeae
      Jason Merrill authored
      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.
      953bbeae
    • Jason Merrill's avatar
      c++: diagnose auto in template arg · d3e2a174
      Jason Merrill authored
      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.
      d3e2a174
    • Jason Merrill's avatar
      c++: init-list of uncopyable type [PR110102] · 35d2c40e
      Jason Merrill authored
      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.
      35d2c40e
    • Marek Polacek's avatar
      doc: Clarification for -Wmissing-field-initializers · 0f8f1dee
      Marek Polacek authored
      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.
      0f8f1dee
    • Andrew Pinski's avatar
      Add Plus to the op list of `(zero_one == 0) ? y : z <op> y` pattern · 55fcaa9a
      Andrew Pinski authored
      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.
      55fcaa9a
    • Andrew Pinski's avatar
      Change the `(zero_one ==/!= 0) ? y : z <op> y` patterns to use multiply rather... · 52c92fb3
      Andrew Pinski authored
      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.
      52c92fb3
    • Andrew Pinski's avatar
      MATCH: Allow unsigned types for `X & -Y -> X * Y` pattern · 7ceed7e3
      Andrew Pinski authored
      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.
      7ceed7e3
    • Andrew Pinski's avatar
      MATCH: Fix zero_one_valued_p not to match signed 1 bit integers · 72e652f3
      Andrew Pinski authored
      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.
      72e652f3
Loading