From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8EBBF3858D35; Tue, 10 Oct 2023 22:08:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8EBBF3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696975713; bh=s9JhYHusJexrXtA7PpEUsllKc2o+Ly7HcvmZXyy8alQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hcfy/hdA9/i6E6/sNrcxJ/vW5duRXDKi8YQ+VDvvuplHrSz1Wp3NKXzZ21B070+tp CUYtkfhFGP9llvWOzXLWULOfjDya0O4FiTZH2kh0vpampLUn4jWXVrifFz1s8FsLk7 BwJJu5kBUtePWL04tx3qJ4a/TFLO2kfuueHCSlUM= From: "juzhe.zhong at rivai dot ai" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111760] risc-v regression: COND_LEN_* incorrect fold/simplify in middle-end Date: Tue, 10 Oct 2023 22:08:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: juzhe.zhong at rivai dot ai X-Bugzilla-Status: UNCONFIRMED 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=3D111760 --- Comment #5 from JuzheZhong --- (In reply to Robin Dapp from comment #2) > https://gcc.gnu.org/pipermail/gcc-patches/2023-September/629904.html >=20 > prevents the wrong code but still leaves us with a redundant negation (and > it is not the only missed optimization of that kind): >=20 > vect_neg_xi_14.4_23 =3D -vect_xi_13.3_22; > vect_res_2.5_24 =3D .COND_LEN_ADD ({ -1, ... }, vect_res_1.0_17, > vect_neg_xi_14.4_23, vect_res_1.0_17, _29, 0); >=20 > That's because my "hackaround" doesn't recognize a valueized sequence > _30 =3D vect_res_1.0_17 - vect_xi_13.3_22; >=20 > Of course I could (reverse valueize) recognize that again and convert it = to > a COND_LEN... but that doesn't seem elegant at all. There must be a simp= ler > way that I'm missing entirely right now. That said, converting the last > statement of such a sequence should be sufficient? Yeah. That's what I want to point it out. Your patch will disable the optimization I made in GIMPLE_FOLD for COND_LEN_xxx. I am not sure how to fix it, I think we need Richi's help for that since he knows the GIMPLE FOLD stuff the best.=