From patchwork Sat Nov 20 16:31:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 47967 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D671F3858025 for ; Sat, 20 Nov 2021 16:32:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D671F3858025 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637425921; bh=CKHGSVvh6rsgUHLGzXzdLe67VmoCxkxCdrqxVKIjUqk=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Xr4dyvjg8twrtclpfNl5r0XTKdvkSPVSNB33ueLjlGV9+barhYaeupSlXnpqt93ha N28DEb0B5OlDPGqgx6+PftAPjYMIXFp5xmHFOImFv/A9PodmSnKomFiXHIa+11L3bK DMP5QEGpGpyzF4WcrDO8DQXkT2dBE3rA0StQq49A= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id 17FC3385840D for ; Sat, 20 Nov 2021 16:31:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 17FC3385840D Received: by mail-pg1-x52a.google.com with SMTP id g28so11324395pgg.3 for ; Sat, 20 Nov 2021 08:31:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:from:subject:to; bh=CKHGSVvh6rsgUHLGzXzdLe67VmoCxkxCdrqxVKIjUqk=; b=uJLcQMsmEPkNdp6Kgbm0vzugNyV4ajG12ffnUT8508438CqPKkjFO8FrWNZqz2A5K8 0TqYbeOGr5KRi/aXRBHFqtQFZp7bRc63EBFViFYrsFbg9sHGKV5g1bLAeYrijW4z5bxI YnFLb/BV8c5f7Bg9D6QbbnjxWCajTnZm14d2LV6i4yI6yTjBhsNUUwZ2alYHy+iZ3Edu ToohuGxSwO3v3cZwbcU8S+5JHonhfQvmTHn01sL1FnKesthVBU9Uy4AZ7r7r7eOi8ZnB O3YLREd5rUEm9YQgtuhyY3hsjcFCuWyoBO+hQ0S/3OWy8vqCr2mNpFld4LfF4MF4dD9q iVcg== X-Gm-Message-State: AOAM530pzb2FevTa6H1I8tRVuXXEAX/bAxj5pGIJNtovg+WHUjHXNuNv 5rlgOD8KLZMDVlE07KY3esFE/hNLK70= X-Google-Smtp-Source: ABdhPJxfFXiHcNGUs0OZpBKzoj/fHbsGvioxE9E6pPWQDFYIT2KKNyOEBuBeNHr2lsbtJweZl1TQMw== X-Received: by 2002:a63:3348:: with SMTP id z69mr24088367pgz.177.1637425890805; Sat, 20 Nov 2021 08:31:30 -0800 (PST) Received: from [172.31.0.175] (c-98-202-48-222.hsd1.ut.comcast.net. [98.202.48.222]) by smtp.gmail.com with ESMTPSA id f2sm3436210pfe.132.2021.11.20.08.31.30 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 20 Nov 2021 08:31:30 -0800 (PST) Message-ID: <5f9d27eb-6202-f087-e6d9-7b2c9e142d05@gmail.com> Date: Sat, 20 Nov 2021 09:31:29 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Content-Language: en-US Subject: [committed][PR tree-optimization103226] Clobber the condition code in the bfin doloop patterns To: GCC Patches X-Spam-Status: No, score=-8.6 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Jeff Law via Gcc-patches From: Jeff Law Reply-To: Jeff Law Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Per Aldy's excellent, but tough to follow analysis in PR 103226, this patch fixes the bfin-elf regression. In simplest terms the doloop patterns on this port may clobber the condition code register, but they do not expose that until after register allocation.  That would be fine, except that other patterns have exposed CC earlier.  As a result the dataflow, particularly for CC, is incorrect. This leads the register allocators to assume that a value in CC outside the loop is still valid inside the loop when in fact, the value has been clobbered.  This is what caused pr80974 to start failing. With this fix, not only do we fix the pr80974 regression, but we fix ~20 other execution failures in the port.  It also reduces test time for the port from ~90 minutes to ~60 minutes. Committed to the trunk, Jeff commit 7950c96ca667ddaab9d6e894da3958ebc2e2dccb Author: Jeff Law Date: Sat Nov 20 11:20:07 2021 -0500 Clobber the condition code in the bfin doloop patterns Per Aldy's excellent, but tough to follow analysis in PR 103226, this patch fixes the bfin-elf regression. In simplest terms the doloop patterns on this port may clobber the condition code register, but they do not expose that until after register allocation. That would be fine, except that other patterns have exposed CC earlier. As a result the dataflow, particularly for CC, is incorrect. This leads the register allocators to assume that a value in CC outside the loop is still valid inside the loop when in fact, the value has been clobbered. This is what caused pr80974 to start failing. With this fix, not only do we fix the pr80974 regression, but we fix ~20 other execution failures in the port. It also reduces test time for the port from ~90 minutes to ~60 minutes. PR tree-optimization/103226 gcc/ * config/bfin/bfin.md (doloop pattern, splitter and expander): Clobber CC. diff --git a/gcc/config/bfin/bfin.md b/gcc/config/bfin/bfin.md index fd65f4d9e63..10a19aac23e 100644 --- a/gcc/config/bfin/bfin.md +++ b/gcc/config/bfin/bfin.md @@ -1959,7 +1959,8 @@ (plus:SI (match_dup 0) (const_int -1))) (unspec [(const_int 0)] UNSPEC_LSETUP_END) - (clobber (match_dup 2))])] ; match_scratch + (clobber (match_dup 2)) + (clobber (reg:BI REG_CC))])] ; match_scratch "" { /* The loop optimizer doesn't check the predicates... */ @@ -1979,7 +1980,8 @@ (plus (match_dup 2) (const_int -1))) (unspec [(const_int 0)] UNSPEC_LSETUP_END) - (clobber (match_scratch:SI 3 "=X,&r,&r"))] + (clobber (match_scratch:SI 3 "=X,&r,&r")) + (clobber (reg:BI REG_CC))] "" "@ /* loop end %0 %l1 */ @@ -1997,7 +1999,8 @@ (plus (match_dup 0) (const_int -1))) (unspec [(const_int 0)] UNSPEC_LSETUP_END) - (clobber (match_scratch:SI 2))] + (clobber (match_scratch:SI 2)) + (clobber (reg:BI REG_CC))] "memory_operand (operands[0], SImode) || splitting_loops" [(set (match_dup 2) (match_dup 0)) (set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))