From patchwork Sat Nov 20 08:20:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 47963 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 3791C385840D for ; Sat, 20 Nov 2021 08:20:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3791C385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637396439; bh=mz/6mUqgHjvKzRcdokQji/hmiXX3sk2wYJA/qXOvq3I=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=wjPyBh6VURc7/d2ox3t8jk2Lem815LDIKbn0K61HWo5C6XTMYErVSotyXIo/kKV+g kwrMlO1wOmw6pfLtYphFK/adT6WeorU4xsOqsCACmWw8QzoLaHuNfkZ81Ut5yr7CBH uSqMzwt5qJN4ajMpd19Z47/lnrvjHId8ge8bFAOI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 7B7553858D3C for ; Sat, 20 Nov 2021 08:20:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7B7553858D3C Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-395-_kZRyfklNiOf3MKyTzj9RQ-1; Sat, 20 Nov 2021 03:20:07 -0500 X-MC-Unique: _kZRyfklNiOf3MKyTzj9RQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A9A2A102CB73; Sat, 20 Nov 2021 08:20:06 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3994660862; Sat, 20 Nov 2021 08:20:06 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 1AK8K3jq2606279 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 20 Nov 2021 09:20:03 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 1AK8K2xn2606278; Sat, 20 Nov 2021 09:20:02 +0100 Date: Sat, 20 Nov 2021 09:20:02 +0100 To: Uros Bizjak Subject: [PATCH] i386: Fix up handling of target attribute [PR101180] Message-ID: <20211120082002.GX2646553@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! As shown in the testcase below, if a function has multiple target attributes (rather than a single one with one or more arguments) or if a function gets one target attribute on one declaration and another one on another declaration, on x86 their effect is not combined into DECL_FUNCTION_SPECIFIC_TARGET, but instead only the last processed target attribute wins. aarch64 handles this right, the following patch follows what it does, i.e. only start with target_option_default_node if DECL_FUNCTION_SPECIFIC_TARGET is previously NULL (i.e. the first target attribute being processed on a function) and otherwise start from the previous DECL_FUNCTION_SPECIFIC_TARGET. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2021-11-20 Jakub Jelinek PR c++/101180 * config/i386/i386-options.c (ix86_valid_target_attribute_p): If fndecl already has DECL_FUNCTION_SPECIFIC_TARGET, use that as base instead of target_option_default_node. * gcc.target/i386/pr101180.c: New test. Jakub --- gcc/config/i386/i386-options.c.jj 2021-11-19 12:48:56.507415161 +0100 +++ gcc/config/i386/i386-options.c 2021-11-19 13:04:31.618044781 +0100 @@ -1443,8 +1443,11 @@ ix86_valid_target_attribute_p (tree fnde /* Initialize func_options to the default before its target options can be set. */ + tree old_target = DECL_FUNCTION_SPECIFIC_TARGET (fndecl); + if (old_target == NULL_TREE) + old_target = target_option_default_node; cl_target_option_restore (&func_options, &func_options_set, - TREE_TARGET_OPTION (target_option_default_node)); + TREE_TARGET_OPTION (old_target)); /* FLAGS == 1 is used for target_clones attribute. */ new_target --- gcc/testsuite/gcc.target/i386/pr101180.c.jj 2021-11-19 13:24:19.334132937 +0100 +++ gcc/testsuite/gcc.target/i386/pr101180.c 2021-11-19 13:23:56.676454806 +0100 @@ -0,0 +1,12 @@ +/* PR c++/101180 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mno-avx -mno-crc32" } */ + +#include + +__attribute__((target ("avx"))) __attribute__((target ("crc32"))) void +foo (__m256 *p, unsigned int *q) +{ + __m256 c = _mm256_and_ps (p[0], p[1]); + *q = __crc32b (*q, 0x55); +}