From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1251) id 1BDD33858C2F; Sat, 24 Jun 2023 22:12:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BDD33858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687644777; bh=Eu/CZq7wd7CTkdu0cU9ungFu/y1EuD9lflVXADzlksc=; h=From:To:Subject:Date:From; b=NC6FdKhf1B+D8m4XI3OUD4xHt3Gkr6haty2CxTCR8CvEhnMQnoZ/inGUquISeUojF tOIMyBjNtG8bOWobreWzF9tqbeKaPkQL5A4mjEnsr7Jd/V8/neUQpuilBc0VxqzvPF VHI5pTA1EMq2oQeRs+sr2htnZpK9N0uAoDb9ATaQ= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Roger Sayle To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-2065] i386: Add alternate representation for {and, or, xor}b %ah, %dh. X-Act-Checkin: gcc X-Git-Author: Roger Sayle X-Git-Refname: refs/heads/master X-Git-Oldrev: 3f97d10aa1ff5984d6fd657f246d3f251b254ff1 X-Git-Newrev: 8f6c747c8638d4c3c47ba2d4c8be86909e183132 Message-Id: <20230624221257.1BDD33858C2F@sourceware.org> Date: Sat, 24 Jun 2023 22:12:57 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8f6c747c8638d4c3c47ba2d4c8be86909e183132 commit r14-2065-g8f6c747c8638d4c3c47ba2d4c8be86909e183132 Author: Roger Sayle Date: Sat Jun 24 23:05:25 2023 +0100 i386: Add alternate representation for {and,or,xor}b %ah,%dh. A patch that I'm working on to improve RTL simplifications in the middle-end results in the regression of pr78904-1b.c, due to changes in the canonical representation of high-byte (%ah, %bh, %ch, %dh) logic. See also PR target/78904. This patch avoids/prevents those failures by adding support for the alternate representation, duplicating the existing *qi_ext_2 as *qi_ext_3 (the new version also replacing any_or with any_logic to provide *andqi_ext_3 in the same pattern). Removing the original pattern isn't trivial, as it's generated by define_split, but this can be investigated after the other pieces are approved. The current representation of this instruction is: (set (zero_extract:DI (reg/v:DI 87 [ aD.2763 ]) (const_int 8 [0x8]) (const_int 8 [0x8])) (subreg:DI (xor:QI (subreg:QI (zero_extract:DI (reg:DI 94) (const_int 8 [0x8]) (const_int 8 [0x8])) 0) (subreg:QI (zero_extract:DI (reg/v:DI 87 [ aD.2763 ]) (const_int 8 [0x8]) (const_int 8 [0x8])) 0)) 0)) after my proposed middle-end improvement, we attempt to recognize: (set (zero_extract:DI (reg/v:DI 87 [ aD.2763 ]) (const_int 8 [0x8]) (const_int 8 [0x8])) (zero_extract:DI (xor:DI (reg:DI 94) (reg/v:DI 87 [ aD.2763 ])) (const_int 8 [0x8]) (const_int 8 [0x8]))) 2023-06-24 Roger Sayle gcc/ChangeLog * config/i386/i386.md (*qi_ext_3): New define_insn. Diff: --- gcc/config/i386/i386.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 95a6653cd13..b50d82bf768 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -11380,6 +11380,8 @@ [(set_attr "type" "alu") (set_attr "mode" "QI")]) +;; *andqi_ext_3 is defined via *qi_ext_3 below. + ;; Convert wide AND instructions with immediate operand to shorter QImode ;; equivalents when possible. ;; Don't do the splitting with memory operands, since it introduces risk @@ -12092,6 +12094,26 @@ [(set_attr "type" "alu") (set_attr "mode" "QI")]) +(define_insn "*qi_ext_3" + [(set (zero_extract:SWI248 + (match_operand 0 "int248_register_operand" "+Q") + (const_int 8) + (const_int 8)) + (zero_extract:SWI248 + (any_logic:SWI248 + (match_operand 1 "int248_register_operand" "%0") + (match_operand 2 "int248_register_operand" "Q")) + (const_int 8) + (const_int 8))) + (clobber (reg:CC FLAGS_REG))] + "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)) + /* FIXME: without this LRA can't reload this pattern, see PR82524. */ + && (rtx_equal_p (operands[0], operands[1]) + || rtx_equal_p (operands[0], operands[2]))" + "{b}\t{%h2, %h0|%h0, %h2}" + [(set_attr "type" "alu") + (set_attr "mode" "QI")]) + ;; Convert wide OR instructions with immediate operand to shorter QImode ;; equivalents when possible. ;; Don't do the splitting with memory operands, since it introduces risk