From patchwork Thu Apr 16 12:08:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1271672 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 492ygM3C81z9sP7 for ; Thu, 16 Apr 2020 22:08:44 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B1FA1385BF81; Thu, 16 Apr 2020 12:08:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 4CDB3385B835 for ; Thu, 16 Apr 2020 12:08:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4CDB3385B835 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=richard.sandiford@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E2E5DC14 for ; Thu, 16 Apr 2020 05:08:33 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8B3A43F73D for ; Thu, 16 Apr 2020 05:08:33 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [committed] early-remat: Handle sets of multiple candidate regs [PR94605] Date: Thu, 16 Apr 2020 13:08:32 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-26.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" early-remat.c:process_block wasn't handling insns that set multiple candidate registers, which led to an assertion failure at the end of the main loop. Instructions that set two pseudos aren't rematerialisation candidates in themselves, but we still need to track them if another instruction that sets the same register is a rematerialisation candidate. Tested on aarch64-linux-gnu, aarch64_be-elf and x86_64-linux-gnu. Pushed as obvious. I'll backport to GCC 9 and 8 too. Richard 2020-04-16 Richard Sandiford gcc/ PR rtl-optimization/94605 * early-remat.c (early_remat::process_block): Handle insns that set multiple candidate registers. gcc/testsuite/ PR rtl-optimization/94605 * gcc.target/aarch64/sve/pr94605.c: New test. --- gcc/early-remat.c | 2 +- gcc/testsuite/gcc.target/aarch64/sve/pr94605.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr94605.c diff --git a/gcc/early-remat.c b/gcc/early-remat.c index 80672cca241..9f5f8541644 100644 --- a/gcc/early-remat.c +++ b/gcc/early-remat.c @@ -2020,7 +2020,7 @@ early_remat::process_block (basic_block bb) } /* Now process definitions. */ - if (next_def && insn == next_def->insn) + while (next_def && insn == next_def->insn) { unsigned int gen = canon_candidate (next_candidate); diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr94605.c b/gcc/testsuite/gcc.target/aarch64/sve/pr94605.c new file mode 100644 index 00000000000..593e959e292 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/pr94605.c @@ -0,0 +1,12 @@ +/* { dg-options "-O2 -msve-vector-bits=256" } */ + +typedef int v8si __attribute__((vector_size(32))); +int g (v8si, v8si); + +void +f (void) +{ + v8si x = {}, y = {}; + while (g (x, y)) + asm ("" : "+w" (x), "+w" (y)); +}