From patchwork Thu Jul 8 21:12:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 1502762 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+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=f8Inzusy; dkim-atps=neutral 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 4GLTYP4WQ4z9sRK for ; Fri, 9 Jul 2021 07:13:45 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2CFBA3AA9C1E for ; Thu, 8 Jul 2021 21:13:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CFBA3AA9C1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1625778823; bh=/TPsVZfs++xzmjH792QMZ5QhCnl7XqdNCT5dNdCQfH4=; h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=f8InzusyDgm30VH7tg/QvNEQc9lb4bgsda3lmi5mQlDwEXM5TPZM/pF5IHpF8+RSR na7K8YdLUmDu4TT4RuYSu9YR8P6FFvBHwwn+6a7bf70HgTs9GR7cxmaITyvQ6VNSYo 1bE7v+0ieN8u+HG28MrOqL3nrbnJOQ6RNNtOp+F8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by sourceware.org (Postfix) with ESMTPS id BA1F1385BC23 for ; Thu, 8 Jul 2021 21:12:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BA1F1385BC23 Received: by mail-pj1-x102f.google.com with SMTP id p17-20020a17090b0111b02901723ab8d11fso4812034pjz.1 for ; Thu, 08 Jul 2021 14:12:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version:content-language; bh=/TPsVZfs++xzmjH792QMZ5QhCnl7XqdNCT5dNdCQfH4=; b=E4qVklQkYbTGCdqn/GYvlxpLsxBk92J+SWdOiw+JF+wxFoZYiPkNbgNmMl0Ptf1ZJU 8tod67nQ07pGL+7O9l3L4j/sSlDDCRbjjvjHxtBNVnYaqQUAfbGMEmZ7tgmixzRUauUB anOWiSR5MTEVOV0XcH6MXbq7zSO2pm87JzLR4yJZekxIw23dAO8t9U11i5O+Akh7mOFi KCajWk1CYwL0Y9i8mW/YGNWJYcjzEeVcYhve3fF6H7xZZazrD1e0wl2kg8Z0f6C1vGjE S62GHj7ZMbwRHOOlTW/+s0P8rbFr9TN6cVEIDIwYGWaKIPqzH6WXIXquOaJ/TxGuGKJ6 rPyg== X-Gm-Message-State: AOAM531p1TYOZVPDRfOP9xXy4JjNasflcV5IJy/VH5pRJOFSxO2h/cCM Jx421m1zPi4i4T13LcoGjA9WZax/f4yeAw== X-Google-Smtp-Source: ABdhPJy7ob5Epa//PpHubKQYAEv4xCyQ1fzZR6i0/y0mr/bULb4v1+WHFQFxv2Bcym7qkXT7l4LGpg== X-Received: by 2002:a17:90a:4584:: with SMTP id v4mr32837145pjg.77.1625778775499; Thu, 08 Jul 2021 14:12:55 -0700 (PDT) Received: from [192.168.1.17] (c-98-202-48-222.hsd1.ut.comcast.net. [98.202.48.222]) by smtp.gmail.com with ESMTPSA id c9sm3453143pja.7.2021.07.08.14.12.54 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Jul 2021 14:12:55 -0700 (PDT) Subject: [committed] Further improvements to H8 variable shift patterns To: GCC Patches Message-ID: <960ff18f-8daa-af73-c6ea-741e83117f47@gmail.com> Date: Thu, 8 Jul 2021 15:12:54 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-8.3 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" And another installment in optimizing a dead architecture.   This builds on prior patches to improve compare/test elimination for shifts.  Specifically for the older chips in the H8 family we have to handle variable shifts with a loop. Right now the splitter generates (set (pc) (if_then_else (lt (countreg) (const_int 0))) to test the shift count.  That will get lowered into a compare and a conditional branch using CC_REG. However, this lowering happens after the compare-elim pass, so we don't get much benefit. Instead we can lower directly to the cc exposing form and remove the unnecessary test ourselves (particularly for the case where the shift count pseudo does not die).  Essentially we know that the copy into the scratch register is going to set the condition codes in a useful way.  So we expose the condition codes on that copy and emit a condition code exposed conditional branch and no longer generate the comparison. Built & tested in the usual way on the H8 without regressions.  Committed to the trunk. Probably the last H8 patch before going on vacation :-) Jeff commit b14ac7b29c9a05c94f62fe065c219bbaa83653db Author: Jeff Law Date: Thu Jul 8 17:09:36 2021 -0400 Further improvements to H8 variable shift patterns gcc/ * config/h8300/shiftrotate.md (variable shifts): Expose condition code handling for the test before the loop. diff --git a/gcc/config/h8300/shiftrotate.md b/gcc/config/h8300/shiftrotate.md index 485303cb906..d3aa6bea064 100644 --- a/gcc/config/h8300/shiftrotate.md +++ b/gcc/config/h8300/shiftrotate.md @@ -377,8 +377,10 @@ (clobber (reg:CC CC_REG))] "epilogue_completed && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))" - [(set (pc) - (if_then_else (le (match_dup 1) (const_int 0)) + [(set (reg:CCZN CC_REG) + (compare:CCZN (match_dup 1) (const_int 0))) + (set (pc) + (if_then_else (le (reg:CCZN CC_REG) (const_int 0)) (label_ref (match_dup 5)) (pc))) (match_dup 4) @@ -411,10 +413,12 @@ (clobber (reg:CC CC_REG))] "epilogue_completed && !find_regno_note (insn, REG_DEAD, REGNO (operands[1]))" - [(set (match_dup 3) - (match_dup 1)) + [(parallel + [(set (reg:CCZN CC_REG) + (compare:CCZN (match_dup 1) (const_int 0))) + (set (match_dup 3) (match_dup 1))]) (set (pc) - (if_then_else (le (match_dup 3) (const_int 0)) + (if_then_else (le (reg:CCZN CC_REG) (const_int 0)) (label_ref (match_dup 5)) (pc))) (match_dup 4)