From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 496733A4740F; Wed, 5 May 2021 06:32:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 496733A4740F From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/100363] gcc generating wider load/store than warranted at -O3 Date: Wed, 05 May 2021 06:32:32 +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: rguenther at suse dot de 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: Wed, 05 May 2021 06:32:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100363 --- Comment #19 from rguenther at suse dot de --- On Tue, 4 May 2021, vgupta at synopsys dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100363 >=20 > --- 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,= while > > > > the vectorized code somewhere relies on them being sufficiently ali= gned for > > > > a 'short'. > > >=20 > > > They absolutely are. > > >=20 > > > And we build the kernel with -Wno-strict-aliasing exactly to make sur= e 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 exp= licitly > > > tell you not to do that. > > >=20 > > > Linus > >=20 > > Note alignment has nothing to do with strict-aliasing (-fno-strict-alia= sing > > you mean btw). > >=20 > > One thing we do is (I'm not 50% sure this explains the observed issue) = assume > > 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 wh= en > > you know lower zero bits. >=20 > 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 - si= nce > that is what it is generating. That's guarded by a runtime check but this check again assumes the accesses are aligned as short and thus will fail if not=