From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by sourceware.org (Postfix) with ESMTPS id 9A564398E47F for ; Wed, 12 May 2021 15:11:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9A564398E47F Received: by mail-qk1-x72d.google.com with SMTP id l129so22481010qke.8 for ; Wed, 12 May 2021 08:11:33 -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:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=d7CEyJavf6inLg9vFbWmRkkZ5xWkj8z0dkBiKxXgLOI=; b=qhMNlY/4q6PTX9dhGArxcPKTQ6AdL398A+QffXGuebDfLbS9qdk5X0+ClAnLTDQH0+ OLeuFCVWWiSj+2Tyi01TzKdMDiO83O9LWySn0etyqcyyNp9x99hG5Z5FgCNBB1FU3N6/ 2kPa/WML0CLAoHHk3qnsKukRaw70N2qdp11h8/KWAlsrqroFo6F3ro3ofg2af+Folp80 F7WVs6/pIbX8bL67KQU58LlGr+1TRpgJd9xDvdat3Uo6ns6AKQSsJZvqrhjKbjCESANt 6aLsOBLZC8N0WPMUq7ox/tq2zrFrYURn3J/2b+2vu0muovUdVQqf22H/HJsqcteduyT3 MxOQ== X-Gm-Message-State: AOAM533bZdPCA1ly5A3V5kaiQoGfNsCX2vQSVOCWqWOcmkkDgpoG/0Vt 7fuLkwk4ZKi71Qd/fsby5HRprVrykhQ= X-Google-Smtp-Source: ABdhPJxZ2VD2OFywrfwxOAAN+C2+OpX3KHJR+kkgBtHSGPFcJqDI5BMB5+wJsUkTI/DPKU7ZmHZ+iQ== X-Received: by 2002:a05:620a:2f9:: with SMTP id a25mr21963297qko.401.1620832293187; Wed, 12 May 2021 08:11:33 -0700 (PDT) Received: from [192.168.0.41] (71-218-14-121.hlrn.qwest.net. [71.218.14.121]) by smtp.gmail.com with ESMTPSA id d10sm150333qtq.55.2021.05.12.08.11.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 May 2021 08:11:32 -0700 (PDT) Subject: Re: [PATCH 2/2] c/100547 - reject overly large vector_size attributes To: Richard Biener , gcc-patches@gcc.gnu.org Cc: joseph@codesourcery.com References: From: Martin Sebor Message-ID: <31eab2a7-a6f9-9b3b-b43e-f0f7deab8f9c@gmail.com> Date: Wed, 12 May 2021 09:11:31 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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, 12 May 2021 15:11:35 -0000 On 5/12/21 2:47 AM, Richard Biener wrote: > This rejects a number of vector components that does not fit an 'int' > which is an internal limitation of RTVEC. > > This regresses gcc.dg/attr-vector_size.c which checks for much larger > supported vectors. Not sure what to do about this - I'll also note > the RTVEC limitation is a host specific limitation (unless we change > this 'int' to int32_t). > > Bootstrapped and tested on x86_64-unknown-linux-gnu with the above > mentioned regression. > > Any comments? Just a few minor ones. > > Thanks, > Richard. > > 2021-05-12 Richard Biener > > PR c/100547 > gcc/c-family/ > * c-attribs.c (type_valid_for_vector_size): Reject too large nunits. > > * gcc.dg/pr100547.c: New testcase. > --- > gcc/c-family/c-attribs.c | 10 ++++++++++ > gcc/testsuite/gcc.dg/pr100547.c | 35 +++++++++++++++++++++++++++++++++ > 2 files changed, 45 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/pr100547.c > > diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c > index c1f652d1dc9..60bcfa22df1 100644 > --- a/gcc/c-family/c-attribs.c > +++ b/gcc/c-family/c-attribs.c > @@ -4252,6 +4252,16 @@ type_valid_for_vector_size (tree type, tree atname, tree args, > return NULL_TREE; > } > > + if (nunits >= (unsigned HOST_WIDE_INT)INT_MAX) The inequality includes INT_MAX, so the phrasing below doesn't exactly match the condition. Since nunits must be a power of 2 the condition might as well be greater than. > + { > + if (error_p) > + error ("number of components of the vector exceeds %d", INT_MAX); "number of vector components" sounds better (though there are other messages that use this phrasing already). Especially since it's computed, I would suggest to mention the value of nunits in the message (it should also be mentioned in the "power of two" message). Martin > + else > + warning (OPT_Wattributes, > + "number of components of the vector exceeds %d", INT_MAX); > + return NULL_TREE; > + } > + > if (ptrnunits) > *ptrnunits = nunits; > > diff --git a/gcc/testsuite/gcc.dg/pr100547.c b/gcc/testsuite/gcc.dg/pr100547.c > new file mode 100644 > index 00000000000..92f34bf974f > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pr100547.c > @@ -0,0 +1,35 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O -g" } */ > + > +typedef int __attribute__((vector_size( > + ((((((((((((((((((((((((((((((8 * sizeof(short)) * sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)) * > + sizeof(short)))) V; /* { dg-error "number of components" } */ > +void k() { V w = { 0 }; } >