Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1guRGk-00063j-FF for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Feb 2019 00:22:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1guRGi-0002Kr-R7 for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Feb 2019 00:22:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1guRGi-0002KH-Bk for pgsql-hackers@lists.postgresql.org; Fri, 15 Feb 2019 00:22:16 +0000 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1guRGe-0008LW-Mo for pgsql-hackers@lists.postgresql.org; Fri, 15 Feb 2019 00:22:15 +0000 Received: by mail-qt1-x842.google.com with SMTP id v10so9074291qtp.8 for ; Thu, 14 Feb 2019 16:22:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=CY/Jzb/1ZoYjBjzl/WZY4zT6e1jTCoc0rQoIOwmi8EE=; b=UsddFGdO4eYxDPKrRhrJSmtRXJRb8mLh9H1B4CGVz2ypodMatVrpNoa698VmzT8mvo pHpmM3RQpkZkbGOSyhQi+jxmqYzMN+4l08Oz1ADyIKDwU1J2IVqaHmsfGtZ9Pm4ECKUf 0gCnkXOpxYONX9woofl6qtXMgH1TnKUJifNnI2gnWNQa5rNdA4ILKctmGDaUeFZHeFqc DjSDyMa5ITjyQ+rN5/qAGkPyFDtPZcogg+VWg56l2ZD3mt52FBiiurU3JbMxZHT/ynhz MxEWlHng9ftH+z9B/9C3q42qQdU2w0t3HMDlbYihGEefro+mSJvCjwwfWTEBVYezLADk CeBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=CY/Jzb/1ZoYjBjzl/WZY4zT6e1jTCoc0rQoIOwmi8EE=; b=QHZCT4Z2Efkz9YbebcGm7urkZDb7zw8VdTsnLeiNEjVvPkyTyUvxmDABqX4zr8Hhqd x/T5kZxWE4i+j+1cI314t2QKNfu6+yDuJXVDIjGhtKu1GNijKmAwESBa/8M8p51juh9s QZwL7O9e25Vm+x8xk9lKNDbFy+qSwd0Fg7Y5tJKhAICu4hNWF7wrnyJsCmFB5IdBLUZS h4FUXVqp/bI2ayDR6jcDEQJk+nse4LBuJKImdHVknQHowP+SURKHMFuhQStRDF2cs29l rc7UHx+gKyoYhUTbTl2AKgZDEQU6AG17i4iGGx1jRVPR8RNpsT2bt4KHFaEbTDZx0Nl9 Fflw== X-Gm-Message-State: AHQUAuYZcEhSMEgaghDE0DChNQ5Ld2OpHJQSa69Ddj+Xznqox56GH5oX tsNlaGP1FzPYjMz278ntm8+UbA== X-Google-Smtp-Source: AHgI3IaMBrehUMRLz+uhPmJNIzH+5mbvmIvSGynk980Lyb5SQIEASF43F0SEQy50rISXlVWnYfcX2Q== X-Received: by 2002:ac8:2d85:: with SMTP id p5mr5528638qta.136.1550190131492; Thu, 14 Feb 2019 16:22:11 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id t2sm2185173qkh.60.2019.02.14.16.22.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 16:22:10 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id D82B7122639; Thu, 14 Feb 2019 21:22:08 -0300 (-03) Date: Thu, 14 Feb 2019 21:22:08 -0300 From: Alvaro Herrera To: Tom Lane Cc: Thomas Munro , Andrew Gierth , David Rowley , PostgreSQL Hackers Subject: Re: Using POPCNT and other advanced bit manipulation instructions Message-ID: <20190215002208.GA25042@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4022.1550185074@sss.pgh.pa.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Feb-14, Tom Lane wrote: > I think we need a clean test for __builtin_popcount(), and to be willing > to use it if available, independently of -mpopcnt. Then separately we > should test to see if -mpopcnt works, probably with the same > infrastructure we use for checking for other compiler flags, viz > > # Optimization flags for specific files that benefit from vectorization > PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-funroll-loops]) > PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-ftree-vectorize]) > + # Optimization flags for bit-twiddling > + PGAC_PROG_CC_VAR_OPT(CFLAGS_POPCNT, [-mpopcnt]) > # We want to suppress clang's unhelpful unused-command-line-argument warnings > > Then the correct test to see if we want to build pg_popcount.c (BTW, > please pick a less generic name for that) and the choose function > is whether we have *both* HAVE__BUILTIN_POPCOUNT and nonempty > CFLAGS_POPCNT. Yeah, this works. I'll post the patch tomorrow. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services