From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5EC7F3959E55; Tue, 4 May 2021 19:33:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5EC7F3959E55 From: "vgupta at synopsys dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/100363] gcc generating wider load/store than warranted at -O3 Date: Tue, 04 May 2021 19:33:17 +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: 10.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: vgupta at synopsys dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 May 2021 19:33:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100363 --- Comment #18 from Vineet Gupta --- (In reply to Richard Biener from comment #9) > (In reply to Linus Torvalds from comment #8) > > (In reply to Alexander Monakov from comment #7) > > >=20 > > > Most likely the issue is that sout/sfrom are misaligned at runtime, w= hile > > > the vectorized code somewhere relies on them being sufficiently align= ed for > > > a 'short'. > >=20 > > They absolutely are. > >=20 > > And we build the kernel with -Wno-strict-aliasing exactly to make sure = the > > compiler doesn't think that "oh, I can make aliasing decisions based on= type > > information". > >=20 > > Because we have those kinds of issues all over, and we know which > > architectures support unaligned loads etc, and all the tricks with > > "memcpy()" and unions make for entirely unreadable code. > >=20 > > So please fix the aliasing logic to not be type-based when people expli= citly > > tell you not to do that. > >=20 > > Linus >=20 > Note alignment has nothing to do with strict-aliasing (-fno-strict-aliasi= ng > you mean btw). >=20 > One thing we do is (I'm not 50% sure this explains the observed issue) as= sume > that if you have two accesses with type 'short' and they are aligned > according to this type then they will not partly overlap. Note this has > nothing to do with C strict aliasing rules but is basic pointer math when > you know lower zero bits. OK, given that source code has type short, they will assume these things are short aligned and thus won't overlap for short accesses. But then the code actually generated by loop vectorizer assumes they are 8 bytes apart - since that is what it is generating. >=20 > I suggest to try the fix suggested in comment#7 and report back if that > fixes the observed issue.=