From patchwork Mon Jul 18 12:00:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 35 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp1809527eik; Mon, 18 Jul 2022 05:02:33 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sGw1BtoLpnXlbZagMwX3hGoyiHgi/tyKzM0V11GPByePPz+yYV36YbQk15d7UReMkD0js+ X-Received: by 2002:a05:6402:51ce:b0:43a:d409:b3e8 with SMTP id r14-20020a05640251ce00b0043ad409b3e8mr36183668edd.166.1658145753843; Mon, 18 Jul 2022 05:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658145753; cv=none; d=google.com; s=arc-20160816; b=PGtwFVaTn/Z8ZdSXcikS0DQ7nyPl/DIsSiqeo3k9gvUJXUj+5B5z+chhZwMNieJ6Zv lD0v4NYCAV4hfzrXjEurnP63oXRSnaKeSFP9AX0HpXqbCTySt1zcE9MZQVvYA3+xXx9h UITpTtPlM2NFGj+RlgJQVxEkDqlr19IHSaLItV+nW1D2W9JLEi7Ev6zN8e9Ack4H0okb FNgnc5biBofs/ZMUNzvb26l3vs3n10W2SJCcuaCo2O7BZj57rwgGnhvDgOEKXBITVf7k vfxxRjT+T5Jao5wbbCB05mY8yF/zg4qNtA+BBRObTqr4IkpwQnyjoEmzkmXI3r3W2t30 MASA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=+8raqENi0nKNLqX49iJdQtuNm2usr9DH+CNZXQmZWGE=; b=R0bL77TZyHESn5e+4pRRPl3YmzdeevL8hAV8bm/fvWvOibYgk+IE3MXwHB9SWQ5q1/ 3iuMlZ0jWo85Q2PVjx9j+3WZoeubzsPq2fs2XWCw6N5OYYl15kE+H2nm+5MM6yC0SWiF ij2NHYcwrXpOMhJm+2afR8zpayaNVV8NMKdwLPmcdo0JHQ82kM9Z8Mvc/F5xxTu3EgPB +quXwlEPnti4U4wBYTKHHIZN5db8Sbf5IBUrMhIyihlMqdk49IlD2owYCKRlf1LIwqj2 IoTs6LatC/kf+vMrKvdKGHxO5+KVF3zLSFWXIxO1OKexM5lcRkyC4nCV5tCXHI+U693n TlCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=KsD6LNUf; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id z17-20020a05640240d100b004359ebb62d7si19094155edb.1.2022.07.18.05.02.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 05:02:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=KsD6LNUf; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 06B8E383A34F for ; Mon, 18 Jul 2022 12:01:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 06B8E383A34F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658145683; bh=+8raqENi0nKNLqX49iJdQtuNm2usr9DH+CNZXQmZWGE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=KsD6LNUfouaPPyld7JFs1NwesDFexiV/jOTTiT/COnpFwHEEql/cTFawyAIm+vaqr Uq41pLDxK3CXKIcs2/zHgXj3Ty8guHrcz8d9A/co/W0E5ZBRF+0UZ0qCI4DGdyCd81 K/fLHt5NvxJgBbhd//ui4Ov0geqSUFml2llI273E= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 6C065385085C for ; Mon, 18 Jul 2022 12:00:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6C065385085C Received: by mail-wr1-x431.google.com with SMTP id r14so16719060wrg.1 for ; Mon, 18 Jul 2022 05:00:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+8raqENi0nKNLqX49iJdQtuNm2usr9DH+CNZXQmZWGE=; b=Dc62v36FaRy6kZr3I7EvisanwchymZiueNK8PR7ACsevweEpdS6Ye+8EpCC298nwxF gx2k4ACNU19MvBrcg3OGdj+36q/3T1pm2k/zfgUMvObODuSRpfyTlIrR0LeOh3soMPxR OYnwYyDIhGNVESIIFUQwOmoY5Kv1rmtJbD7Rp78HDcMPDNWafHT3wC5nIrnqresux3C7 84Z9l6ncyM3kjSAsebtzr9jvjWGrGCjGJsWIZvszAgdAUPKhajK1o6o9WTcmMmIUNIKf l/H2/tUAluTppUAs+t52P8ssf2N0uPVp1ifqL9HabvViYgu8sJBrtcBkz2CNUVG9OPX1 DcMg== X-Gm-Message-State: AJIora9nE91fiLwttTVVRlWuMcPlVEnJNRFhwql7+khvpKOZ1vUIIvb5 Xi/ShL1GWm88lCpcQAeUgQTobhKyMcA= X-Received: by 2002:a05:6000:2ab:b0:21d:b410:5999 with SMTP id l11-20020a05600002ab00b0021db4105999mr22403854wry.517.1658145637829; Mon, 18 Jul 2022 05:00:37 -0700 (PDT) Received: from fatty.nomansland ([193.187.151.25]) by smtp.gmail.com with ESMTPSA id h7-20020adf9cc7000000b0021d8faf57d5sm11049233wre.74.2022.07.18.05.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 05:00:37 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [committed 1/2] arc: Fix interrupt's epilogue. Date: Mon, 18 Jul 2022 15:00:35 +0300 Message-Id: <20220718120036.3290240-1-claziss@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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.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: "Li, Pan2 via Gcc-patches" Reply-To: Claudiu Zissulescu Cc: fbedard@synopsys.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1738690252429437103?= X-GMAIL-MSGID: =?utf-8?q?1738691841801653561?= The stack pointer adjustment in interrupt epilogue is happening after restoring the ZOL registers which is wrong. Fixing this. gcc/ * config/arc/arc.cc (arc_expand_epilogue): Adjust the frame pointer first when in interrupts. gcc/testsuite/ * gcc.target/arc/interrupt-13.c: New file. Signed-off-by: Claudiu Zissulescu --- gcc/config/arc/arc.cc | 2 +- gcc/testsuite/gcc.target/arc/interrupt-13.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/arc/interrupt-13.c diff --git a/gcc/config/arc/arc.cc b/gcc/config/arc/arc.cc index fbc17e684a0..77730c88e55 100644 --- a/gcc/config/arc/arc.cc +++ b/gcc/config/arc/arc.cc @@ -3965,7 +3965,7 @@ arc_expand_epilogue (int sibcall_p) if (size) emit_insn (gen_blockage ()); - if (ARC_INTERRUPT_P (fn_type) && restore_fp) + if (ARC_INTERRUPT_P (fn_type)) { /* We need to restore FP before any SP operation in an interrupt. */ diff --git a/gcc/testsuite/gcc.target/arc/interrupt-13.c b/gcc/testsuite/gcc.target/arc/interrupt-13.c new file mode 100644 index 00000000000..0ed8451c512 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/interrupt-13.c @@ -0,0 +1,15 @@ +/* { dg-options "-O2" } */ + +extern int foo (int *); + +void __attribute__((interrupt("ilink"))) +irq (void) +{ + struct { + int x0; + int x1; + } a = {1 ,2}; + foo ((int *)&a); +} + +/* { dg-final { scan-assembler "add_s\\s+sp,sp,8.*pop_s\\s+r0" } } */ From patchwork Mon Jul 18 12:00:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 36 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp1809974eik; Mon, 18 Jul 2022 05:03:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u3Nzh0+QNjpvB6mDhPr6/oh/3ttsgg+SCxR0xnrlsjSbv8B7S3sIpaZ8xN8Hz6sWKJrE61 X-Received: by 2002:a05:6402:2425:b0:43b:20a8:ae8b with SMTP id t37-20020a056402242500b0043b20a8ae8bmr29464139eda.234.1658145785789; Mon, 18 Jul 2022 05:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658145785; cv=none; d=google.com; s=arc-20160816; b=Doo2QjmJpt6NhEz8sSEKcpJ8fSdCUMGvI+8sMl0ZwvH28OjLHP8RTI1KillvHS1jg9 flFPaPqer0QEb+M9rJZ9y6SFRmP2ATQosipa8Hgg8ZU2ORRyWEM9XPYUTYTW3qvy6Lv+ J0xBms0JGqzC7lm1ACWA4gm7VyYwTK+NhlUWmjyD4PwKcMgc122C4Lfa+n+LKbnnlx95 6O55vmuZOXft3kK41+Cl79q47mP3X2vISBkCXcCdthQPDjDKs6aTbThUyXRgRmiadqzB P21miB+Ti5iMDPmdPQEsfcjXplTY5oak17ziT9hrymrDeE2JwKLVCCE97w8oLCKdxUDZ BvAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=2lVGu00lXqmNBx7mlXY91VOh3ORAFwpSJmvc/C86l9g=; b=jDIxyEeZV0KvdOKPf/fpN5AQEzlaOWG3XBiwOVAgKzIovPhGUygufLK0fICDwbA+Dg zH67nRwlaJwxaXAlV0z+DNN38vNsCjiBHORB86o7XsgmCQ+sgCaYeBunG37NY8ZTEaK2 /+w9dRgOzP00mYoz+7pndOASMa5wJkTmyuKNjkcIKhvU5054acatZeVhsS2b/WO3yEXI Tu1Z3ujgtifd0iGoEotFKgh+ceIMsiEHWdhWYmec0+GcX/FoZoMR9NZNorp4qrQXwAoZ /bGxsAv9lbT53EeH04oVMSqyiEtHOdSpJtSMIPzNaGeeEjHcNOxMQfJn8di/B+WHkP4B YCCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="LYEl/PCh"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id q10-20020a170906940a00b0072e6774827asi12324833ejx.915.2022.07.18.05.03.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 05:03:05 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="LYEl/PCh"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 3965838515C8 for ; Mon, 18 Jul 2022 12:02:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3965838515C8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658145720; bh=2lVGu00lXqmNBx7mlXY91VOh3ORAFwpSJmvc/C86l9g=; 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=LYEl/PChTXJUujc+wuA1PTVMbdAF1o3fOy5/jYB/hKIEDLIbWUUAYos7M5f7iQTX+ WE8bTWT1brM1WVPxfHirSPbaDis1QsPTIQZbCtrZW5Gx04tMaKTcNauMGdzwurICce aPlc/diANYaWoOVqighl/KzCBL3hTNdW7ezRlvGQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 3E7E9385117B for ; Mon, 18 Jul 2022 12:00:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3E7E9385117B Received: by mail-wr1-x431.google.com with SMTP id r14so16719583wrg.1 for ; Mon, 18 Jul 2022 05:00:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2lVGu00lXqmNBx7mlXY91VOh3ORAFwpSJmvc/C86l9g=; b=ViupnrzW46OgI4XIYfcvIcLLrKFfq8tyzlX6TviMY5ecDaV43nnKbPufaclSanWP6H wTV7rB/5fztsBaXzkhcip250xDDfZIO3ozuhR9IRGrgEvtJRlMMoYykMOb8JfqRAq5TN lfBsTqSUiRLUJZgY3tIRlpVdZUWjuTB1SQxgiEjiAkNqB4i7be7kATb6vwLeIXJBlJa0 9WHl/33Pm9Od33yUm+lNl8I8hBFfItBPWHYUVIlT4AQWQgN0gLhYD7I2Au9LVu3kv/B1 3psnTSZ/oKi7MxzyWTxT0trdzaLmIS5WlExxUbVIaWw+9JJsxBw6jkEjxNUSJoRoqynn VqLg== X-Gm-Message-State: AJIora/tL3zXVd1DM9cuSZjhR8F9w+4OWzw8X9091uj0zeTk+LuQ+gPy EFohsmOojZ2yQ1U0QBaqbo3oTiWQFa4= X-Received: by 2002:a5d:6483:0:b0:21d:99c5:cb6e with SMTP id o3-20020a5d6483000000b0021d99c5cb6emr22823386wri.592.1658145643527; Mon, 18 Jul 2022 05:00:43 -0700 (PDT) Received: from fatty.nomansland ([193.187.151.25]) by smtp.gmail.com with ESMTPSA id h7-20020adf9cc7000000b0021d8faf57d5sm11049233wre.74.2022.07.18.05.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 05:00:43 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [committed 2/2] libgcc/arc: Update udivmodsi4 and make the lib safe for rf16 Date: Mon, 18 Jul 2022 15:00:36 +0300 Message-Id: <20220718120036.3290240-2-claziss@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220718120036.3290240-1-claziss@gmail.com> References: <20220718120036.3290240-1-claziss@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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.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: "Li, Pan2 via Gcc-patches" Reply-To: Claudiu Zissulescu Cc: fbedard@synopsys.com, Claudiu Zissulescu Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1738691875486351438?= X-GMAIL-MSGID: =?utf-8?q?1738691875486351438?= From: Claudiu Zissulescu The ARC soft udivmodsi4 algorithm and as well as using umodsi3 for reduced register set configurations are wrong. libgcc/ * config/arc/lib2funcs.c (udivmodsi4): Update AND mask. * config/arc/lib1funcs.S (umodsi3): Don't use it for RF16 configurations. --- libgcc/config/arc/lib1funcs.S | 2 ++ libgcc/config/arc/lib2funcs.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libgcc/config/arc/lib1funcs.S b/libgcc/config/arc/lib1funcs.S index 14fd1d2f303..b06361257d1 100644 --- a/libgcc/config/arc/lib1funcs.S +++ b/libgcc/config/arc/lib1funcs.S @@ -936,6 +936,7 @@ SYM(__divsi3): #endif /* L_divsi3 */ +#ifndef __ARC_RF16__ #ifdef L_umodsi3 .section .text .align 4 @@ -950,6 +951,7 @@ SYM(__umodsi3): ENDFUNC(__umodsi3) #endif /* L_umodsi3 */ +#endif /* !__ARC_RF16__ */ #ifdef L_modsi3 .section .text diff --git a/libgcc/config/arc/lib2funcs.c b/libgcc/config/arc/lib2funcs.c index 70727b55365..8cba45172b2 100644 --- a/libgcc/config/arc/lib2funcs.c +++ b/libgcc/config/arc/lib2funcs.c @@ -59,7 +59,7 @@ udivmodsi4 (nint32_t num, nint32_t den, word_t modwanted) nint32_t bit = 1; nint32_t res = 0; - while (den < num && bit && !(den & (1LL << 63))) + while (den < num && bit && !(den & (1L << 31))) { den <<= 1; bit <<= 1;