From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id 680073858C74 for ; Thu, 13 Jul 2023 11:08:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 680073858C74 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-6b5d7e60015so494820a34.0 for ; Thu, 13 Jul 2023 04:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689246515; x=1691838515; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=zexhvhuJ2nprvru0IAIZ3p2zgflvebUtfyh+xYk7mS4=; b=FtvNqVROfU12+cgYW0qDMn4Y65ZlsKzfKTNM6tUyyBUXDC3m/1jNtV7zoOMC82ac63 fqtAvLDNvrKpf/2Stt6cOt2VWrpAEIvdayitHly3DLKlYO+OqRMOyGLuxIs5sNSsUzAl cztrrZNiU/jdfe2t3te9mg5TrTzVFIZ0btpJOn2wwPRYwfMqvQKmxYBAAm2k3AEtGLTP zrAQHgS+UbIgwub/8+ycojIBUloOnRVIs+FloTKRNpyO7rTQGKuP8N8Yz5vERXHAlruX pGtvp8QIcmnAjyiKmXJZruebgoTmjxp5TZ3uQHV9M6zTlUEnqacdX4gDd8cpRVa0x+aI 6/mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689246515; x=1691838515; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zexhvhuJ2nprvru0IAIZ3p2zgflvebUtfyh+xYk7mS4=; b=OczamgxX11wl03GIkdD3T3u62OpaGI/ZwhGxGgtAZpws33J8y7IPJMPJmcfg7CO7DQ CnXFWv6rR/YqXCJy/Er31wyiy1I+9J6pg8a4yP3bTd60WA32qNiMWQxM0jF27VScSP97 AHjUyS5QL95j+Xt1L8IANP2Fw8yZbE7ylDoEX81coaIt3aWb1evSp4oVWLXAhII5AEfZ pahtreHTHESIqDee5Q4WL4iWCoUqRyf51MFSSTfH/vYDDTjgo2pwSQ4g+Yxz35EE1/bH rNTfQ5DEPL8WEfq+pQRFOT5E6TbivUEmG+zIZOwrk5/eW73WKU12fIQiZ998p5eNWpik Pevg== X-Gm-Message-State: ABy/qLbXHTE9C/JYA785JzxU5MZtEZrlzVGdBtEN+81Wp2WDKU+KFqsn vnXzOu71OvlxZqMyJqfRyY4PEgx/HoHWE0WE/fyUIw== X-Google-Smtp-Source: APBJJlFVKNMmZDCqIigFFhtD/DXq7VYCqCF4IO/+sqDkpGH45/KjmFhTIHqc8h1S0IUYYb6eRRILfQ== X-Received: by 2002:a05:6870:8a2b:b0:1b0:1e3f:1369 with SMTP id p43-20020a0568708a2b00b001b01e3f1369mr1783002oaq.57.1689246515053; Thu, 13 Jul 2023 04:08:35 -0700 (PDT) Received: from [192.168.15.31] ([187.11.53.99]) by smtp.gmail.com with ESMTPSA id v13-20020a056870e28d00b001b3d5b06b6asm2926487oad.23.2023.07.13.04.08.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Jul 2023 04:08:34 -0700 (PDT) Message-ID: <9c33143c-c100-225e-0638-ac7a6291a261@linaro.org> Date: Thu, 13 Jul 2023 08:07:16 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v4 1/6] stdlib: Optimization qsort{_r} swap implementation (BZ 19305) To: Paul Eggert Cc: libc-alpha@sourceware.org References: <20230711190722.4028821-1-adhemerval.zanella@linaro.org> <20230711190722.4028821-2-adhemerval.zanella@linaro.org> <01eee84c-d5e6-a5a0-79be-e5b58ca6e541@cs.ucla.edu> Content-Language: en-US From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <01eee84c-d5e6-a5a0-79be-e5b58ca6e541@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 12/07/23 18:04, Paul Eggert wrote: > On 2023-07-11 12:07, Adhemerval Zanella via Libc-alpha wrote: >> +/* Returns true if elements can be copied using word loads and stores. >> +   The SIZE and BASE must be a multiple of the ALIGN.  */ >> +__attribute_const__ __always_inline >> +static bool >> +is_aligned (const void *base, size_t size, unsigned char align) >> +{ >> +  unsigned char lsbits = (unsigned char) size; >> + >> +  lsbits |= (unsigned char)(uintptr_t) base; >> +  return (lsbits & (align - 1)) == 0; >> +} > > Doesn't the following source code generate better machine code? It does for me, anyway (x86-64). Even if the code were the same, the simplicity would be a win. > >   static bool >   is_aligned (const void *base, size_t size, size_t align) >   { >     return (((uintptr_t) base | size) & (align - 1)) == 0; >   } > Ok. > >> +  if (is_aligned (pbase, size, sizeof (uint64_t))) >> +    swap_func = SWAP_WORDS_64; > > alignof not sizeof, in contexts like these that are talking about alignment not size. Indeed, I will fix it.