From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_GMAIL_RCVD, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id B0DC61F453 for ; Thu, 24 Jan 2019 08:35:57 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-type; q=dns; s=default; b=lyJ7 bkdQtGD3D0hmmUUkeVhJ0GUlqrrfhnSFBzsjCqGdy7Tge8Dc6heaHeJTfYo5dAtS wk9sKXAO7WBLXTDle32PB7V/yn3Ht6jFgHKIP4P5nYs/4A5ciXno/EW66OMtVB34 QWZd4+42u3LG5pNx5MEVbh1G1vZEnClDozrZrvY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-type; s=default; bh=F7TnYepJsJ Gzd1WRk+XBk2+9l8Q=; b=vPEFtVCK5c65inzcJw8GvY/xMhX5ME2IfDjez3I8fl g3Lm/wjDX9ee5Vm6UuqWs1vTeZjsQUnwz9eSpash+QGXhBCMEXKywzoimwX8LBsy xqz5jQ7kSqgGImtOjT7Xsukrp1ZpF9LR6TLytjsiBWmPt+gmUUyQUuxMFlCVwRxX U= Received: (qmail 43746 invoked by alias); 24 Jan 2019 08:35:55 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 43732 invoked by uid 89); 24 Jan 2019 08:35:53 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-it1-f177.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=R+H4hSWtkeBofKAL3+P9Rqu8fsVI1yBi4N/3AXnUIOQ=; b=R4LDioGl+uKfBRFTbDHaurT2IJzt1P25VaY01VsajNZEMAFWuBPVlczA19SlIZk6Sk Mi8RAQUwQcx2A7s7YVzPDcGchZgPg8T3tp1+8PpG8XLMRJVBcQGMV7MpVeDfoG5obKZI GVqGBjXkGPDLjEgf3/cXloYJKaRbkwH0rGYlNBx7uv/QUq2B/PK+X70NwamEprGi2bbl Z/VnCPxeGxEnyNHnP1owGI23D9hwjoDCBAoXtBYz8M/w1H4xAHar/ZTMG+I+JueElujz XJAQ0oJsKydAhYBiy9SYALhXoWm15sZsXeHCAINXR0SUTQL2K9nTxTucpCJ/X51pn9gZ bvFw== MIME-Version: 1.0 References: <4b9fbc74-e05e-da71-5e8b-61af289a9f70@twiddle.net> In-Reply-To: <4b9fbc74-e05e-da71-5e8b-61af289a9f70@twiddle.net> From: Uros Bizjak Date: Thu, 24 Jan 2019 09:35:39 +0100 Message-ID: Subject: Re: [PATCH, alpha]: Fix sysdeps/alpha/remqu.S clobbering $f3 reg To: Richard Henderson Cc: libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" On Thu, Jan 24, 2019 at 9:23 AM Richard Henderson wrote: > > On 1/18/19 5:06 AM, Uros Bizjak wrote: > > Hello! > > > > Attached patch fixes sysdeps/alpha/remqu.S clobbering $f3 register via > > $y_is_neg path. There was missing restore of $f3 before the return > > from the function. > > > > The patch also reorders insns a bit, so it becomes similar as much as > > possible to divqu.S. > > > > Without the patch, math/big testcase from Go-1.11 testsuite (that > > includes lots of corner cases that exercise remqu) FAIL, with patched > > function, the testcase PASSes without problems. > > > > +++ b/sysdeps/alpha/remqu.S > > @@ -59,20 +59,19 @@ __remqu: > > subq Y, 1, AT > > stt $f0, 0(sp) > > and Y, AT, AT > > + excb > > + beq AT, $powerof2 > > > > stt $f1, 8(sp) > > - excb > > Why are you moving the excb above the powerof2 branch? > The path at powerof2 does not touch fpcr or issue fp insns. This was meant to unify the flow with the __divqu assembly, which does the above before calling DIVBYZERO. The idea was that __divqu is used much more than __remqu, so the later should do the same as the former. > > @@ -94,12 +93,12 @@ __remqu: > > mulq AT, Y, AT > > ldt $f0, 0(sp) > > ldt $f3, 48(sp) > > - lda sp, FRAME(sp) > > cfi_remember_state > > cfi_restore ($f0) > > cfi_restore ($f1) > > cfi_restore ($f3) > > cfi_def_cfa_offset (0) > > + lda sp, FRAME(sp) > > This change is actively wrong wrt the unwind info. Again, this will match __divqu assembly. It looks that __divqu needs to be fixed then. > > @@ -246,12 +247,16 @@ $y_is_neg: > > quotient must be either 0 or 1, so the remainder must be X > > or X-Y, so just compute it directly. */ > > cmpule Y, X, AT > > + excb > > + mt_fpcr $f3 > > subq X, Y, RV > > ldt $f0, 0(sp) > > + ldt $f3, 48(sp) > > cmoveq AT, X, RV > > > > lda sp, FRAME(sp) > > cfi_restore ($f0) > > + cfi_restore ($f3) > > cfi_def_cfa_offset (0) > > ret $31, (RA), 1 > > This appears to be the only change required to fix the bug. That is true. This part is the problematic part and clobbers $f3. Should I resend the patch only with this part fixed? > Can you walk me through why the other changes? As said above, I was trying to make __remqu like __divqu, but it looks that __divqu should be fixed in some places. Thanks, Uros.