From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id BC82C3851154 for ; Tue, 28 Jun 2022 15:47:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BC82C3851154 Received: by mail-ed1-x534.google.com with SMTP id e2so18212551edv.3 for ; Tue, 28 Jun 2022 08:47:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qpxi/PY/RRVvyvzZQ/UfBhQF0rOyt0o5APJ0BbLtTLc=; b=SyfhVe6EKd10l1/wfPX2ESdGi2e1Zh97MmhLbPCJtKH9T+/HXiscza18NBHIlVHa33 SUCW/ZyG5vqbo3NN7fL8w2NVezwvYIvAuJqC3YxpjwsXc1HDFb77hes/0kA5zmSYFZYV gQkUPc3jwmGTSOep9JqJ/E7Q2PDISKnpNcMuwAEIHqBKEs3skTOVioSH9t1D7hkLwSU6 ZqSr4EdeByHPZovN6byk5yPbeCRHpeDMoe6osV54gHf93ZhQy/VGTEaMJ65Hdr5ppb4x O4NV5DIT/HAzxPXZemkCXE8Oqz5xc3kHLBxy+RDuSvxqYNAyfd63lEIll/MeYE9FqEjT fKkA== X-Gm-Message-State: AJIora+wfGrZnX8ktnaJxEhPC/SxiOT8BR3zT4iNy+h6ZLRd2Oajp5iR Wh5Lhj6NQW+UwKQ/Jq/JSWTxGb79ryhWnsjjJMY= X-Google-Smtp-Source: AGRyM1v0bZrK2mlwFsvXMk46mKAnekiaX6eXZLoU67YZcfh+amMcFIu+ikxiK7y9N25yMAUUn3CSpjQzJP1N6uNNomU= X-Received: by 2002:a05:6402:4387:b0:435:94c6:716d with SMTP id o7-20020a056402438700b0043594c6716dmr24726482edc.298.1656431247563; Tue, 28 Jun 2022 08:47:27 -0700 (PDT) MIME-Version: 1.0 References: <3eb44329-3b12-896c-14c4-3473d43aed3d@ispras.ru> <3b44a272-447c-28d7-678d-5968df7ec248@ispras.ru> In-Reply-To: <3b44a272-447c-28d7-678d-5968df7ec248@ispras.ru> From: Adonis Ling Date: Tue, 28 Jun 2022 23:47:16 +0800 Message-ID: Subject: Re: Why does different types of array subscript used to iterate affect auto vectorization To: Alexander Monakov Cc: gcc-help@gcc.gnu.org X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, 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 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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:47:30 -0000 On Tue, Jun 28, 2022 at 11:38 PM Alexander Monakov wrote: > 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 > For the secondary issue, could I explain that Clang chooses to ignore it? -- Best regards, Adonis