Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8363743ybl; Thu, 16 Jan 2020 15:23:54 -0800 (PST) X-Google-Smtp-Source: APXvYqxyyw5OhJm84dU4VOOiUJlpC6Fd6DiGVHciMordtOxoNkOMkgQsVR6Fu99MQ7hoku82LbFv X-Received: by 2002:a9d:4805:: with SMTP id c5mr4179736otf.292.1579217034489; Thu, 16 Jan 2020 15:23:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579217034; cv=none; d=google.com; s=arc-20160816; b=i2R/V4/mYAsMMwOENdLwJgdRvsJNvGIzIT1qCB88tIOaSa2fPB+LNheFppEA2Pq9ls N8+0f3RgKINlTO6DmwNcorSXarvOVu+jnEjRRnRYhmJf8/I6fvQduQ7pudBHuj3q+NyO UBPWeG8Q2fViwnQ5Ef+A+qFA63LN4m/P/0KeZVhrwNah0H/+iw8zgE5vNxfRVUO34eYe L1FdiIsEfGkFP0zwexutLiZkAeoFrvqLMt7n/Y3e4ZuIoelwRl6CL0k+0RwwVLmAUgYK OCbFDN9SaY9XjzdqSPrrZLNT3nL6F2LXRRUf1MjcAMDVxS7g+hKZwsbf/f68mb4uWUCf IS+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=FT7k/4QfYPSy+MIOQUdSEw7SdtCbCiotmVkPGKvs8DU=; b=0MxItLd22UCXxPRe+RlpmD+1r3EhtPl77m61At4FeHCv0EEsd3p4TRC9Myn3paOv7i kM7fZkstANqRigDCTKpVgQ83id7Euuz6WVkr+8oxEhSF8CSkFJtrsrV6cCHhJ/l/4WQm CjOu7rU3a6tmTgyN0QD070JL7IfD2oYVuDRiXAO1xAU6ExDsMXIs2nSQ+jRHXqSoxuNt 3VKwVV4piJXSAKAMRiTmRu4qoxeE9m1wJZsrMj6f9jiZCCT1nAJ3XAJFFilzREQojJq4 UfxGCzIw+ucQ1nsae1p2T04UUEmAcO8Vy/s2QVPSsHTpCGErvpDahag9Y7envoUJSYL9 yC+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZBNmytBW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l11si12653176oie.231.2020.01.16.15.23.42; Thu, 16 Jan 2020 15:23:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZBNmytBW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729587AbgAPTrw (ORCPT + 99 others); Thu, 16 Jan 2020 14:47:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:42752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729504AbgAPTrv (ORCPT ); Thu, 16 Jan 2020 14:47:51 -0500 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 219B1214AF for ; Thu, 16 Jan 2020 19:47:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579204070; bh=iWPOEPrLhN/0dUzUlwpw4/5CopjoSgUDgsorKgvcJmw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ZBNmytBWuC0U8dtoZhF+ykaCrw12X24OzwI/4jlMPsTBRD4Skon1q/5BmRHCR7j36 U0SG46PBe9dZfmajYfQMP3/t6SsA/c/cTCxLI/yJ5fRxBdrzdYEx5a5LO34zOO6yIp MHsX6faaZ9XilvurLWm/Gziak4DDpI+m16cZOi68= Received: by mail-wr1-f49.google.com with SMTP id z3so20428981wru.3 for ; Thu, 16 Jan 2020 11:47:50 -0800 (PST) X-Gm-Message-State: APjAAAU8zwKkbvKu0TJRIdlx5OyP8eibnXd0ctEC+v3/VOgyyUsG1EVN /h5XwuBuPQD/9oB+foYWiZZOQ4L6k8JbaklHcdBt9A== X-Received: by 2002:adf:ebc6:: with SMTP id v6mr4976488wrn.75.1579204068445; Thu, 16 Jan 2020 11:47:48 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Andy Lutomirski Date: Thu, 16 Jan 2020 11:47:36 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v4 10/11] lib: vdso: Allow arches to override the ns shift operation To: Christophe Leroy Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , nathanl@linux.ibm.com, Arnd Bergmann , Thomas Gleixner , Vincenzo Frascino , Andrew Lutomirski , LKML , linuxppc-dev , linux-arm-kernel , "open list:MIPS" , X86 ML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 16, 2020 at 9:58 AM Christophe Leroy wrote: > > On powerpc/32, GCC (8.1) generates pretty bad code for the > ns >>= vd->shift operation taking into account that the > shift is always < 32 and the upper part of the result is > likely to be nul. GCC makes reversed assumptions considering > the shift to be likely >= 32 and the upper part to be like not nul. > > unsigned long long shift(unsigned long long x, unsigned char s) > { > return x >> s; > } > > results in: > > 00000018 : > 18: 35 25 ff e0 addic. r9,r5,-32 > 1c: 41 80 00 10 blt 2c > 20: 7c 64 4c 30 srw r4,r3,r9 > 24: 38 60 00 00 li r3,0 > 28: 4e 80 00 20 blr > 2c: 54 69 08 3c rlwinm r9,r3,1,0,30 > 30: 21 45 00 1f subfic r10,r5,31 > 34: 7c 84 2c 30 srw r4,r4,r5 > 38: 7d 29 50 30 slw r9,r9,r10 > 3c: 7c 63 2c 30 srw r3,r3,r5 > 40: 7d 24 23 78 or r4,r9,r4 > 44: 4e 80 00 20 blr > > Even when forcing the shift with an &= 31, it still considers > the shift as likely >= 32. > > Define a vdso_shift_ns() macro that can be overriden by > arches. Would mul_u64_u64_shr() be a good alternative? Could we adjust it to assume the shift is less than 32? That function exists to benefit 32-bit arches. --Andy