From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 88BFB385841D for ; Mon, 14 Nov 2022 07:48:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 88BFB385841D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668412128; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=v+eMMTNbY+U9aohzxk9ZIKWUQYZ1pL5L1HpCWcl84eQ=; b=K63cPPk0roR30hSf51XfBnvbLKG1xadwQGh8AsJUy77rvZ6Jx8jcW62IxdCF2oSbsgGdwO FG//CTpsDo+RVhUhTDqRbZHnx/wkwWqPi/rFtrB82IBg/G7FDsozTJYdnjQT8trXU/R+6Y l+6kUFf2eDc5p81x4INpqig0oTTamh4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-621-In_-65CsOQmyGpkORcuoTQ-1; Mon, 14 Nov 2022 02:48:45 -0500 X-MC-Unique: In_-65CsOQmyGpkORcuoTQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8561C185A78F; Mon, 14 Nov 2022 07:48:44 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 46651492B06; Mon, 14 Nov 2022 07:48:44 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 2AE7mdF02822429 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 14 Nov 2022 08:48:39 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2AE7mcpG2822428; Sun, 13 Nov 2022 19:48:38 -1200 Date: Sun, 13 Nov 2022 19:48:37 -1200 From: Jakub Jelinek To: Richard Biener , Jeff Law , Uros Bizjak Cc: gcc-patches@gcc.gnu.org, Florian Weimer , "H.J. Lu" Subject: [PATCH] libatomic: Handle AVX+CX16 AMD like Intel for 16b atomics [PR104688] Message-ID: Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 List-Id: Hi! Working virtually out of Baker Island. We got a response from AMD in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104688#c10 so the following patch starts treating AMD with AVX and CMPXCHG16B ISAs like Intel by using vmovdqa for atomic load/store in libatomic. Ok for trunk if it passes bootstrap/regtest? 2022-11-13 Jakub Jelinek PR target/104688 * config/x86/init.c (__libat_feat1_init): Revert 2022-03-17 change - on x86_64 no longer clear bit_AVX if CPU vendor is not Intel. --- libatomic/config/x86/init.c.jj 2022-03-17 18:48:56.708723194 +0100 +++ libatomic/config/x86/init.c 2022-11-13 18:23:26.315440071 -1200 @@ -34,18 +34,6 @@ __libat_feat1_init (void) unsigned int eax, ebx, ecx, edx; FEAT1_REGISTER = 0; __get_cpuid (1, &eax, &ebx, &ecx, &edx); -#ifdef __x86_64__ - if ((FEAT1_REGISTER & (bit_AVX | bit_CMPXCHG16B)) - == (bit_AVX | bit_CMPXCHG16B)) - { - /* Intel SDM guarantees that 16-byte VMOVDQA on 16-byte aligned address - is atomic, but so far we don't have this guarantee from AMD. */ - unsigned int ecx2 = 0; - __get_cpuid (0, &eax, &ebx, &ecx2, &edx); - if (ecx2 != signature_INTEL_ecx) - FEAT1_REGISTER &= ~bit_AVX; - } -#endif /* See the load in load_feat1. */ __atomic_store_n (&__libat_feat1, FEAT1_REGISTER, __ATOMIC_RELAXED); return FEAT1_REGISTER; Jakub