public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/110237] gcc.dg/torture/pr58955-2.c is miscompiled by RTL scheduling after reload Date: Mon, 26 Jun 2023 11:14:27 +0000 [thread overview] Message-ID: <bug-110237-4-KJ5c6h4DbE@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-110237-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110237 --- Comment #17 from rguenther at suse dot de <rguenther at suse dot de> --- On Mon, 26 Jun 2023, amonakov at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110237 > > --- Comment #16 from Alexander Monakov <amonakov at gcc dot gnu.org> --- > (In reply to rguenther@suse.de from comment #14) > > vectors of T and scalar T interoperate TBAA wise. What we disambiguate is > > > > int a[2]; > > > > int foo(int *p) > > { > > a[0] = 1; > > *(v4si *)p = {0,0,0,0}; > > return a[0]; > > } > > > > because the V4SI vector store is too large for the a[] object. That > > doesn't even use TBAA (it works with -fno-strict-aliasing just fine). > > Thank you for the example. If we do the same for vector loads, that's a footgun > for users who use vector loads to access small objects: > > // alignment to 16 is ensured externally > extern int a[2]; > > int foo() > { > a[0] = 1; > > __v4si v = (__attribute__((may_alias)) __v4si *) &a; > // mask out extra elements in v and continue > ... > } > > This is a benign data race on data that follows 'a' in the address space, but > otherwise should be a valid and useful technique. Yes, we do the same to loads. I hope that's not a common technique though but I have to admit the vectorizer itself assesses whether it's safe to access "gaps" by looking at alignment so its code generation is prone to this same "mistake". Now, is "alignment to 16 is ensured externally" good enough here? If we consider static int a[2]; and code doing if (is_aligned (a)) { __v4si v = (__attribute__((may_alias)) __v4si *) &a; } then we cannot even use a DECL_ALIGN that's insufficient for decls that bind locally. Note we have similar arguments with aggregate type sizes (and TBAA) where when we infer a dynamic type from one access we check if the other access would fit. Wouldn't the above then extend to that as well given we could also do aggregate copies of "padding" and ignore the bits if we'd have ensured the larger access wouldn't trap? So supporting the above might be a bit of a stretch (though I think we have to fix the vectorizer here). > > If the v4si store is masked we cannot do this anymore, but the IL > > we seed the alias oracle with doesn't know the store is partial. > > The only way to "fix" it is to take away all of the information from it. > > But that won't fix the trapping issue? I think we need a distinct RTX for > memory accesses where hardware does fault suppression for masked-out elements. Yes, it doesn't fix that part. The idea of using BLKmode instead of a vector mode for the MEMs would, I guess, together with specifying MEM_SIZE as not known.
next prev parent reply other threads:[~2023-06-26 11:14 UTC|newest] Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-13 13:50 [Bug rtl-optimization/110237] New: " rguenth at gcc dot gnu.org 2023-06-14 11:02 ` [Bug rtl-optimization/110237] " amonakov at gcc dot gnu.org 2023-06-14 12:09 ` rguenth at gcc dot gnu.org 2023-06-20 9:52 ` rguenth at gcc dot gnu.org 2023-06-20 11:35 ` crazylht at gmail dot com 2023-06-20 12:20 ` rguenther at suse dot de 2023-06-20 16:05 ` crazylht at gmail dot com 2023-06-21 5:48 ` crazylht at gmail dot com 2023-06-21 7:33 ` rguenth at gcc dot gnu.org 2023-06-25 4:06 ` crazylht at gmail dot com 2023-06-26 7:41 ` rguenther at suse dot de 2023-06-26 7:58 ` amonakov at gcc dot gnu.org 2023-06-26 8:07 ` rguenther at suse dot de 2023-06-26 8:22 ` amonakov at gcc dot gnu.org 2023-06-26 8:35 ` rguenther at suse dot de 2023-06-26 8:44 ` crazylht at gmail dot com 2023-06-26 8:54 ` amonakov at gcc dot gnu.org 2023-06-26 11:14 ` rguenther at suse dot de [this message] 2023-06-26 18:19 ` amonakov at gcc dot gnu.org 2023-06-27 6:53 ` rguenther at suse dot de 2023-06-27 7:30 ` cvs-commit at gcc dot gnu.org 2023-06-27 9:50 ` amonakov at gcc dot gnu.org 2023-06-27 10:03 ` rguenther at suse dot de 2023-06-29 1:27 ` cvs-commit at gcc dot gnu.org 2023-06-29 1:28 ` cvs-commit at gcc dot gnu.org 2023-06-29 1:29 ` cvs-commit at gcc dot gnu.org 2023-11-27 12:39 ` rdapp at gcc dot gnu.org 2023-11-29 12:26 ` cvs-commit at gcc dot gnu.org 2023-11-29 12:27 ` rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-110237-4-KJ5c6h4DbE@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).