Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp623922pxj; Thu, 20 May 2021 18:14:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwamBxofr2pKjKsfBBzAEHBnkXG6cHRHXvPsfBtbQLJs/WbXikShDFeyGXJHjX2MtSdJO+m X-Received: by 2002:a05:6402:883:: with SMTP id e3mr7850258edy.1.1621559644370; Thu, 20 May 2021 18:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621559644; cv=none; d=google.com; s=arc-20160816; b=QDJirlcxS7mAzLkYSl2sqB1pR9CkC5CCHP4oXiAd47AMeHHv7wF0y5lFX6Uw8NpN4P Q+eGP/75BT7xyR7LG8OyzK5CHld8b9tUgsgSZy7MH0tkkETuM81q3ucZrCHRUGs3eYuM qGd4i/papmtvAF5CS07MgJcRtc2n1qCzXHLD4nZ18INLbERrzLRshf/EQhSpfmndVq5u hc31UPTgHQxFAqmQXVu5h+scC/5bsavpD+F3YqjoVGdeIsrMaMbBsrqyy4sZF1EfsnQF 4fHdnodVV6cwSgS3wWq00omp5xTq3wQtJhzrTKR799cRcOpy9d+vtiBC14t+Ajgse+rO Q1dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=l3zXB7z1H35nnTT54pwXWfkMGkBdwPmSKjNio+Xf6No=; b=seuuhhih5Okh31hIoK4dtwBORTTgaG1jOJ84xCkMtiyH9YPFJ5Sr0IRA43cU67eJgo PXoTnzoYNET6YPAIY2ZvvVZbZSWdzu0Y06g9juiu6H2ql3vpOKDHpEyMyGu3VxVNVm32 M3Xsoh9SzCj6ShNpKCIuct6+l7Aieghtqa4Safe8hg5UcObY9X5BhmkYnyhg3GTc6x3Z 92/dsAEnxuc6otLiTm7zJqw1zfvHeB0qx+n9LlV5QQD5fHpb1jNcdMnllv+XicOzO+PR P/1vSrqEiaPx6kM4eNHJ39mFZ26enuPSynrznxfh1ZgcTxrzh2lRRFGZO9iY71G49y8T iR+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U3D2G5Aj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j19si1284681edj.231.2021.05.20.18.13.41; Thu, 20 May 2021 18:14:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U3D2G5Aj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241610AbhETLnk (ORCPT + 99 others); Thu, 20 May 2021 07:43:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:43922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240555AbhETLXD (ORCPT ); Thu, 20 May 2021 07:23:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 26B5161965; Thu, 20 May 2021 10:12:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505520; bh=7oYuLHNwzc9jy8+tx7Q4sSHTjfKDMdJFbkcaYmc36R8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U3D2G5AjFKBSLDfkLz/JzIyD/lePt22iflOk/zILuPU4LvXjY2NxFK28x1/dlozZc ANcPo1zm4PSxr9Clxun1mBCJU3Y6fUPRM4DtLozZWIvQFLxBueVEYvjMSOtNmuBdTh GKUjwQoYwVE8Ynb8xBUmonJpemKPhYHFuwmvY7Bg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Maciej W. Rozycki" , Thomas Bogendoerfer Subject: [PATCH 4.4 172/190] MIPS: Avoid DIVU in `__div64_32 is result would be zero Date: Thu, 20 May 2021 11:23:56 +0200 Message-Id: <20210520092107.856692195@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maciej W. Rozycki commit c1d337d45ec0a802299688e17d568c4e3a585895 upstream. We already check the high part of the divident against zero to avoid the costly DIVU instruction in that case, needed to reduce the high part of the divident, so we may well check against the divisor instead and set the high part of the quotient to zero right away. We need to treat the high part the divident in that case though as the remainder that would be calculated by the DIVU instruction we avoided. This has passed correctness verification with test_div64 and reduced the module's average execution time down to 1.0445s and 0.2619s from 1.0668s and 0.2629s respectively for an R3400 CPU @40MHz and a 5Kc CPU @160MHz. Signed-off-by: Maciej W. Rozycki Signed-off-by: Thomas Bogendoerfer Signed-off-by: Greg Kroah-Hartman --- arch/mips/include/asm/div64.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/arch/mips/include/asm/div64.h +++ b/arch/mips/include/asm/div64.h @@ -68,9 +68,11 @@ \ __high = __div >> 32; \ __low = __div; \ - __upper = __high; \ \ - if (__high) { \ + if (__high < __radix) { \ + __upper = __high; \ + __high = 0; \ + } else { \ __asm__("divu $0, %z1, %z2" \ : "=x" (__modquot) \ : "Jr" (__high), "Jr" (__radix)); \