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 907DB385DDC6 for ; Tue, 25 Jun 2024 16:10:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 907DB385DDC6 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 907DB385DDC6 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719331861; cv=none; b=rdBJ75ZNZlRFdIn0radCnWJanCbEM1OTHe7xO3e+vCcIh5od9gfR6/etVpNSgkQ6tIY73M0ZZiZQe9wN9Q4ip9cZM1lLXf35yRODl5hzE9YSZHFFrOPZ9b4lL/RgP7KtU565kF/3n9uugKuF2KXFxdhDK0fHX3N7ardwC35Zj24= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719331861; c=relaxed/simple; bh=JMLqzXAoVBQ+BCaZBVvyo6AmmGfqsm7p7MsZeO0vd1I=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=YcXMwtx8WN7UjOCQWefiF09f1P3955uMtLZB6PU3kaqLnl2a4Y0QZhdPZoKZNbLMBWVvYtiR2aDMMca9mlYjH/PTEiRhqEfUpWhPXXBDGSNtzafCtR+HO2wD/iAno3nM2IX8kwgo09K7//djDffUTWFWL1O2jfSkevfQl9suugs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719331858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qgCBJK5+zIrqCo8q7E7ogWmMYgZVNKpKltXPcMPR6Sk=; b=WEgd7/ZHRT1ifHsxLJlgBngRs7wLYxH6g5rJbfSfUHB2QDS/YZ/nR4uNnKWeUoefdXdZlb 8nxUA2Htv0xJti9VKhMwewR77I+kJaHrcQ5brfDOSt6+ZCUQAxs73eOCSVjkWmo3gM3S2y xtMjgbbNnsk3vSvucJXoo8lS/GBIfME= Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-BvKP6ozmMpenbBRV3CCxrQ-1; Tue, 25 Jun 2024 12:10:56 -0400 X-MC-Unique: BvKP6ozmMpenbBRV3CCxrQ-1 Received: by mail-ot1-f70.google.com with SMTP id 46e09a7af769-700b3896211so4195473a34.3 for ; Tue, 25 Jun 2024 09:10:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719331856; x=1719936656; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qgCBJK5+zIrqCo8q7E7ogWmMYgZVNKpKltXPcMPR6Sk=; b=Xd9zdvorjMJ5XV74wdJk7SBNRAMIvwJHQ8VTOHzoPux7jw+YuhGqhcvXPwBZ5JKwOR 6ZCnTf8sMBFFu/kZ+E8xobjTalvlIwB2rGmG9Le+8/PRzG1Bc2aaBWd1CwyL4RNpuW0y e0NcdHjTTiUZm8itmekzNTJT95ucVTPzMReqg7Xc9hEiFwmiw+CgS1noA+cscgxTyuYp ugcgg75+yHPRAqqojyc5fbq6vxDZMdczE11+Ij2KVNAz+LZSBgpm3zBdAAzFu2SePq1Z msdH+xHqHRZ3UCnB1wjT3pJYIGDNi5SohqeHsFdkIn9pOfR1IG9oJQijCspuGhYTrgN0 NGrA== X-Forwarded-Encrypted: i=1; AJvYcCUAkPImRt5XX0Hhjwk0hF0KOa74YCkA0gAcIMMoAk2pcBdlUKj8V5stdfUO34fwpAZLeZbjErWrfu1ptWAGJC6+4o6bLthtKw== X-Gm-Message-State: AOJu0YzO2VorjQwIF7jcP2NU6ByNHFo+d72eeAR7+oFz9cqbAbnwfY9h ZneAgeGHhSW+8pDur61IsrLmW4yX1blTxU+gEaSciYcp4bht4fU8pg2P+H6yQL29sUONgdoTQ2R 150kPDB540HZlANEW8kTCi96anersASNOhBYG2g/vxTT9RMFBHfKhOqg= X-Received: by 2002:a05:6830:2693:b0:6f9:6299:1175 with SMTP id 46e09a7af769-700af9343c1mr10786464a34.13.1719331855799; Tue, 25 Jun 2024 09:10:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGc7mSvIr1ZBsMXkeWnP0lDx5wH598d23fdQFN/aoR76IR5C8QyzTFIUrX/SnTHp70JC5cibw== X-Received: by 2002:a05:6830:2693:b0:6f9:6299:1175 with SMTP id 46e09a7af769-700af9343c1mr10786432a34.13.1719331855377; Tue, 25 Jun 2024 09:10:55 -0700 (PDT) Received: from [192.168.1.130] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79c082c7433sm54548685a.53.2024.06.25.09.10.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Jun 2024 09:10:54 -0700 (PDT) Message-ID: <54838cdd-21ef-4eb1-9f8c-e94a469bdca3@redhat.com> Date: Tue, 25 Jun 2024 12:10:53 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH][c++ frontend]: check for missing condition for novector [PR115623] To: Tamar Christina , gcc-patches@gcc.gnu.org Cc: nd@arm.com, nathan@acm.org References: From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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: On 6/25/24 04:01, Tamar Christina wrote: > Hi All, > > It looks like I forgot to check in the C++ frontend if a condition exist for the > loop being adorned with novector. This causes a segfault because cond isn't > expected to be null. > > This fixes it by issuing the same kind of diagnostics we issue for the other > pragmas. > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > Ok for master? and backport to GCC-14? Hmm, I'm not sure we want to error in this case; it's pointless, but indeed we aren't going to vectorize a loop that always loops. I'd think we should treat it the same as an explicit "true" condition. And perhaps the same for unroll/ivdep. Does the C front-end treat the null condition different from a constant true condition? > Thanks, > Tamar > > gcc/cp/ChangeLog: > > PR c++/115623 > * parser.cc (cp_parser_c_for): Add check for C++ cond. > > gcc/testsuite/ChangeLog: > > PR c++/115623 > * g++.dg/vect/vect-novector-pragma_2.cc: New test. > > --- > diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc > index e7409b856f1127e303c6515a3bb2d61a10e7c378..24d7b0e4992fdff69951ac5955f304e473f53374 100644 > --- a/gcc/cp/parser.cc > +++ b/gcc/cp/parser.cc > @@ -14107,6 +14107,12 @@ cp_parser_c_for (cp_parser *parser, tree scope, tree init, bool ivdep, > "% pragma"); > condition = error_mark_node; > } > + else if (novector) > + { > + cp_parser_error (parser, "missing loop condition in loop with " > + "% pragma"); > + condition = error_mark_node; > + } > finish_for_cond (condition, stmt, ivdep, unroll, novector); > /* Look for the `;'. */ > cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON); > diff --git a/gcc/testsuite/g++.dg/vect/vect-novector-pragma_2.cc b/gcc/testsuite/g++.dg/vect/vect-novector-pragma_2.cc > new file mode 100644 > index 0000000000000000000000000000000000000000..05dba4db1c6544bc53cd05482d1b2e767052cf43 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/vect/vect-novector-pragma_2.cc > @@ -0,0 +1,10 @@ > +/* { dg-do compile } */ > + > +void f (char *a, int i) > +{ > +#pragma GCC novector > + for (;;i++) > + a[i] *= 2; > +} > + > +/* { dg-error "missing loop condition in loop with 'GCC novector' pragma before ';' token" "" { target *-*-* } 6 } */ > > > >