From patchwork Thu Sep 7 14:06:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 137645 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp2981250vqo; Thu, 7 Sep 2023 07:07:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExO9RIQJthtTfjpQQfyX/PB6DucxcstaS/A9jHu25XYLLKZ0vb70klFeQFwraqrebZsZ0N X-Received: by 2002:a05:6402:384:b0:525:442b:6068 with SMTP id o4-20020a056402038400b00525442b6068mr4617166edv.13.1694095672891; Thu, 07 Sep 2023 07:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694095672; cv=none; d=google.com; s=arc-20160816; b=VhXQV5fGAi6fehNDcV3l56pf7rjFe/sAufzMrHtj8SRRpm7vEpfumGSO9zY2TMyZfT NZRUjGrBtfe3XUOMMUylkuO9dO6IrTWYGd7wjTWJCOIqaYcJbpy9yvvzoTrL8YX8v1N/ 79iRzLUjXrjHpxBzts90RpywrjhoEIJm4ltmtdhPrHxY4F0S6p1y2CxVlaK9I1E2Nr4V XL8lJYO62EqJt/sWsmHhfddI7UZIsbo7qYrHQtwCJtdSnZ/YFWa53eozK0jbsTDxboi5 0Zpn4j+MpiC3twDNg7DztxDGeBJIYM3yaxMkWVz7v3x+pzdIyGMXwD3netDeOvtQblqg mHnA== 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:content-language :subject:to:user-agent:mime-version:date:message-id:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=dhc/eGkD9EpH4JuxjEPP4wnuZuaupQ9krHd7JVUtfBI=; fh=XNn3asQvIblazGK92GBt13dVv+YmGV3pBS0JC29ZQco=; b=a4qqVlvHRjoygMUb+YieTqk4QnmL9Qjc6SApGr4Rq6PakhiE/+GBu5GSzYExGtsOnR Z2DJ5p5od2ManlbhNOV2pLmTwaCd5Oj6nM89u5XqfHJx4I06A9uw4eNsD0RPHZz4m0yR n8y7Uy4zz2/9T8TPnQTt1QUNUPwLlx6+6foIj/X+6s1aOIog2YPmyCGLCB+Jk1rO3ekC bRjRis1ahx2Yfs7NegZf/jtEwirv8fsLq8XR49aKx45LQQm37s4LvmC5PKtip9Kt3n+S F4cYcG4NnD8HU99JUE6j8EmunyTS68Amv2uRlxq3eavC89d5R1XiWDnJUwZW2NLPMwUx w3aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=O7GbbINI; 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id m6-20020aa7c486000000b00525665e8c36si11018360edq.430.2023.09.07.07.07.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 07:07:52 -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=O7GbbINI; 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 CE9973854810 for ; Thu, 7 Sep 2023 14:07:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE9973854810 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694095645; bh=dhc/eGkD9EpH4JuxjEPP4wnuZuaupQ9krHd7JVUtfBI=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=O7GbbINI0LA4IsOXTjp5OA9XK8/y62qQHiaPaH8S8pozVnph7SiEFXEVjgnbgw3gY m9vaEIS0Ev2o7xW54uI+X+xR+XiSvvbofP7WTZPoOyY0Ha424q9v2UITjCLt1YQc0p tq/oBU0TJcNMhoaMMwo2jVnh2FRvzd6bA6En/5WI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 61D753858410 for ; Thu, 7 Sep 2023 14:06:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 61D753858410 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-150-Zvv8oMYpMNypiQXPbX7AvQ-1; Thu, 07 Sep 2023 10:06:22 -0400 X-MC-Unique: Zvv8oMYpMNypiQXPbX7AvQ-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-76f29f14e0aso103147185a.0 for ; Thu, 07 Sep 2023 07:06:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694095581; x=1694700381; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zd5yOOC7gqCE343pJGX9wVBxdPCFUgN07gbC3yz55aM=; b=T9FDynll1M3+ZbgRan8h3nmt7InFu/4YBdXecEHiJE1VH2LgAfn8KMGpWH8rqIYLA/ MnBBglSyKUWJUzaNl0DPoQkNHSGNPzYt0fB8p5mhN4ZDZiMwb4LbdimQNSEuE6VwdBGL gVngkX3uEMjsj8m9rPackuRpWoKsvTwabDdu10V0iE+UtEhlvtJAE9iEpuKtQdSKNuN5 QyR1Ich2LJXJJxmbATR2Tq0W+Dj0bS/3DX5I9risA/FcCgIZ/6GzPAukPk+jwB/cVz2D IOF2X5ur33RCto3hPRekZ4vatM9+lpyrWrn12MV89Vp2sDXwXOFCDbs8s3kH5JtBQB3m w1EQ== X-Gm-Message-State: AOJu0Yz30hztan+Ngfj51jBIZyANRBpd9EMIf83UiLSUgzwLfNhYVdtk 9FS8Yi2p1d1WPN1sXj1OFmWrLO8XCdX5GbAe9CZw1dcu15ECb8q93rE2m3WTEIkiALhL0qN0PZM ADI7kcuI4T53s6hG9E6k8AljZ60lyoUpQy9JejXuHoMY2PiRUJhnHndL4nJu1+6ZTqyzSbZ6p8O wxGPG4 X-Received: by 2002:a05:620a:2ae2:b0:76e:eeaa:a06e with SMTP id bn34-20020a05620a2ae200b0076eeeaaa06emr20003174qkb.4.1694095581795; Thu, 07 Sep 2023 07:06:21 -0700 (PDT) X-Received: by 2002:a05:620a:2ae2:b0:76e:eeaa:a06e with SMTP id bn34-20020a05620a2ae200b0076eeeaaa06emr20003147qkb.4.1694095581476; Thu, 07 Sep 2023 07:06:21 -0700 (PDT) Received: from [192.168.1.88] (192-0-143-139.cpe.teksavvy.com. [192.0.143.139]) by smtp.gmail.com with ESMTPSA id j15-20020a0cc34f000000b00655935bca82sm2201402qvi.134.2023.09.07.07.06.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 Sep 2023 07:06:21 -0700 (PDT) Message-ID: Date: Thu, 7 Sep 2023 10:06:20 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 To: "gcc-patches@gcc.gnu.org" Subject: [pushed][PR111225][LRA]: Don't reuse chosen insn alternative with special memory constraint X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Vladimir Makarov via Gcc-patches From: Vladimir Makarov Reply-To: Vladimir Makarov Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776388064417913595 X-GMAIL-MSGID: 1776388064417913595 The following patch solves https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111225 The patch was successfully bootstrapped and tested on x86-64, aarch64, and ppc64le. commit f7bca44d97ad01b39f9d6e7809df7bf517eeb2fb Author: Vladimir N. Makarov Date: Thu Sep 7 09:59:10 2023 -0400 [LRA]: Don't reuse chosen insn alternative with special memory constraint To speed up GCC, LRA reuses chosen alternative from previous constraint subpass. A spilled pseudo is considered ok for any memory constraint although stack slot assigned to the pseudo later might not satisfy the chosen alternative constraint. As we don't consider all insn alternatives on the subsequent LRA sub-passes, it might result in LRA failure to generate the correct insn. This patch solves the problem. gcc/ChangeLog: PR target/111225 * lra-constraints.cc (goal_reuse_alt_p): New global flag. (process_alt_operands): Set up the flag. Clear flag for chosen alternative with special memory constraints. (process_alt_operands): Set up used insn alternative depending on the flag. gcc/testsuite/ChangeLog: PR target/111225 * gcc.target/i386/pr111225.c: New test. diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc index c718bedff32..3aaa4906999 100644 --- a/gcc/lra-constraints.cc +++ b/gcc/lra-constraints.cc @@ -1462,6 +1462,9 @@ static int goal_alt_matches[MAX_RECOG_OPERANDS]; static int goal_alt_dont_inherit_ops_num; /* Numbers of operands whose reload pseudos should not be inherited. */ static int goal_alt_dont_inherit_ops[MAX_RECOG_OPERANDS]; +/* True if we should try only this alternative for the next constraint sub-pass + to speed up the sub-pass. */ +static bool goal_reuse_alt_p; /* True if the insn commutative operands should be swapped. */ static bool goal_alt_swapped; /* The chosen insn alternative. */ @@ -2130,6 +2133,7 @@ process_alt_operands (int only_alternative) int curr_alt_dont_inherit_ops_num; /* Numbers of operands whose reload pseudos should not be inherited. */ int curr_alt_dont_inherit_ops[MAX_RECOG_OPERANDS]; + bool curr_reuse_alt_p; /* True if output stack pointer reload should be generated for the current alternative. */ bool curr_alt_out_sp_reload_p; @@ -2217,6 +2221,7 @@ process_alt_operands (int only_alternative) reject += static_reject; early_clobbered_regs_num = 0; curr_alt_out_sp_reload_p = false; + curr_reuse_alt_p = true; for (nop = 0; nop < n_operands; nop++) { @@ -2574,7 +2579,10 @@ process_alt_operands (int only_alternative) if (satisfies_memory_constraint_p (op, cn)) win = true; else if (spilled_pseudo_p (op)) - win = true; + { + curr_reuse_alt_p = false; + win = true; + } break; } break; @@ -3318,6 +3326,7 @@ process_alt_operands (int only_alternative) goal_alt_offmemok[nop] = curr_alt_offmemok[nop]; } goal_alt_dont_inherit_ops_num = curr_alt_dont_inherit_ops_num; + goal_reuse_alt_p = curr_reuse_alt_p; for (nop = 0; nop < curr_alt_dont_inherit_ops_num; nop++) goal_alt_dont_inherit_ops[nop] = curr_alt_dont_inherit_ops[nop]; goal_alt_swapped = curr_swapped; @@ -4399,7 +4408,8 @@ curr_insn_transform (bool check_only_p) } lra_assert (goal_alt_number >= 0); - lra_set_used_insn_alternative (curr_insn, goal_alt_number); + lra_set_used_insn_alternative (curr_insn, goal_reuse_alt_p + ? goal_alt_number : LRA_UNKNOWN_ALT); if (lra_dump_file != NULL) { diff --git a/gcc/testsuite/gcc.target/i386/pr111225.c b/gcc/testsuite/gcc.target/i386/pr111225.c new file mode 100644 index 00000000000..5d92daf215b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr111225.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fsanitize=thread -mforce-drap -mavx512cd" } */ + +typedef long long __m256i __attribute__ ((__vector_size__ (32))); + +int foo (__m256i x, __m256i y) +{ + __m256i a = x & ~y; + return !__builtin_ia32_ptestz256 (a, a); +} + +int bar (__m256i x, __m256i y) +{ + __m256i a = ~x & y; + return !__builtin_ia32_ptestz256 (a, a); +}