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: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-4.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 199401F487 for ; Sun, 29 Mar 2020 13:10:50 +0000 (UTC) Received: from localhost ([::1]:37516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIXiC-00027h-RX for normalperson@yhbt.net; Sun, 29 Mar 2020 09:10:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55737) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIXi9-00026Y-6V for bug-gnulib@gnu.org; Sun, 29 Mar 2020 09:10:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jIXi7-00067L-T3 for bug-gnulib@gnu.org; Sun, 29 Mar 2020 09:10:44 -0400 Received: from mail-il1-x131.google.com ([2607:f8b0:4864:20::131]:36602) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jIXi6-00061K-3Q for bug-gnulib@gnu.org; Sun, 29 Mar 2020 09:10:42 -0400 Received: by mail-il1-x131.google.com with SMTP id p13so13157785ilp.3 for ; Sun, 29 Mar 2020 06:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=FpO13MsQQmHy3QMAd7V9FIkJNkC9wOBKM69YLk/FxGw=; b=qgby/59ocFYXY1yb/TsWb/h+6ZFYh5Pc3fyIc8Zoj7fjsviFQv3PQQXDhHeb+eT2GF JzrC4n041P5JmjyiZ4Ynubc+uESBP3qpXqLIrsuWX7qyJIbnup0Mmf8W9w/T8wn9kw/y lI58S2lU6knwXnV3Uuv+J7x2WneT4kLkzNNakwoWOWJzSeHjWZCvtj7iLSCRJbxpjSe3 kgL6Z4M8uc5qlQRQpMwXPWaG+0jNLKHrB8BULjjbD5L9ZBwwZ5Z6lqUWGO9wSbl9MO0U 4ih6CfLptIi8Sq9YgkuUNYryWEtuJlf5N7LgdJHjPraByiHII4BfwwJMS4j77s+GekbV gOPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=FpO13MsQQmHy3QMAd7V9FIkJNkC9wOBKM69YLk/FxGw=; b=do8IeH5hP5ZjlgSSWvmArNKP/pau2hAVPsb4lU+JPJYUn6L+wQapNgo5A1QqnHNUew +PaW8nRBr+Cytxj9UMDW53kuAp9wb5Zyv1OyrQ1pVkCepjo2HKiUiv8bDO8CBClux74P VOetdfA0eMcm/1iSQq+HbjeLiSPW0T97Ds+NysXAKHlviR9Q3Rlt15u/MSV7TimUCxad srCLHBe4za/gA0i/3Di2oNTIreOWbuFWtIuslN8lKp3xa8EnH8YCtYgF5o8ubCsrkW76 Y6xNur8OhdvFNGtBvRdkvkorYZ/BE5vAzTCYBtjfszWPBBjX//FjoI8aQ+tK+RtozRUE isLQ== X-Gm-Message-State: ANhLgQ3v2mRwu3fZhJH6PrGVLRkBjPn3yhpHK5j2gIjvL9K8gmFST5GB Za1oWWToiMgzrSfOHrulcEWtrZuppGEWOwkZ/n6cyHyD/x0= X-Google-Smtp-Source: ADFU+vt2GZ0COAyEquopK0RwVhwAozS/OYpbn7Wgr2mDGyhEhuTsRCWaPeG5vKNZOMg/nqU+Ba/OQOWl8pV2mJdo150= X-Received: by 2002:a05:6e02:be7:: with SMTP id d7mr7371911ilu.238.1585487440025; Sun, 29 Mar 2020 06:10:40 -0700 (PDT) MIME-Version: 1.0 References: <36880643.fgSLelLy8r@omega> In-Reply-To: <36880643.fgSLelLy8r@omega> From: Jeffrey Walton Date: Sun, 29 Mar 2020 09:10:16 -0400 Message-ID: Subject: Re: test-bitrotate.c missing test cases To: Bruno Haible Content-Type: text/plain; charset="UTF-8" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::131 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: noloader@gmail.com Cc: bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" On Sun, Mar 29, 2020 at 8:53 AM Bruno Haible wrote: > > Hi Jeffrey, > > > It looks like test-bitrotate.c is missing test cases. It is missing > > the 32-bit rotl and rotr of 0-bits. > > > > The 0-bit rotate should tickle undefined behavior. > > > > If you want to clear the undefined behavior, then use this code. ... > > The functions are specified in bitrotate.h, e.g. like this: > > /* Given an unsigned 64-bit argument X, return the value corresponding > to rotating the bits N steps to the left. N must be between 1 and > 63 inclusive. */ > BITROTATE_INLINE uint64_t > rotl64 (uint64_t x, int n) > > I think it is on purpose that N = 0 and N = 64 are not allowed. Namely, > when N = 0 or N = 64, you would have a different, more efficient code > branch anyway. > > > It will be compiled down to a single instruction on platforms like IA-32. > > Yes, this is the intent. And we should help the compiler produce good > code, for example by adding statements like > assume (n > 0 && n < 64); > Allowing N = 0 or N = 64 goes backwards, because on some platforms it > will prevent the compiler from choosing the best possible instruction. Forgive my ignorance... No'oping 0 leaks timing information, and no'oping 64 is undefined behavior. (And in the current implementation No'oping 0 is also undefined behavior). Is that what is desired? I also don't think developers are going to write a rotate like: if (n != 0) x = rotr32(x, n); Or maybe, I have never seen a shift or rotate written like that. Jeff