[Bug c++/61663] [DR 976] Deduction for const T& conversion functions

2023-06-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61663

--- Comment #5 from CVS Commits  ---
The trunk branch has been updated by Nathan Sidwell :

https://gcc.gnu.org/g:80f075b410125bddb31459428760645baba1a69f

commit r14-1689-g80f075b410125bddb31459428760645baba1a69f
Author: Nathan Sidwell 
Date:   Sat Jun 10 12:42:17 2023 -0400

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.

[Bug target/109650] avr-gcc incorrect code with -Os

2023-06-10 Thread gjl at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109650

Georg-Johann Lay  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #14 from Georg-Johann Lay  ---
Fixed in v12.4+ and v13.2+.

[Bug rtl-optimization/110202] _mm512_ternarylogic_epi64 generates unnecessary operations

2023-06-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110202

Andrew Pinski  changed:

   What|Removed |Added

   Last reconfirmed||2023-06-10
 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW

--- Comment #4 from Andrew Pinski  ---
(In reply to Jakub Jelinek from comment #3)
> Well, there is nothing magic on exactly 0x55 immediate, there are 256
> possible immediates, most of them use all of A, B, C, some of them use just
> A, B, others just B, C, others just A, C, others just A, others just B,
> others just C, others none of them.
> And I must say I don't immediately see easy rules how to find out from the
> immediate value which set is which, so unless we find some easy rule for
> that, we'd need to hardcode the mapping between the 256 values to a bitmask
> which inputs are actually used.
> And then the question is how to represent that in RTL to make it clear that
> some operands are mentioned but their value isn't really used.

In the case of 0x55, an idea might be to split (or expand) it into how ~ is
represented.

That is:
(insn:TI 6 3 12 2 (set (reg:V8DI 20 xmm0 [85])
(xor:V8DI (mem:V8DI (reg/v/f:DI 5 di [orig:84 a ] [84]) [0 *a_3(D)+0
S64 A512])
(const_vector:V8DI [
(const_int -1 [0x]) repeated x8
]))) "/app/example.cpp":21:14 6764 {*one_cmplv8di2}
 (expr_list:REG_DEAD (reg/v/f:DI 5 di [orig:84 a ] [84])
(nil)))

[Bug target/109650] avr-gcc incorrect code with -Os

2023-06-10 Thread gjl at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109650

Georg-Johann Lay  changed:

   What|Removed |Added

 CC|saaadhu at gcc dot gnu.org |

--- Comment #13 from Georg-Johann Lay  ---
r14-1688

[Bug target/92729] [avr] Convert the backend to MODE_CC so it can be kept in future releases

2023-06-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92729

--- Comment #64 from CVS Commits  ---
The releases/gcc-12 branch has been updated by Georg-Johann Lay
:

https://gcc.gnu.org/g:ee92dc2dae45acc79d4dc08ea31adf894831840a

commit r12-9691-gee92dc2dae45acc79d4dc08ea31adf894831840a
Author: Georg-Johann Lay 
Date:   Sat Jun 10 21:47:53 2023 +0200

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
Backport from 2023-05-10 master r14-1688.
* 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, *add.for.eqne.): New insns.
(*cbranch4): Rename to cbranch4_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.
Rework signtest-and-branch peepholes for *sbrx_branch.
(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, *reversed_tst)
(*cmpqi_sign_extend): Remove insns.
(define_c_enum "unspec") [UNSPEC_IDENTITY]: Remove.
* config/avr/avr-dimode.md (cbranch4): Canonicalize
comparisons.
* config/avr/predicates.md (scratch_or_d_register_operand): New.
* config/avr/constraints.md (Yxx): New constraint.

gcc/testsuite/
PR target/109650
Backport from 2023-05-10 master r14-1688.
* gcc.target/avr/torture/pr109650-1.c: New test.
* gcc.target/avr/torture/pr109650-2.c: New test.

[Bug target/109650] avr-gcc incorrect code with -Os

2023-06-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109650

--- Comment #12 from CVS Commits  ---
The releases/gcc-12 branch has been updated by Georg-Johann Lay
:

https://gcc.gnu.org/g:ee92dc2dae45acc79d4dc08ea31adf894831840a

commit r12-9691-gee92dc2dae45acc79d4dc08ea31adf894831840a
Author: Georg-Johann Lay 
Date:   Sat Jun 10 21:47:53 2023 +0200

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
Backport from 2023-05-10 master r14-1688.
* 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, *add.for.eqne.): New insns.
(*cbranch4): Rename to cbranch4_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.
Rework signtest-and-branch peepholes for *sbrx_branch.
(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, *reversed_tst)
(*cmpqi_sign_extend): Remove insns.
(define_c_enum "unspec") [UNSPEC_IDENTITY]: Remove.
* config/avr/avr-dimode.md (cbranch4): Canonicalize
comparisons.
* config/avr/predicates.md (scratch_or_d_register_operand): New.
* config/avr/constraints.md (Yxx): New constraint.

gcc/testsuite/
PR target/109650
Backport from 2023-05-10 master r14-1688.
* gcc.target/avr/torture/pr109650-1.c: New test.
* gcc.target/avr/torture/pr109650-2.c: New test.

[Bug fortran/86277] Presence of optional arguments not recognized for zero length arrays

2023-06-10 Thread mikael at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86277

--- Comment #19 from Mikael Morin  ---
(In reply to anlauf from comment #15)
> 
> Your patch also seems to fix (at first glance) the character case as well
> as type, so this appears to be the right direction.

Yet, your patch identifies a bug in trans_array_constructor.
Not sure whether that bug can also be visible in a different case.

[Bug target/92729] [avr] Convert the backend to MODE_CC so it can be kept in future releases

2023-06-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92729

--- Comment #63 from CVS Commits  ---
The releases/gcc-13 branch has been updated by Georg-Johann Lay
:

https://gcc.gnu.org/g:6165b233ecc637efb5edcad8a34aae74b165a711

commit r13-7436-g6165b233ecc637efb5edcad8a34aae74b165a711
Author: Georg-Johann Lay 
Date:   Sat Jun 10 21:47:53 2023 +0200

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
Backport from 2023-05-10 master r14-1688.
* 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, *add.for.eqne.): New insns.
(*cbranch4): Rename to cbranch4_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.
Rework signtest-and-branch peepholes for *sbrx_branch.
(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, *reversed_tst)
(*cmpqi_sign_extend): Remove insns.
(define_c_enum "unspec") [UNSPEC_IDENTITY]: Remove.
* config/avr/avr-dimode.md (cbranch4): Canonicalize
comparisons.
* config/avr/predicates.md (scratch_or_d_register_operand): New.
* config/avr/constraints.md (Yxx): New constraint.

gcc/testsuite/
PR target/109650
Backport from 2023-05-10 master r14-1688.
* gcc.target/avr/torture/pr109650-1.c: New test.
* gcc.target/avr/torture/pr109650-2.c: New test.

[Bug target/109650] avr-gcc incorrect code with -Os

2023-06-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109650

--- Comment #11 from CVS Commits  ---
The releases/gcc-13 branch has been updated by Georg-Johann Lay
:

https://gcc.gnu.org/g:6165b233ecc637efb5edcad8a34aae74b165a711

commit r13-7436-g6165b233ecc637efb5edcad8a34aae74b165a711
Author: Georg-Johann Lay 
Date:   Sat Jun 10 21:47:53 2023 +0200

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
Backport from 2023-05-10 master r14-1688.
* 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, *add.for.eqne.): New insns.
(*cbranch4): Rename to cbranch4_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.
Rework signtest-and-branch peepholes for *sbrx_branch.
(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, *reversed_tst)
(*cmpqi_sign_extend): Remove insns.
(define_c_enum "unspec") [UNSPEC_IDENTITY]: Remove.
* config/avr/avr-dimode.md (cbranch4): Canonicalize
comparisons.
* config/avr/predicates.md (scratch_or_d_register_operand): New.
* config/avr/constraints.md (Yxx): New constraint.

gcc/testsuite/
PR target/109650
Backport from 2023-05-10 master r14-1688.
* gcc.target/avr/torture/pr109650-1.c: New test.
* gcc.target/avr/torture/pr109650-2.c: New test.

[Bug fortran/86277] Presence of optional arguments not recognized for zero length arrays

2023-06-10 Thread mikael at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86277

Mikael Morin  changed:

   What|Removed |Added

  Attachment #55296|0   |1
is obsolete||

--- Comment #18 from Mikael Morin  ---
Created attachment 55300
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55300=edit
Alternative patch v2

(In reply to Mikael Morin from comment #17)
> Looking further at the implementation of gfc_trans_allocate_array_storage,
> the size vs elem_size dance can be removed from my patch, as size is almost
> unused in the onstack case.

Updated patch attached.

[Bug fortran/86277] Presence of optional arguments not recognized for zero length arrays

2023-06-10 Thread mikael at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86277

--- Comment #17 from Mikael Morin  ---
Looking further at the implementation of gfc_trans_allocate_array_storage, the
size vs elem_size dance can be removed from my patch, as size is almost unused
in the onstack case.

[Bug target/92729] [avr] Convert the backend to MODE_CC so it can be kept in future releases

2023-06-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92729

--- Comment #62 from CVS Commits  ---
The master branch has been updated by Georg-Johann Lay :

https://gcc.gnu.org/g:30a8771c0f5ddcbc329408c3bbf4f100b01acca9

commit r14-1688-g30a8771c0f5ddcbc329408c3bbf4f100b01acca9
Author: Georg-Johann Lay 
Date:   Sat Jun 10 21:47:53 2023 +0200

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, *add.for.eqne.): New insns.
(*cbranch4): Rename to cbranch4_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.
Rework signtest-and-branch peepholes for *sbrx_branch.
(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, *reversed_tst)
(*cmpqi_sign_extend): Remove insns.
(define_c_enum "unspec") [UNSPEC_IDENTITY]: Remove.
* config/avr/avr-dimode.md (cbranch4): 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.

[Bug target/109650] avr-gcc incorrect code with -Os

2023-06-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109650

--- Comment #10 from CVS Commits  ---
The master branch has been updated by Georg-Johann Lay :

https://gcc.gnu.org/g:30a8771c0f5ddcbc329408c3bbf4f100b01acca9

commit r14-1688-g30a8771c0f5ddcbc329408c3bbf4f100b01acca9
Author: Georg-Johann Lay 
Date:   Sat Jun 10 21:47:53 2023 +0200

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, *add.for.eqne.): New insns.
(*cbranch4): Rename to cbranch4_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.
Rework signtest-and-branch peepholes for *sbrx_branch.
(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, *reversed_tst)
(*cmpqi_sign_extend): Remove insns.
(define_c_enum "unspec") [UNSPEC_IDENTITY]: Remove.
* config/avr/avr-dimode.md (cbranch4): 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.

[Bug fortran/86277] Presence of optional arguments not recognized for zero length arrays

2023-06-10 Thread mikael at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86277

--- Comment #16 from Mikael Morin  ---
(In reply to anlauf from comment #13)
> (In reply to Mikael Morin from comment #12)
> > (In reply to anlauf from comment #8) 
> > > Enabling derived types does not work when they occur in an array 
> > > constructor,
> > > and the code would ICE on empty constructors of derived type.
> > > 
> > 
> > Looking at the code, I couldn't foresee where the ICE would happen, so I
> > tried it myself.
> > I see no ICE here.
> 
> I got an ICE with pointer_check_14.f90 and realloc_on_assign_18.f90
> which have an empty DT with no component.
> 
They work here.  I must be doing something stupidly wrong.
My compiler is a bit outdated, but not that much:
GNU Fortran (GCC) 14.0.0 20230529 (experimental)

[Bug fortran/86277] Presence of optional arguments not recognized for zero length arrays

2023-06-10 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86277

--- Comment #15 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #14)
> Will look at your approach later.

For the draft testcase, your patch seems to handle the explicit temporaries,
but there is a runtime error (memory corruption?) for some of the cases
with array ctors.

Your patch also seems to fix (at first glance) the character case as well
as type, so this appears to be the right direction.

[Bug d/110193] d_signed_or_unsigned_type is invoked for vector types

2023-06-10 Thread ibuclaw at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110193

--- Comment #4 from ibuclaw at gcc dot gnu.org ---
A shortcut to signed_or_unsigned_type_for for vector types seems reasonable
nonetheless.

[Bug d/110193] d_signed_or_unsigned_type is invoked for vector types

2023-06-10 Thread ibuclaw at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110193

--- Comment #3 from ibuclaw at gcc dot gnu.org ---
(In reply to ibuclaw from comment #2)
> Gimple dump:
> ---
> __vector(int[4]) rshift (__vector(int[4]) v)
> {
>   __vector(int[4]) D.1795;
> 
>   _1 = VIEW_CONVERT_EXPR(v);
>   _2 = _1 >> 2;
>   D.1795 = VIEW_CONVERT_EXPR<__vector(int[4])>(_2);
>   return D.1795;
> }
I've just realized that I wasn't reading this code dump properly.  Everything
looks correct here.

I've a look again and picked at random vector E_V8HImode, that has a precision
of 3.  Whereas a cent has a precision of 128.

[Bug rtl-optimization/110202] _mm512_ternarylogic_epi64 generates unnecessary operations

2023-06-10 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110202

Jakub Jelinek  changed:

   What|Removed |Added

 CC||hjl.tools at gmail dot com,
   ||jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek  ---
Well, there is nothing magic on exactly 0x55 immediate, there are 256 possible
immediates, most of them use all of A, B, C, some of them use just A, B, others
just B, C, others just A, C, others just A, others just B, others just C,
others none of them.
And I must say I don't immediately see easy rules how to find out from the
immediate value which set is which, so unless we find some easy rule for that,
we'd need to hardcode the mapping between the 256 values to a bitmask which
inputs are actually used.
And then the question is how to represent that in RTL to make it clear that
some operands are mentioned but their value isn't really used.

[Bug d/110193] d_signed_or_unsigned_type is invoked for vector types

2023-06-10 Thread ibuclaw at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110193

ibuclaw at gcc dot gnu.org changed:

   What|Removed |Added

 CC||ibuclaw at gcc dot gnu.org

--- Comment #2 from ibuclaw at gcc dot gnu.org ---
Just having a cursory look, the only references to d_signed_or_unsigned_type is
via d_unsigned_type and d_signed_type.

The former is only called by d_gimplify_unsigned_rshift_expr.

So I guess you must mean you've noticed this with something like.

__vector(int[4]) unsigned_rshift(__vector(int[4]) v)
{
return v >>> 2;
}

It turns out that this accident doesn't affect the intent on x86.

https://d.godbolt.org/z/99fK7fWaW

Gimple dump:
---
__vector(int[4]) rshift (__vector(int[4]) v)
{
  __vector(int[4]) D.1795;

  _1 = VIEW_CONVERT_EXPR(v);
  _2 = _1 >> 2;
  D.1795 = VIEW_CONVERT_EXPR<__vector(int[4])>(_2);
  return D.1795;
}

[Bug d/110113] gdc -fpreview=dip1021 crash in d/dmd/root/aav.d:127 dmd_aaGetRvalue from DsymbolTable::lookup(Identifier const*)

2023-06-10 Thread ibuclaw at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110113

ibuclaw at gcc dot gnu.org changed:

   What|Removed |Added

 Status|WAITING |ASSIGNED

--- Comment #9 from ibuclaw at gcc dot gnu.org ---
(In reply to ibuclaw from comment #8)
> Regression caused by upstream.
> 
> https://github.com/dlang/dmd/pull/14837
Tracked it down to a memory corruption bug in the D front-end.

There is a call to Mem.xrealloc(ptr) inside the escape analysis code, which
allocates a new GC pointer, marking the old pointer as "free" to reuse by the
next GC.malloc request.

However, said pointer is to a data structure with Array(T) fields, each to
which contain a pointer that references itself (a smallarray optimization).

The corruption arises as eventually there are two references to the same
address one that is reading/writing to it as an `VarDeclaration**`, the other
as an `aaA**`.  Segfault occurs as a result of aaGetRvalue interpreting a
`VarDeclaration*` as an `aaA*`.

Fix is in review, and will backport to both GCC-13 and GCC-12.

[Bug tree-optimization/110203] Sum should optimize to closed form

2023-06-10 Thread llvm at rifkin dot dev via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110203

--- Comment #4 from Jeremy R.  ---
Thanks for tracking down the duplicates

[Bug rtl-optimization/110202] _mm512_ternarylogic_epi64 generates unnecessary operations

2023-06-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110202

Andrew Pinski  changed:

   What|Removed |Added

  Component|target  |rtl-optimization
   Severity|normal  |enhancement

--- Comment #2 from Andrew Pinski  ---
Note you get a warning in your negate1 case


: In function '__m512i negate1(const __m512i*)':
:7:36: warning: 'res' is used uninitialized [-Wuninitialized]
7 | res = _mm512_ternarylogic_epi64(res, res, *a, 0x55);
  |   ~^~~~
:6:13: note: 'res' was declared here
6 | __m512i res;
  | ^~~


But even doing this:
__m512i negate1(const __m512i *a)
{
__m512i res = _mm512_undefined_si512 ();
res = _mm512_ternarylogic_epi64(res, res, *a, 0x55);
return res;
}


Will cause an extra zeroing.

[Bug target/110202] _mm512_ternarylogic_epi64 generates unnecessary operations

2023-06-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110202

--- Comment #1 from Andrew Pinski  ---
Created attachment 55299
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55299=edit
Corrected testcase

[Bug tree-optimization/98960] Failure to optimize accumulate loop to mul

2023-06-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98960

Andrew Pinski  changed:

   What|Removed |Added

 Resolution|--- |DUPLICATE
 Status|NEW |RESOLVED

--- Comment #3 from Andrew Pinski  ---
Dup of bug 65855.

*** This bug has been marked as a duplicate of bug 65855 ***

[Bug middle-end/65855] SCEV / SCCP missing optimization: triangular numbers

2023-06-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65855

Andrew Pinski  changed:

   What|Removed |Added

 CC||gabravier at gmail dot com

--- Comment #12 from Andrew Pinski  ---
*** Bug 98960 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/98960] Failure to optimize accumulate loop to mul

2023-06-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98960

Andrew Pinski  changed:

   What|Removed |Added

 CC||llvm at rifkin dot dev

--- Comment #2 from Andrew Pinski  ---
*** Bug 110203 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/110203] Sum should optimize to closed form

2023-06-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110203

Andrew Pinski  changed:

   What|Removed |Added

 Resolution|--- |DUPLICATE
 Status|UNCONFIRMED |RESOLVED

--- Comment #3 from Andrew Pinski  ---
Dup of bug 98960.

*** This bug has been marked as a duplicate of bug 98960 ***

[Bug tree-optimization/110204] [14 Regression] Suspicous warning when compiling ranges-v3 using GCC trunk (iteration 9223372036854775807 invokes undefined behavior)

2023-06-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110204

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |14.0
Summary|Suspicous warning when  |[14 Regression] Suspicous
   |compiling ranges-v3 using   |warning when compiling
   |GCC trunk (iteration|ranges-v3 using GCC trunk
   |9223372036854775807 invokes |(iteration
   |undefined behavior) |9223372036854775807 invokes
   ||undefined behavior)
   Keywords||needs-bisection

[Bug tree-optimization/110204] Suspicous warning when compiling ranges-v3 using GCC trunk (iteration 9223372036854775807 invokes undefined behavior)

2023-06-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110204

--- Comment #1 from Andrew Pinski  ---
Created attachment 55298
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55298=edit
Testcase preprocessed source

Please next time attach the preprocessed source as requested at
https://gcc.gnu.org/bugs/ .

[Bug c++/110204] New: Suspicous warning when compiling ranges-v3 using GCC trunk (iteration 9223372036854775807 invokes undefined behavior)

2023-06-10 Thread jun at junz dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110204

Bug ID: 110204
   Summary: Suspicous warning when compiling ranges-v3 using GCC
trunk (iteration 9223372036854775807 invokes undefined
behavior)
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: jun at junz dot org
  Target Milestone: ---

Given code:

#include 
#include 
#include 

std::map m;

std::vector foo() {
  return ranges::to(m | ranges::views::keys);
}

GCC trunk reports:

/opt/compiler-explorer/gcc-trunk-20230610/include/c++/14.0.0/bits/stl_iterator_base_funcs.h:175:9:
warning: iteration 9223372036854775807 invokes undefined behavior
[-Waggressive-loop-optimizations]
  175 | while (__n--)
  | ^
/opt/compiler-explorer/gcc-trunk-20230610/include/c++/14.0.0/bits/stl_iterator_base_funcs.h:175:9:
note: within this loop

while Clang and GCC 13 both say OK. I think this is a regression.
goldbolt link: https://godbolt.org/z/W33aMqr5c

[Bug fortran/86277] Presence of optional arguments not recognized for zero length arrays

2023-06-10 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86277

--- Comment #14 from anlauf at gcc dot gnu.org ---
Created attachment 55297
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55297=edit
Draft testcase

This testcase tries to probe many different paths for real array ctors.
I have similar testcases for character and DT which need more work.

Will look at your approach later.

[Bug fortran/86277] Presence of optional arguments not recognized for zero length arrays

2023-06-10 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86277

--- Comment #13 from anlauf at gcc dot gnu.org ---
(In reply to Mikael Morin from comment #12)
> (In reply to anlauf from comment #8) 
> > Enabling derived types does not work when they occur in an array 
> > constructor,
> > and the code would ICE on empty constructors of derived type.
> > 
> 
> Looking at the code, I couldn't foresee where the ICE would happen, so I
> tried it myself.
> I see no ICE here.

I got an ICE with pointer_check_14.f90 and realloc_on_assign_18.f90
which have an empty DT with no component.

I guess it's all about zeros...

[Bug tree-optimization/110203] Sum should optimize to closed form

2023-06-10 Thread llvm at rifkin dot dev via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110203

--- Comment #2 from Jeremy R.  ---
I wasn't able to get this to work with unsigned either
https://godbolt.org/z/bGcW7ebjd but maybe there's some other way to trigger
this optimization

[Bug libstdc++/110196] stacktrace_entry does not print which library the function was from

2023-06-10 Thread fabian_kessler at gmx dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110196

--- Comment #11 from fabian_kessler at gmx dot de  ---
With the following code extension, I get what I want, but this may also be
platform dependent:

class stacktrace_entry{
// ...  
  std::string _symbol(uintptr_t const pc) const {
Dl_info info;
int status;
link_map *map;
status = dladdr1((void const *)(pc), , reinterpret_cast(),
 RTLD_DL_LINKMAP);
return std::string(info.dli_fname ?: "");
  }
// ...
}

// ...

inline std::ostream <<(std::ostream &__os,
const stacktrace_entry &__f) {
  std::string __desc, __file;
  int __line;
  if (__f._M_get_info(&__desc, &__file, &__line)) {
__os.width(4);
__os << __f._symbol(__f._M_pc) << "(" << __desc << ") at " << __file << ':'
 << __line;
  }
  return __os;
}

Outputs:

   0# /mnt/c/Users/Febbe/workspace/test/build/test_stacktrace_20(main) at
/mnt/c/Users/Febbe/workspace/test/test/main.cpp:7
   1# /lib/x86_64-linux-gnu/libc.so.6(__libc_start_call_main) at
../sysdeps/nptl/libc_start_call_main.h:58
   2# /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main_impl) at
../csu/libc-start.c:360
   3# /mnt/c/Users/Febbe/workspace/test/build/test_stacktrace_20(_start) at :0

[Bug tree-optimization/110203] Sum should optimize to closed form

2023-06-10 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110203

Andrew Pinski  changed:

   What|Removed |Added

   Severity|normal  |enhancement
   Keywords||missed-optimization

--- Comment #1 from Andrew Pinski  ---
This is most likely just not taking into account that signed integer overflow
is undefined.

[Bug c++/110102] [13 regression] initializer_list ctors of containers skip Allocator_traits::construct, copies move-only type

2023-06-10 Thread arthur.j.odwyer at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110102

--- Comment #9 from Arthur O'Dwyer  ---
(In reply to Jason Merrill from comment #8)
> (In reply to Arthur O'Dwyer from comment #6)
> > I still think it would be nice if GCC stopped supporting
> > int f(std::vector v) { return v[0]; }
> > , at least silently by default.
> 
> Fixed (to require -fconcepts-ts) on trunk.

Nice! Thank you!

[Bug tree-optimization/110203] New: Sum should optimize to closed form

2023-06-10 Thread llvm at rifkin dot dev via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110203

Bug ID: 110203
   Summary: Sum should optimize to closed form
   Product: gcc
   Version: 13.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: llvm at rifkin dot dev
  Target Milestone: ---

For both of

int foo(int num) {
if(num == 1) return 1;
return num + foo(num - 1);
}

int bar(int num) {
int sum = 0;
for(int i = 1; i <= num; i++) {
sum += i;
}
return sum;
}


GCC emits loops:

foo(int):
xor eax, eax
cmp edi, 1
je  .L8
.L2:
mov edx, edi
sub edi, 1
add eax, edx
cmp edi, 1
jne .L2
add eax, 1
ret
.L8:
mov eax, 1
ret
bar(int):
testedi, edi
jle .L12
add edi, 1
mov eax, 1
xor edx, edx
.L11:
add edx, eax
add eax, 1
cmp eax, edi
jne .L11
mov eax, edx
ret
.L12:
xor edx, edx
mov eax, edx
ret


GCC should optimize this to the closed form.

There is precedent for this transformation, llvm does it
https://godbolt.org/z/Kfffe5aPz.

[Bug analyzer/110014] -Wanalyzer-allocation-size mishandles realloc (..., .... * sizeof (object))

2023-06-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110014

--- Comment #1 from CVS Commits  ---
The master branch has been updated by Tim Lange :

https://gcc.gnu.org/g:39adc5eebd61fd276f3f1ef9d7228756a35bd0cb

commit r14-1685-g39adc5eebd61fd276f3f1ef9d7228756a35bd0cb
Author: Tim Lange 
Date:   Fri Jun 9 20:08:22 2023 +0200

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  

PR analyzer/110014

gcc/testsuite/ChangeLog:

* gcc.dg/analyzer/realloc-pr110014.c: New tests.

[Bug analyzer/109577] -Wanalyzer-allocation-size mishandles __builtin_mul_overflow

2023-06-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109577

--- Comment #3 from CVS Commits  ---
The master branch has been updated by Tim Lange :

https://gcc.gnu.org/g:39adc5eebd61fd276f3f1ef9d7228756a35bd0cb

commit r14-1685-g39adc5eebd61fd276f3f1ef9d7228756a35bd0cb
Author: Tim Lange 
Date:   Fri Jun 9 20:08:22 2023 +0200

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  

PR analyzer/110014

gcc/testsuite/ChangeLog:

* gcc.dg/analyzer/realloc-pr110014.c: New tests.

[Bug analyzer/109577] -Wanalyzer-allocation-size mishandles __builtin_mul_overflow

2023-06-10 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109577

--- Comment #2 from CVS Commits  ---
The master branch has been updated by Tim Lange :

https://gcc.gnu.org/g:1d57a2232575913ad1085bac0ba5e22b58185179

commit r14-1684-g1d57a2232575913ad1085bac0ba5e22b58185179
Author: Tim Lange 
Date:   Fri Jun 9 20:07:33 2023 +0200

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  

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.

[Bug fortran/86277] Presence of optional arguments not recognized for zero length arrays

2023-06-10 Thread mikael at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86277

--- Comment #12 from Mikael Morin  ---
(In reply to anlauf from comment #8) 
> Enabling derived types does not work when they occur in an array constructor,
> and the code would ICE on empty constructors of derived type.
> 

Looking at the code, I couldn't foresee where the ICE would happen, so I tried
it myself.
I see no ICE here.

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 04b5e30b96a..4fd3fb65a54 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -2941,10 +2941,6 @@ trans_array_constructor (gfc_ss * ss, locus * where)
 from constructor only for meaningful shape.  */
   bool zero_sized = zero_sized_array_p (expr);

-  /* FIXME: constant array constructors for DT have some issues...  */
-  if (expr->ts.type == BT_DERIVED || expr->ts.type == BT_CLASS)
-   zero_sized = false;
-
   if (!zero_sized)
nelem = gfc_constant_array_constructor_p (c);


program test
  implicit none
  type :: t
integer :: c
  end type t
  integer :: m(0)
  integer, allocatable :: n(:)
  call i
  call i(m)
  call i(n)
  allocate (n(0))
  call i(n)
  call i([integer::])   ! expect "optional argument present: T"
  call i([1])
  call j([t::])
contains
  subroutine i(str)
integer, dimension(:), optional, intent(in) :: str
write(6,*) 'optional argument present:', present(str)
  end subroutine i
  subroutine j(str)
type(t), dimension(:), optional, intent(in) :: str
write(6,*) 'optional argument present:', present(str)
  end subroutine j
end program

[Bug fortran/86277] Presence of optional arguments not recognized for zero length arrays

2023-06-10 Thread mikael at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86277

--- Comment #11 from Mikael Morin  ---
(In reply to Mikael Morin from comment #9)
> (In reply to anlauf from comment #8)
> > 
> > I haven't understood yet how (and why) temporaries are generated for
> > procedure arguments even when it is known at compile-time that these have
> > size zero.  I'd appreciate input from others.
> 
> See trans_array_constructor.

Actually, your patch is already touching that function.
I'm afraid this is an area nobody (well, nobody but you) dares touching.

[Bug c++/110202] New: _mm512_ternarylogic_epi64 generates unnecessary operations

2023-06-10 Thread fabio at cannizzo dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110202

Bug ID: 110202
   Summary: _mm512_ternarylogic_epi64 generates unnecessary
operations
   Product: gcc
   Version: 13.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: fabio at cannizzo dot net
  Target Milestone: ---

Consider the following two alternative implementations of a bitwise complement
of an avx512 register.

#include 

__m512i negate1(const __m512i *a)
{
__m512i res;
res = c(res, res, *a, 0x55);
return res;
}

__m512i negate2(const __m512i *a)
{
__m512i res;
res = _mm512_xor_si512(*a, _mm512_set1_epi32(-1));
return res;
}

which compiled with "-O3 -mavx512f" generates the asm listings (see godbolt:
https://godbolt.org/z/jvrxEjW65)

negate1(long long __vector(8) const*):
vpxor   xmm0, xmm0, xmm0
vpternlogq  zmm0, zmm0, ZMMWORD PTR [rdi], 85
ret
negate2(long long __vector(8) const*):
vpternlogd  zmm0, zmm0, ZMMWORD PTR [rdi], 0x55
ret

negate1 introduces an unnecessary xor operation. Probably this is because it
does not recognize that, when vpternlogd is used with code 0x55, it only uses
the third zmm argument.

[Bug fortran/86277] Presence of optional arguments not recognized for zero length arrays

2023-06-10 Thread mikael at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86277

--- Comment #10 from Mikael Morin  ---
Created attachment 55296
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55296=edit
Another way to fix this problem

[Bug fortran/86277] Presence of optional arguments not recognized for zero length arrays

2023-06-10 Thread mikael at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86277

Mikael Morin  changed:

   What|Removed |Added

 CC||mikael at gcc dot gnu.org

--- Comment #9 from Mikael Morin  ---
(In reply to anlauf from comment #8)
> 
> I haven't understood yet how (and why) temporaries are generated for
> procedure arguments even when it is known at compile-time that these have
> size zero.  I'd appreciate input from others.

I think temporaries in this case come from the scalarizer, which is known to
generate superfluous temporaries with array constructors.  See
trans_array_constructor.

[Bug libstdc++/110196] stacktrace_entry does not print which library the function was from

2023-06-10 Thread fabian_kessler at gmx dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110196

--- Comment #10 from fabian_kessler at gmx dot de  ---
> It is only called once, isn't it?

Actually, _S_init is even called in a loop. And the singleton pattern is also a
code extension from me. Therefore, backtrace_create_state is also called in a
loop.

> 
> This isn't portable, not all systems have /proc/self/exe, or readlink.
> 
> I think it would be better to move this function into the library, and use
> std::filesystem::read_symlink.

Yes, that code snipped was just to test my assumption, which was only partially
correct. Adding the path improved the stacktrace, but did not add the
originating library.
I don't feel experienced, to contribute STL code for more than x86_64.

[Bug libstdc++/99832] std::chrono::system_clock::to_time_t needs ABI tag for 32-bit time_t

2023-06-10 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99832

Jonathan Wakely  changed:

   What|Removed |Added

   Last reconfirmed||2023-06-10
 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW

[Bug c++/110195] defaulted constructor does not respect the private accessor

2023-06-10 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110195

--- Comment #8 from Jonathan Wakely  ---
In the context of the C++ standard a "defect report" has a very specific
meaning, and it doesn't apply here.

The proposal
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1008r1.pdf changed
this property, and doesn't describe the old semantics as defective, just
unfortunate.