Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp32897pxj; Thu, 20 May 2021 03:57:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw22n2bGXgeQ1YdyHu6J8LVHd3e8hxQnyPxy4+U2fWjv8O0M+Y0pr0KKXOU5GLB6oadYDLk X-Received: by 2002:a05:6402:1ac7:: with SMTP id ba7mr4397345edb.299.1621508274951; Thu, 20 May 2021 03:57:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621508274; cv=none; d=google.com; s=arc-20160816; b=A3uuunLJy36dkZ4yKFzbhbyjSfEYKEf738gBoyuc+OziB7seOhirMd6UdT+gucZ0Au sLI0P4SST0DFMS04zu14KYR9A92or3lC0TjfyPq534MCO23ej0XpRDIrUWiNnaIcrjlD GnPWqJZbAUOuy9ZsZUnkNHs/7LVE3EFKeVy+RY984Q2U5CKt7My+sSOdanZCyVz17Niv GISr6UM4sdzDESDK9N42ptnun5IYd3GpP1YPFqXw9xiMIR7A+t5J8zlWNWANnsUZx+Os fDOP06W1B474f9BGuKd7Uq2ONsi5WQiYTOSWYpOg2GpUVFfahRGp7ZhN7rp7mj+cb8Nx vkVg== 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=TP6xncWIUjBYkDSQ2IVhNFQVtspoGhrK5kZre+fipcpIcDHePBSzaL63Yta45ru2Py xsAcCHEogaFkLL33vaEw3M0umA20kVCeRxqxIORht6NqEJc4+S671iHQF0x07sccD5n9 zjXVMI90POAhNrhj+qxxGhUFWX4VFyATgqK3CZ5pTh9UkO35UlsyhDyf+lQSuZ9cF4U1 agS5o48YIzCGf+3t/r/nRmvqDlGWTYYHwTqo5tMm2cC1SkAGoQ9Fo2fJYU/v4LvClHjF dScf+QFDW1xENX+yf87o5ol+ZGNpGl8j8GC16XcNRtUS5rZQ8R1IIi93CvGPeEtHGeNJ K6WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wt6rtNO5; 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 n2si2204011edi.195.2021.05.20.03.57.30; Thu, 20 May 2021 03:57:54 -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=wt6rtNO5; 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 S238326AbhETK4R (ORCPT + 99 others); Thu, 20 May 2021 06:56:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:43962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237363AbhETKks (ORCPT ); Thu, 20 May 2021 06:40:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 45280613F7; Thu, 20 May 2021 09:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504547; bh=7oYuLHNwzc9jy8+tx7Q4sSHTjfKDMdJFbkcaYmc36R8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wt6rtNO53EfDdl6rcL7GB4hGEPpt2MXToREy5k679TRROcJxJQPjZSGFZUxGiRV3O 2O5dc41MySFcCFiLIrtZqXk7il01Ay9NfH436sMTh9xG77IJWyCg+sR+Kfd4F9XZ3e HvZJJpSsvnSdSEQXRVYie4Wq8iaKqLvw+7er8lho= 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.14 295/323] MIPS: Avoid DIVU in `__div64_32 is result would be zero Date: Thu, 20 May 2021 11:23:07 +0200 Message-Id: <20210520092130.318513588@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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)); \