From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 581B83858421; Wed, 3 Jan 2024 19:14:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 581B83858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704309248; bh=saCE0RPuKasWYdEvRChLCBVDi+meblpmiEWzevOnUKw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=p6Yh7A4OCcsxuYEBVkrJXM4HvS8hfhidKovzC2oJwlmacnUC1/L89m+F684QjL5Vy /RXEgmvQYOTh8F281xNBrouZVErrplauhxnonlOZDu8O1HnviakOjhzavICWPp8nsI aXsVfiotFFNljuDaN8MLxoyW0li798wVuSCZvXO8= From: "phosit at autistici dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/19347] Invariant load not moved out of loop Date: Wed, 03 Jan 2024 19:14:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.0.0 X-Bugzilla-Keywords: alias, missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: phosit at autistici dot org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: 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=3D19347 Phosit changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |phosit at autistici dot org --- Comment #9 from Phosit --- When there are few iterations (likely when it is unroled) there is no alias-check: void fill(int* data, int& value) { for(unsigned long i{0}; i !=3D 4; ++i) data[i] =3D value; } --- at -O2 results in: fill(int*, int&): movd xmm1, DWORD PTR [rsi] pshufd xmm0, xmm1, 0xe0 movq QWORD PTR [rdi], xmm0 movd xmm0, DWORD PTR [rsi] pshufd xmm0, xmm0, 0xe0 movq QWORD PTR [rdi+8], xmm0 ret --- At -O3 the loop isn't removed and (thus) there is an alias-check.=