From patchwork Wed Jun 9 09:16:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Zissulescu Ianculescu X-Patchwork-Id: 1489763 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=naDvr813; 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 4G0M4K39nPz9sRN for ; Wed, 9 Jun 2021 19:19:13 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 709AC385383B for ; Wed, 9 Jun 2021 09:19:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 709AC385383B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1623230351; bh=yBv5cZyBw82Iq8VKxvZul5x9X+NGhr8c24TgNtAC5RU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=naDvr8136DmcVZmfTrw+o06Grrg/0Xy61/IAdaAoLa0cKcXVvIvuviFegAmMcBmad TSxZGPIuglOrhl75XGsG3bajqfGcdzQ0x0nMtgBDgxBVhA18OhNOGMYb8wvJ4ZX1if V5QWoc4bV5C3re7NbbX19aFbr4aIxF1DnMjjcyqY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id B10203857023 for ; Wed, 9 Jun 2021 09:16:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B10203857023 Received: by mail-ej1-x62d.google.com with SMTP id og14so32051536ejc.5 for ; Wed, 09 Jun 2021 02:16:53 -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:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yBv5cZyBw82Iq8VKxvZul5x9X+NGhr8c24TgNtAC5RU=; b=ZDUwSKgPH0en1hUNFqp5lcfiEgDEKWsYc4ufVf0zk1SM5NmQm6KiPIWcCXryQwAaxB Vb8B8dDwQY0dMcfSuW1qJtf+7ksns2vIRH4A3NNnFNgYD1adIRiU6lPztYPRr2q1R/ie 9M9gOzWfxHVrzWWSkOUaiUpmrzMAxTcFFaB0M657AB2DEyMC8JwaSOhHk4kyndzB+3PA wGfqrka4ufdIG6AB4nowvN4Wjl4UcemNOxendQR4al2IuaFwj2VN5rzcbYbaMgFJpapQ VYBqefMGBJsfsNvynGNQNaHSqSZGo5CfM1dcgJjSQKJykjGDpSgyMqEHzTIwxTzqkQlx m60w== X-Gm-Message-State: AOAM532sP1q499RKcfqNaA0JHEntfojScYGO7MHM+dq93tjZcW2LS6OX qeBce9th7Cc4mGOJtsYy7yQ7pvozpf/zxA== X-Google-Smtp-Source: ABdhPJxRIVdxe7Fjvd1itd3apUBGCC5gvbmTY6WbfKIsg9ZeXy7zOCBGMddXS3O414g5Eq5lsLIB+g== X-Received: by 2002:a17:906:9512:: with SMTP id u18mr27686548ejx.61.1623230212593; Wed, 09 Jun 2021 02:16:52 -0700 (PDT) Received: from localhost.localdomain ([79.115.44.61]) by smtp.gmail.com with ESMTPSA id t2sm825371ejx.72.2021.06.09.02.16.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 02:16:52 -0700 (PDT) X-Google-Original-From: Claudiu Zissulescu To: gcc-patches@gcc.gnu.org Subject: [committed] arc: Update doloop_end patterns Date: Wed, 9 Jun 2021 12:16:44 +0300 Message-Id: <20210609091644.476605-3-claziss@synopsys.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210609091644.476605-1-claziss@synopsys.com> References: <20210609091644.476605-1-claziss@synopsys.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 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.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: , X-Patchwork-Original-From: Claudiu Zissulescu via Gcc-patches From: Claudiu Zissulescu Ianculescu Reply-To: Claudiu Zissulescu Cc: fbedard@synopsys.com Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" ARC processor can use LP instruction to implement zero overlay loops. The current inplementation doesn't handle the unlikely situation when the loop iterator is located in memory. Refurbish the loop_end insn pattern into a define_insn_and_split pattern. This patch is also backported to gcc11. gcc/ yyyy-dd-mm Claudiu Zissulescu * config/arc/arc.md (loop_end): Change it to define_insn_and_split. Signed-off-by: Claudiu Zissulescu --- gcc/config/arc/arc.md | 46 +++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md index aed0b40728b..90ba85e274e 100644 --- a/gcc/config/arc/arc.md +++ b/gcc/config/arc/arc.md @@ -4962,7 +4962,7 @@ (define_insn "*bbit" (define_expand "doloop_end" [(parallel [(set (pc) (if_then_else - (ne (match_operand 0 "" "") + (ne (match_operand 0 "nonimmediate_operand") (const_int 1)) (label_ref (match_operand 1 "" "")) (pc))) @@ -4988,44 +4988,38 @@ (define_insn "arc_lp" ;; if by any chance the lp_count is not used, then use an 'r' ;; register, instead of going to memory. -(define_insn "loop_end" - [(set (pc) - (if_then_else (ne (match_operand:SI 2 "nonimmediate_operand" "0,m") - (const_int 1)) - (label_ref (match_operand 1 "" "")) - (pc))) - (set (match_operand:SI 0 "nonimmediate_operand" "=r,m") - (plus (match_dup 2) (const_int -1))) - (unspec [(const_int 0)] UNSPEC_ARC_LP) - (clobber (match_scratch:SI 3 "=X,&r"))] - "" - "; ZOL_END, begins @%l1" - [(set_attr "length" "0") - (set_attr "predicable" "no") - (set_attr "type" "loop_end")]) - ;; split pattern for the very slim chance when the loop register is ;; memory. -(define_split +(define_insn_and_split "loop_end" [(set (pc) - (if_then_else (ne (match_operand:SI 0 "memory_operand") + (if_then_else (ne (match_operand:SI 0 "nonimmediate_operand" "+r,!m") (const_int 1)) - (label_ref (match_operand 1 "")) + (label_ref (match_operand 1 "" "")) (pc))) (set (match_dup 0) (plus (match_dup 0) (const_int -1))) (unspec [(const_int 0)] UNSPEC_ARC_LP) - (clobber (match_scratch:SI 2))] - "memory_operand (operands[0], SImode)" + (clobber (match_scratch:SI 2 "=X,&r"))] + "" + "@ + ; ZOL_END, begins @%l1 + #" + "reload_completed && memory_operand (operands[0], Pmode)" [(set (match_dup 2) (match_dup 0)) - (set (match_dup 2) (plus:SI (match_dup 2) (const_int -1))) + (parallel + [(set (reg:CC_ZN CC_REG) + (compare:CC_ZN (plus:SI (match_dup 2) (const_int -1)) + (const_int 0))) + (set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))]) (set (match_dup 0) (match_dup 2)) - (set (reg:CC CC_REG) (compare:CC (match_dup 2) (const_int 0))) (set (pc) - (if_then_else (ne (reg:CC CC_REG) + (if_then_else (ne (reg:CC_ZN CC_REG) (const_int 0)) (label_ref (match_dup 1)) (pc)))] - "") + "" + [(set_attr "length" "0,24") + (set_attr "predicable" "no") + (set_attr "type" "loop_end")]) (define_insn "loop_fail" [(set (reg:SI LP_COUNT)