From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 223513857C7B; Fri, 14 Jan 2022 09:16:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 223513857C7B From: "guihaoc at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/95737] PPC: Unnecessary extsw after negative less than Date: Fri, 14 Jan 2022 09:16:14 +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: 8.3.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: guihaoc at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: segher 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jan 2022 09:16:14 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95737 --- Comment #9 from HaoChen Gui --- Add a pattern to convert the plus mode to DI.=20 +(define_insn_and_split "*my_split" + [(set (match_operand:DI 0 "gpc_reg_operand") + (sign_extend:DI (plus:SI (match_operand:SI 1 "ca_operand") + (const_int -1))))] + "" + "#" + "" + [(parallel [(set (match_dup 0) + (plus:DI (match_dup 2) + (const_int -1))) + (clobber (match_dup 2))])] +{ + operands[2] =3D copy_rtx (operands[1]); + PUT_MODE (operands[2], DImode); +}) With the patch, the "extsw" could be optimized out. I compared the performa= nce between P8 code (with the patch) and P9 code. The performance of P9 is bett= er.=20 ISA says that computation with CA causes additional latency. It should be t= rue. The only concern is P9 code uses more register.=