From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 523103857738 for ; Wed, 26 Jul 2023 16:38:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 523103857738 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-pf1-x433.google.com with SMTP id d2e1a72fcca58-666e97fcc60so30627b3a.3 for ; Wed, 26 Jul 2023 09:38:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690389521; x=1690994321; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Y+SD8CCKhE6hWvCKXa5jpLyfv3QG1ej044WuwK0lAPc=; b=J0sexowudpMT7sLOemZKHdCOhl/iCF/qj24QeNk6gSsI4W5XY74csHNSfuJokYuhdy A7QKu6SMc/bi4i/ttAkYh6gG23F09iCkVAitEINIA3ptgeNc6fsNyKsHNO2n4eo1C8LM gEvLDsap3g0Vp0CB1WsHDJubid24b9cgBHij6DewFhdARXeCu5ImUFRl13cJOthZ3PiL qTBK0G+pcrCkAbqY90SG7PuAQ54NpwwT3NhRahEwxdIONO1n5ruN/ZrlVobAdeQ0hWYJ 6bVMb1s2YkkQ07R+wMFOTVSwbY6rjvJpfgoU5nay609IkSQ1+ou44yRuLBrpI314HTF6 aJAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690389521; x=1690994321; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Y+SD8CCKhE6hWvCKXa5jpLyfv3QG1ej044WuwK0lAPc=; b=WlUIVVXdt9k2gIjYaWaUyEt6/0RE7w4vfhQJCTKFvxAriYXYtZf3PHXlFCHsWzKrns K2tV0Q14irW8SzjKZ/1NkPyqmJH6fXi6YqxvllE4vsmspuSqodJQ6rfs9lD+u9i7u7bh IAH1qiD3EFOHxtf3uY2U1iHUnfcULO7IXOZHNA/n+kZO6bPNXFe5ttVfLENn75nI2wF+ YeRldZDcw3Y756LeaKWnJnI0R8kHKKyXoQzJLmxN7ZoHXW7JWcVmKqHZx5BA8bqo6cHy p5eB8YY6dDvm4nz76Ne9CeaNpT+a6mBEJfAKwwwt9pHSB2Yj9O39Tz8SD+/nn4zcNmV6 /hMg== X-Gm-Message-State: ABy/qLZtu19s8ZFFIfNq3cn4UeK03p2qz7+E+rfrszVD3UQnNqb1/4KO NCCgCILoI3A4v6UcCv2rnIcvFQ== X-Google-Smtp-Source: APBJJlFnKJM6q/CmcdAwGk8q7hIzYKzw9AGTgeNnn8nqiu6EOvXywG961iEbI72r9rPFfK3Tw9j6OQ== X-Received: by 2002:a05:6a00:17a9:b0:686:6fa8:2b0d with SMTP id s41-20020a056a0017a900b006866fa82b0dmr3101783pfg.4.1690389520882; Wed, 26 Jul 2023 09:38:40 -0700 (PDT) Received: from ?IPV6:2602:ae:1598:4c01:9456:37ab:20dc:17e1? ([2602:ae:1598:4c01:9456:37ab:20dc:17e1]) by smtp.gmail.com with ESMTPSA id q16-20020a62e110000000b00686eeaab7ecsm98013pfh.215.2023.07.26.09.38.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Jul 2023 09:38:40 -0700 (PDT) Message-ID: Date: Wed, 26 Jul 2023 09:38:38 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] x86_64: Optimize ffsll function code size. Content-Language: en-US To: Sunil K Pandey , libc-alpha@sourceware.org Cc: hjl.tools@gmail.com References: <20230726160524.1955013-1-skpgkp2@gmail.com> From: Richard Henderson In-Reply-To: <20230726160524.1955013-1-skpgkp2@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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 7/26/23 09:05, Sunil K Pandey via Libc-alpha wrote: > Ffsll function size is 17 byte, this patch optimizes size to 16 byte. > Currently ffsll function randomly regress by ~20%, depending on how > code get aligned. > > This patch fixes ffsll function random performance regression. > --- > sysdeps/x86_64/ffsll.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sysdeps/x86_64/ffsll.c b/sysdeps/x86_64/ffsll.c > index a1c13d4906..dbded6f0a1 100644 > --- a/sysdeps/x86_64/ffsll.c > +++ b/sysdeps/x86_64/ffsll.c > @@ -29,7 +29,7 @@ ffsll (long long int x) > long long int tmp; > > asm ("bsfq %2,%0\n" /* Count low bits in X and store in %1. */ > - "cmoveq %1,%0\n" /* If number was zero, use -1 as result. */ > + "cmove %k1,%k0\n" /* If number was zero, use -1 as result. */ This no longer produces -1, but 0xffffffff in cnt. However, since the return type is 'int', cnt need not be 'long long int' either. I'm not sure why tmp exists at all, since cnt is the only register modified. r~