From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B85CC3857006; Sat, 10 Jun 2023 20:46:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B85CC3857006 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686429982; bh=UDE1dEudVEH2ClFF9UfkLRZTNpnzAKUfxqE5jRzOVLU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Afig4eO2/DMdHk1Ad6Q0M7lDmfZvEl7O6My2WonFUUgLyrL3oBzSDkedMtVscV2lP n0msAtWBIYYPViKi9Ip+Y9rz74XKcvCavfX/MYsn5QhwPgHMKmc4tLIATvF/uXUuJP 73n3fNVYuS+pU5LynAcfWcEVXOLi1YqnsfSVczYA= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/109650] avr-gcc incorrect code with -Os Date: Sat, 10 Jun 2023 20:46:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: patch, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109650 --- 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 blo= cks. This patch removes the machine-dependent reorg pass in avr_reorg entire= ly. It is replaced by a new, AVR specific mini-pass that runs prior to spli= t2. Canonicalization of comparisons away from the "difficult" codes GT[U] a= nd LE[U] is now mostly performed by implementing TARGET_CANONICALIZE_COMPARISON. Moreover: * Text peephole conditions get "dead_or_set_regno_p (*, REG_CC)" as nee= ded. * RTL peephole conditions get "peep2_regno_dead_p (*, REG_CC)" as neede= d. * 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 functio= ns. (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 ins= ns. (*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 need= ed. (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.=