From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1D17A3858414; Tue, 28 Nov 2023 07:43:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D17A3858414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701157397; bh=iRBGR8abt6HdQ4/lfGhZfhbaJd+bHzczS/wP+7+4a0w=; h=From:To:Subject:Date:From; b=slLQO8IJGzVBlHEm/vis3HgaSQoeHgyIz/tUEV0JF7pUvkPuKQ+Fvq10VkSh2BIjW Z+W4FjrJ28IMrk4oJkk4oCA3331RvczCon8rNM3pTZiBJjeWW/q4S20kqE/TyuZzXu lEm6DrwwqnYpHocYrMme+n5ae1IHsnjUT8YUt/bc= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/112742] New: missed vectorization with src[a*b+i] where a*b is not int rather than same percission as size_type Date: Tue, 28 Nov 2023 07:43:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter blocked target_milestone cf_gcctarget Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112742 Bug ID: 112742 Summary: missed vectorization with src[a*b+i] where a*b is not int rather than same percission as size_type Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Blocks: 53947 Target Milestone: --- Target: x86_64-*-* aarch64-*-* Take: ``` void f(unsigned char * __restrict src,=20 unsigned stride, int h, int row) { unsigned char *src1 =3D src+row*stride; for(int col =3D 0; col < h; col++) { src1[col]=3Dsrc1[col] + 1; } } void f1(unsigned char * __restrict src, unsigned rs, unsigned cs, unsigned stride, int h, int row) { for(int col =3D 0; col < h; col++) { src[row*stride+col]=3Dsrc[row*stride+col] + 1; } } ``` These 2 function should be vectorized. But f1 does not. If we use -m32 (or -mabi=3Dilp32 on aarch64) f1 does now get vectorized. Note LLVM is able to vectorize f1 for both aarch64 and x86_64. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D53947 [Bug 53947] [meta-bug] vectorizer missed-optimizations=