From patchwork Thu May 4 18:29:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 90174 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp526813vqo; Thu, 4 May 2023 11:30:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6HmygD2uDQ/2/DrGK7lb7eEgfcvGz2Gje8xsGEUlh4BIwFw3vvGwEBuGCN+mYsLo012T7M X-Received: by 2002:a17:906:ef0e:b0:957:7551:38c0 with SMTP id f14-20020a170906ef0e00b00957755138c0mr7557698ejs.7.1683225014653; Thu, 04 May 2023 11:30:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683225014; cv=none; d=google.com; s=arc-20160816; b=zJo9Jh5Pl/P0HdzzJP7eMrEzp4OFoveCS4IGOWu7AB0PAjx7sJ5C+39yHs/6nKEJNw XvlLasItoCrce6tfykduZS3besLTvjACiafwNNQ+Q4+9Vr0RfcXmbYDUL09OUEKrNZnb HWiKHSh+6LN+hd+4FDmHgsdOn2gfFmFOnflgyalZXnjMJnPb90d9gCUadOAJMVIgGdPY Kiw2MYz+yFqbP8IFxZDLAgZJUSQBgkynX7sp0G2DrlCPCp9q3kLRXvJaTspzy4/o3Flp F/Fq0MynweEIw5AQ0Qynd0cVqU6bUOydpvq6qO+xB1FyG+7ekgVkn/AlRFODFToY2/57 k5Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:to:subject :message-id:date:mime-version:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=KX92pJoZYqvE1NnhQLlwItEN8eMjBWJBG/PaQftzwhA=; b=YLwc4Y4RmWY76VEvP0ffz/TR4DLmHz3fjCRpyWzm0ej3NL6a+TaLxuY2tI6ILrL5aP GTiT9cvzVS2iHUBMkhSTIGguEkyh4thYP9T1jnOmVCt9ZBmvArKWMVtZc3jw9Jz+Rf9o v+VFqhl/FqNDBiyVOV3RJK6fWEcSY8ooAvhI9Zr2daGz/BLSCzna4Heygv+VIHWgINTk 3KUmSBR+vfTfdthKlBn5hvq7tsv1HEGO/YqX3fSU/y+WYtDNPZtY9y5SVh4Zs5iLSer0 UCAZ2EWEzsvm7Bsuh4t+ljK4pO1PibT15ztreUuw0kWnsS2X2s7dZM9FiLIdj7kbdVBs P1gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="JspA91/T"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id eu22-20020a170907299600b00965ba75fef7si779812ejc.736.2023.05.04.11.30.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 11:30:14 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="JspA91/T"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4A8B2385702E for ; Thu, 4 May 2023 18:30:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A8B2385702E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683225013; bh=KX92pJoZYqvE1NnhQLlwItEN8eMjBWJBG/PaQftzwhA=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=JspA91/Tyzon4AsTh6sOhFT07slBoL4jrrEEqffSI7TzItFrAJpv9YfvfZ6YVGcFi kVyLkyy3Dyf9Rc92EWuP9WWjEJ1M74srNoVqVykUVAbEnMVkbuNtHBXmcx9l8X19L2 uAeVnwOJXjjSml+fj87n4SRrZyFvPy2nUf+F7gh4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by sourceware.org (Postfix) with ESMTPS id 7E1C93858D33 for ; Thu, 4 May 2023 18:29:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7E1C93858D33 Received: by mail-qk1-x731.google.com with SMTP id af79cd13be357-74df951e897so38473185a.2 for ; Thu, 04 May 2023 11:29:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683224968; x=1685816968; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=KX92pJoZYqvE1NnhQLlwItEN8eMjBWJBG/PaQftzwhA=; b=lRssyMlNFv/nLFUGmCptrHklrJVdysxDVUkpf5Ddwitw/lXsoeZzrUAafgj4WSIy9F fRNIPZvtR36q7VGFImMwYbGqY95SufT1RDJM5gAH9ryeHQkctlu4Wjd/JmWc/b1UjK7E wAxD6ug/a1KQ7KAtwOpBkq6EizXcQFsiJO+JzraRNn5fsRavJAPrDzV04vSzqtQaPzLF hHUqevYfUn3t6yRFRxbmez9Wq6gRZOKEmhQ/H2w82RnzwRS5NCITjDxnpMr/wxnx6xxr H9JmiAOx8EPIFHH9bzBo9M9H9PXTsNWbn3wxbhJz3CCq1jd0iwYGx5dfc5iBTmr3Y5iQ BD2g== X-Gm-Message-State: AC+VfDzyaTiTIOI3rnA5Upyz7I68HbWdrjbzoq/sUHUal+U2dAD2/X8G SLX4uWab8bdgHj68S+FQHk2bTOMoDdmQnuzm3bWVNMrnmNk53Q== X-Received: by 2002:a05:6214:b67:b0:5f4:357c:3bf5 with SMTP id ey7-20020a0562140b6700b005f4357c3bf5mr19961962qvb.13.1683224968368; Thu, 04 May 2023 11:29:28 -0700 (PDT) MIME-Version: 1.0 Date: Thu, 4 May 2023 20:29:17 +0200 Message-ID: Subject: [PATCH] i386: Tighten ashift to lea splitter operand predicates [PR109733] To: "gcc-patches@gcc.gnu.org" X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Uros Bizjak via Gcc-patches From: Uros Bizjak Reply-To: Uros Bizjak Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764989353072259753?= X-GMAIL-MSGID: =?utf-8?q?1764989353072259753?= The predicates of ashift to lea post-reload splitter were too broad so the splitter tried to convert the mask shift instruction. Tighten operand predicates to match only general registers. gcc/ChangeLog: PR target/109733 * config/i386/predicates.md (index_reg_operand): New predicate. * config/i386/i386.md (ashift to lea splitter): Use general_reg_operand and index_reg_operand predicates. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Pushed to master. Uros. diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index d49f1cdc3fe..63207fc9305 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -13331,8 +13331,8 @@ (define_insn_and_split "*ashl3_1_slp" ;; Convert ashift to the lea pattern to avoid flags dependency. (define_split - [(set (match_operand:SWI 0 "register_operand") - (ashift:SWI (match_operand:SWI 1 "index_register_operand") + [(set (match_operand:SWI 0 "general_reg_operand") + (ashift:SWI (match_operand:SWI 1 "index_reg_operand") (match_operand 2 "const_0_to_3_operand"))) (clobber (reg:CC FLAGS_REG))] "reload_completed @@ -13350,9 +13350,9 @@ (define_split ;; Convert ashift to the lea pattern to avoid flags dependency. (define_split - [(set (match_operand:DI 0 "register_operand") + [(set (match_operand:DI 0 "general_reg_operand") (zero_extend:DI - (ashift:SI (match_operand:SI 1 "index_register_operand") + (ashift:SI (match_operand:SI 1 "index_reg_operand") (match_operand 2 "const_0_to_3_operand")))) (clobber (reg:CC FLAGS_REG))] "TARGET_64BIT && reload_completed diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index 878b144b0fb..362266e1f6c 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -32,6 +32,11 @@ (define_predicate "general_reg_operand" (and (match_code "reg") (match_test "GENERAL_REGNO_P (REGNO (op))"))) +;; True if the operand is an INDEX class register. +(define_predicate "index_reg_operand" + (and (match_code "reg") + (match_test "INDEX_REGNO_P (REGNO (op))"))) + ;; True if the operand is a nonimmediate operand with GENERAL class register. (define_predicate "nonimmediate_gr_operand" (if_then_else (match_code "reg")