From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 260133858D38; Tue, 23 Apr 2024 10:11:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 260133858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713867116; bh=tWtLozAETDj21b1rt4IMr84K2i1eDjfkDJNXJ9S57WQ=; h=From:To:Subject:Date:From; b=aBs8YRANHLw98ozgagVb7kWbtmx4C78aSHwQzyuefJesfumJnPovLUZbDFv6T0+rZ khH0osr/mAT0v8H4Yx8jJeN6f3+Yw8SzA1NknCcyXDIo2nXfKVM7S5z50rPFQJlS9W AzQ8eM1C0XJcRczGzS/n5kpAGHHECd09wmxrTEak= From: "652023330028 at smail dot nju.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114823] New: Missed optimization of redundant loops Date: Tue, 23 Apr 2024 10:11:55 +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: X-Bugzilla-Severity: normal X-Bugzilla-Who: 652023330028 at smail dot nju.edu.cn 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 bug_severity priority component assigned_to reporter target_milestone 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=3D114823 Bug ID: 114823 Summary: Missed optimization of redundant loops Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: 652023330028 at smail dot nju.edu.cn Target Milestone: --- Hello, for the reduced code below, its second loop is redundant. There seem= s to be a missed optimization. https://godbolt.org/z/McqeYdnfY int a[1024]; int b[1024]; void func() { for (int i =3D 0; i < 1024; i+=3D1) { a[i] =3D b[i] * 2; } for (int i =3D 0; i < 1024; i+=3D1) { a[i] =3D b[i] * 2; } } GCC -O3: func: xor eax, eax .L2: movdqa xmm0, XMMWORD PTR b[rax] add rax, 16 pslld xmm0, 1 movaps XMMWORD PTR a[rax-16], xmm0 cmp rax, 4096 jne .L2 xor eax, eax .L3: movdqa xmm0, XMMWORD PTR b[rax] add rax, 16 pslld xmm0, 1 movaps XMMWORD PTR a[rax-16], xmm0 cmp rax, 4096 jne .L3 ret Expected code: func: xor eax, eax .L2: movdqa xmm0, XMMWORD PTR b[rax] add rax, 16 pslld xmm0, 1 movaps XMMWORD PTR a[rax-16], xmm0 cmp rax, 4096 jne .L2 ret Thank you very much for your time and effort! We look forward to hearing fr= om you.=