From patchwork Tue Aug 6 16:18:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 95390 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 73ABD3858429 for ; Tue, 6 Aug 2024 16:19:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id A7F6D385841E for ; Tue, 6 Aug 2024 16:19:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A7F6D385841E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ispras.ru ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A7F6D385841E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=83.149.199.84 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722961142; cv=none; b=ljlKfr/16TpenBMbq6VgatVgKz/cKGkkpNqV5ZkiNTjPOWq6MEK4k1mdYV5lQT4fBio/erk7ycDakKbO+U/4o28utucGRZrB4Mh30aD44FcWGHBcmxlWk8lC6MiF8bwzRg4FjFIgLoAGp8JuhiV6jm35gKMcHyIfFwoaUk4Brgc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722961142; c=relaxed/simple; bh=gBDJNEdEthdyBVR6aOwJfsv7cYJz+hTwqiHo7UvYaC8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=sdPwhf+3q/DYAXG+yPV1Gz/zvadIy/qO/O2X5Fg0fX3yE5a6A32p+mwNJrm9Sf4N6iJCHOOvIZ6Ovabyq4YuoX00PDrfJG+V1n5WwQK9DueihFarHjA9PlFLsVo0dtssLqO/vjCbRrPgBkGbPFHCUlUKroSCc8fxQcyZhSe92ZQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost.intra.ispras.ru (unknown [10.10.3.121]) by mail.ispras.ru (Postfix) with ESMTP id 7F18F40737C3; Tue, 6 Aug 2024 16:18:59 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 7F18F40737C3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1722961139; bh=ppv4tLQ4NGTf3fke+TfYNek594D8nnLTTObIrUJQ3qA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bngoc1gkTCEPDJnBrxHxNCDrqVtOXOm8Z3D9SvQGgy+Tcd93AdI+T8l9+t6aR0ElB x+8vWPyWd+SQW8voOSFwd0QrO3s9xnxoo3JCkx/XpytxJ5fo6udNWHCZLL8i/8mQoi 34CRxU50QcnkXVVV26IZ9fEafPhpF5mrhoUYa2r8= From: Alexander Monakov To: gcc-patches@gcc.gnu.org Cc: Andi Kleen , Alexander Monakov Subject: [PATCH 1/3] libcpp: configure: check for AVX2 instead of SSE4 Date: Tue, 6 Aug 2024 19:18:48 +0300 Message-Id: <20240806161850.18839-1-amonakov@ispras.ru> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-8.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org Upcoming patches first drop Binutils ISA support from SSE4.2 to SSSE3, then bump it to AVX2. Instead of fiddling with detection, just bump our configure check to AVX2 immediately: if by some accident somebody builds GCC without AVX2 support in the assembler, they will get SSE2 vectorized lexer, which is not too slow. libcpp/ChangeLog: * config.in: Regenerate. * configure: Regenerate. * configure.ac: Check for AVX2 instead of SSE4.2. * lex.cc: Adjust for changed config macro. --- libcpp/config.in | 6 +++--- libcpp/configure | 4 ++-- libcpp/configure.ac | 6 +++--- libcpp/lex.cc | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libcpp/config.in b/libcpp/config.in index 253ef03a3d..a0ca9e4df4 100644 --- a/libcpp/config.in +++ b/libcpp/config.in @@ -35,6 +35,9 @@ */ #undef HAVE_ALLOCA_H +/* Define to 1 if you can assemble AVX2 insns. */ +#undef HAVE_AVX2 + /* Define to 1 if you have the Mac OS X function CFLocaleCopyPreferredLanguages in the CoreFoundation framework. */ #undef HAVE_CFLOCALECOPYPREFERREDLANGUAGES @@ -210,9 +213,6 @@ /* Define to 1 if you have the `putc_unlocked' function. */ #undef HAVE_PUTC_UNLOCKED -/* Define to 1 if you can assemble SSE4 insns. */ -#undef HAVE_SSE4 - /* Define to 1 if you have the header file. */ #undef HAVE_STDDEF_H diff --git a/libcpp/configure b/libcpp/configure index 32d6aaa306..74af097620 100755 --- a/libcpp/configure +++ b/libcpp/configure @@ -9140,14 +9140,14 @@ case $target in int main () { -asm ("pcmpestri %0, %%xmm0, %%xmm1" : : "i"(0)) +asm ("vpshufb %ymm0, %ymm1, %ymm2") ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : -$as_echo "#define HAVE_SSE4 1" >>confdefs.h +$as_echo "#define HAVE_AVX2 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext diff --git a/libcpp/configure.ac b/libcpp/configure.ac index b883fec776..cfefb63552 100644 --- a/libcpp/configure.ac +++ b/libcpp/configure.ac @@ -197,9 +197,9 @@ fi case $target in i?86-* | x86_64-*) - AC_TRY_COMPILE([], [asm ("pcmpestri %0, %%xmm0, %%xmm1" : : "i"(0))], - [AC_DEFINE([HAVE_SSE4], [1], - [Define to 1 if you can assemble SSE4 insns.])]) + AC_TRY_COMPILE([], [asm ("vpshufb %ymm0, %ymm1, %ymm2")], + [AC_DEFINE([HAVE_AVX2], [1], + [Define to 1 if you can assemble AVX2 insns.])]) esac # Enable --enable-host-shared. diff --git a/libcpp/lex.cc b/libcpp/lex.cc index 1591dcdf15..fa9c03614c 100644 --- a/libcpp/lex.cc +++ b/libcpp/lex.cc @@ -344,7 +344,7 @@ search_line_sse2 (const uchar *s, const uchar *end ATTRIBUTE_UNUSED) return (const uchar *)p + found; } -#ifdef HAVE_SSE4 +#ifdef HAVE_AVX2 /* A version of the fast scanner using SSE 4.2 vectorized string insns. */ static const uchar *