From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id 9C47A382F864 for ; Tue, 28 Jun 2022 15:38:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9C47A382F864 Received: from [10.10.3.121] (unknown [10.10.3.121]) by mail.ispras.ru (Postfix) with ESMTPS id 3F07E40D403D; Tue, 28 Jun 2022 15:38:25 +0000 (UTC) Date: Tue, 28 Jun 2022 18:38:25 +0300 (MSK) From: Alexander Monakov To: Adonis Ling cc: gcc-help@gcc.gnu.org Subject: Re: Why does different types of array subscript used to iterate affect auto vectorization In-Reply-To: Message-ID: <3b44a272-447c-28d7-678d-5968df7ec248@ispras.ru> References: <3eb44329-3b12-896c-14c4-3473d43aed3d@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Jun 2022 15:38:31 -0000 On Tue, 28 Jun 2022, Adonis Ling via Gcc-help wrote: > > Here the main problem is '*array' and 'nread' have the same type, so they > > might overlap. Ideally the compiler would recognize that that cannot happen > > because it would make 'array[nread++] = i' undefined due to unsequenced > > modifications, but GCC is not sufficiently smart (yet). The secondary issue > > is the same as below: > > > > I got your point. > > After that, I tried to add __restrict__ to nread as the following shows and > GCC still doesn't optimize it. As I said, there's a secondary issue even if you add 'restrict'. Alexander