From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id 6E3343851C18 for ; Wed, 14 Apr 2021 20:24:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6E3343851C18 Received: by mail-pg1-x52c.google.com with SMTP id z16so15250266pga.1 for ; Wed, 14 Apr 2021 13:24:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=L0Pv1qy/pSCMcwLUR8xpKfqidzqL+xY+OAum83M7YMY=; b=qtagDYHFOyH/g53FIHUKlCkUFuJQJE5tpFxvLvB62cSxpmrnPhNT70oZtTxi3gLXIF OSHEzsXbzLFYCVdmbmTsCTOsFKxlPDFx2UwzzwuKGWmwEtlQCylkkoFGPnPRW2SsKZx5 iejitrEfax0fQBJRTrVsZlD3ugoWabDdxbPiXvRLpOlLl2w/3KhC7rpjcQ78Szwg0c4P xWPMdlnA1iA2dkYCWCMKJhrvxeBjL/1g70w53D/EI2YDLCaN6C/7ffV47dOhE3AhNMx8 GnTW8ptUbucR3GRMTdnCk4FsT6XSphvqa5/fOP4cBlxKp1Ws1hJwikJZuVLNyG0Coxi9 BaRA== X-Gm-Message-State: AOAM530LumQpAVX/sjFLD8ejXkQU+y5aGaIwEWUsSu0/icUTYHxvvoOz Q/5Z150+MEHunx4AX1FfQHI= X-Google-Smtp-Source: ABdhPJwUMK0fQL2jiRQPaAuyn369eqiOU7VQwGHu29Jxl0RMsRImvBY+vyFWUnHzvFEUbsbypcsQFA== X-Received: by 2002:a62:8804:0:b029:253:6745:908c with SMTP id l4-20020a6288040000b02902536745908cmr4342393pfd.16.1618431894599; Wed, 14 Apr 2021 13:24:54 -0700 (PDT) Received: from [192.168.1.29] (65-130-82-141.slkc.qwest.net. [65.130.82.141]) by smtp.gmail.com with ESMTPSA id c14sm243670pfj.46.2021.04.14.13.24.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Apr 2021 13:24:54 -0700 (PDT) Subject: Re: [PATCH] c: Don't drop vector attributes that affect type identity [PR98852] To: gcc-patches@gcc.gnu.org, joseph@codesourcery.com, polacek@redhat.com, richard.sandiford@arm.com References: From: Jeff Law Message-ID: <0ce30c95-7333-a677-a8be-a902b80f36eb@gmail.com> Date: Wed, 14 Apr 2021 14:24:53 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Wed, 14 Apr 2021 20:24:56 -0000 On 4/14/2021 9:32 AM, Richard Sandiford via Gcc-patches wrote: > types are distinct from GNU vector types in at least > their mangling. However, there used to be nothing explicit in the > VECTOR_TYPE itself to indicate the difference: we simply treated them > as distinct TYPE_MAIN_VARIANTs. This caused problems like the ones > reported in PR95726. > > The fix for that PR was to add type attributes to the > types, in order to maintain the distinction between them and GNU > vectors. However, this in turn caused PR98852, where c_common_type > would unconditionally drop the attributes on the source types. > This meant that: > > vector + vector > > had a GNU vector type rather than an vector type. > > See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96377#c2 for > Jakub's analysis of the history of this c_common_type code. > TBH I'm not sure which case the build_type_attribute_variant > code is handling, but I think we should at least avoid dropping > attributes that affect type identity. > > I've tried to audit the C and target-specific attributes to look > for other types that might be affected by this, but I couldn't > see any. We are only dealing with: > > gcc_assert (code1 == VECTOR_TYPE || code1 == COMPLEX_TYPE > || code1 == FIXED_POINT_TYPE || code1 == REAL_TYPE > || code1 == INTEGER_TYPE); > > which excludes most affects_type_identity attributes. The closest > was s390_vector_bool, but the handler for that attribute changes > the type node and drops the attribute itself (*no_add_attrs = true). > > I put the main list handling into a separate function > (remove_attributes_matching) because a later patch will need it > for something else. > > Tested on aarch64-linux-gnu, arm-linux-gnueabihf, armeb-eabi and > x86_64-linux-gnu. OK for trunk? The bug also occurs on GCC 10 branch, > but we'll need a slightly different fix there. > > Thanks, > Richard > > > gcc/ > PR c/98852 > * attribs.h (affects_type_identity_attributes): Declare. > * attribs.c (remove_attributes_matching): New function. > (affects_type_identity_attributes): Likewise. > > gcc/c/ > PR c/98852 > * c-typeck.c (c_common_type): Do not drop attributes that > affect type identity. > > gcc/testsuite/ > PR c/98852 > * gcc.target/aarch64/advsimd-intrinsics/pr98852.c: New test. OK Jeff