From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by sourceware.org (Postfix) with ESMTPS id 54EEA3858D37 for ; Sun, 19 Nov 2023 04:03:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 54EEA3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 54EEA3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700366602; cv=none; b=nxnupETTTXWsIRZrDBmWOd61oWhM+y+/jnAgJcGTuBGsOEPh4IZMxZxn7+491FFfvu0PV5x6Pi7Rrud3PuwQZCzO6yUSSv37Xx3HcG/r6opVNz2s1lZAOcYKeIDEslykUHqrDIOeO6afwi2pCON4BmrnnWZ+we05/YRpQ0sIDI4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700366602; c=relaxed/simple; bh=RkjzZXHB14REXMP7EjsUgz7WcSbcnw/eyHMWP8Q969k=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=XNO+INuibnSUAMwydRm6LqvKdnq6IMnXa7LqzS7DuoZue4G8OPLx3l0ZmbptpEdDuwFSwp7YR1AP7L6M2K63aRGERGhJcwwmSYst8THkLXogD9Zrfgm5/ir8E3rXCLuUmZ8nZMpvz/Xv3yEVgAqpiGLAnFrVoTEzDCbvfqoSWUA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-1f573a9ed69so1910951fac.1 for ; Sat, 18 Nov 2023 20:03:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700366600; x=1700971400; darn=gcc.gnu.org; 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=5HNyVSTJsCC39N3F+I1sXDGNtSZugHYR+zm0XpnAxCU=; b=nsum40n1CmCMGDPTbcNhwGrFj+Le0uM5jDSraFRhSdV9fOjogLdOTa1l1ZSoGWyXPe qsVX2XcKGS0LJEGuFohuaeL0sQPemhUAGUFFxlQfduz5FuZKj6KiNaKk5DGM7ZyxSWYT N0AGrC1gRCl1i+Gg5/eWlLwFL+52wOhTMn819zWganvuIjC8e+aGxO4ZGS/uFwf/EU+x jMxFS2lTWm7qBMTL43Vj/Ex7gCWXIJDAQb6wmxHHPqi9d+65G5yKBUmLKOfAZBrUXeRo iefYRpVy3TJ3LczrBEur7zCr+8Qo7bNA79/zKx4KeklgoXEX6xQ+Sgic+6QMJD0oFaCY xzOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700366600; x=1700971400; 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=5HNyVSTJsCC39N3F+I1sXDGNtSZugHYR+zm0XpnAxCU=; b=rc+I3+R1KvENTnixWt1aweK5bJwPtxYH5vStmqsthVkIPgztAKvrgic3A+iVUaJz+T 835PuVL53Pcu/HHEywnR2yPWwC5fzcy+n7eYoUej8kkYiMZexku+4l90/KI6NCWssyXf SAEp1LP6UuL2a2hc/0xVqN3fNB4HyshxCp6F8+OZk1WZwm1wv2+X6KKpF7ySa1l6d4uD IXvxEZNit/aTyOTHMedLf3Fm49Nmnin3W0tVzIhlnIuW1+2YX9TUt5zMS1ds7yQlYcH7 mcygETJxE2x3cMsb75mDkb5rZGeJjY8/l2D0ew0f7VDiIDDeigiSvhc8bO1PElXUxZug 8LzA== X-Gm-Message-State: AOJu0YxkBXOkPO2pGzzQdKppysiuxEq3QMlfX2Mxl5BOo6MAPdh2d1Do kKWeeKfU8/MsEAGXUqWEKxg= X-Google-Smtp-Source: AGHT+IFSTHP3UfYfRMHl/fVxNLvfBNfKgwNFepz2Uk/kuWoJuLaXYeqo4Qs1R838qdCEMMzpAGailw== X-Received: by 2002:a05:6870:cb4a:b0:1ea:809c:3eb with SMTP id oz10-20020a056870cb4a00b001ea809c03ebmr4563423oab.44.1700366600550; Sat, 18 Nov 2023 20:03:20 -0800 (PST) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id tp12-20020a0568718b8c00b001d4c5e4c2c5sm856288oab.25.2023.11.18.20.03.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 18 Nov 2023 20:03:20 -0800 (PST) Message-ID: <8c954624-1f07-456e-9a1d-7302e82375ab@gmail.com> Date: Sat, 18 Nov 2023 21:03:19 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] tree-ssa-math-opts: popcount (X) == 1 to (X ^ (X - 1)) > (X - 1) optimization for direct optab [PR90693] Content-Language: en-US To: Jakub Jelinek , Richard Biener Cc: gcc-patches@gcc.gnu.org References: From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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 11/18/23 03:27, Jakub Jelinek wrote: > Hi! > > On Fri, Nov 17, 2023 at 03:01:04PM +0100, Jakub Jelinek wrote: >> As a follow-up, I'm considering changing in this routine the popcount >> call to IFN_POPCOUNT with 2 arguments and during expansion test costs. > > Here is the follow-up which does the rtx costs testing. > While having to tweak internal-fn.def so that POPCOUNT can have a custom > expand_POPCOUNT, I have noticed we are inconsistent, some DEF_INTERNAL* > macros (most of them) were undefined at the end of internal-fn.def (but in > some cases uselessly undefined again after inclusion), while others were not > (and sometimes undefined after the inclusion). I've changed it to always > undefine at the end of internal-fn.def. > > Ok for trunk if it passes bootstrap/regtest? > > 2023-11-18 Jakub Jelinek > > PR tree-optimization/90693 > * tree-ssa-math-opts.cc (match_single_bit_test): Mark POPCOUNT with > result only used in equality comparison against 1 with direct optab > support as .POPCOUNT call with 2 arguments. > * internal-fn.h (expand_POPCOUNT): Declare. > * internal-fn.def: Document missing DEF_INTERNAL* macros and make sure > they are all undefined at the end. > (DEF_INTERNAL_INT_EXT_FN): New macro. > (POPCOUNT): Use it instead of DEF_INTERNAL_INT_FN. > * internal-fn.cc (lookup_hilo_internal_fn, lookup_evenodd_internal_fn, > widening_fn_p, get_len_internal_fn): Don't undef DEF_INTERNAL_*FN > macros after inclusion of internal-fn.def. > (DEF_INTERNAL_INT_EXT_FN): Define to nothing before inclusion to > define expanders. > (expand_POPCOUNT): New function. > > + unsigned cmp_cost = seq_cost (cmp_insns, speed_p); > + if (popcount_cost < cmp_cost) > + emit_insn (popcount_insns); > + else > + { > + emit_insn (cmp_insns); > + plhs = expand_normal (lhs); > + if (GET_MODE (cmp) != GET_MODE (plhs)) > + cmp = convert_to_mode (GET_MODE (plhs), cmp, 1); > + emit_move_insn (plhs, cmp); > + } Did you want <= for the test to use popcount? That seems like a better choice in that scenario to me as the popcount is likely smaller. OK for the trunk as-is or using a <= test. jeff