public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/107389] New: Alignment not inferred from type at -O0 Date: Tue, 25 Oct 2022 07:57:14 +0000 [thread overview] Message-ID: <bug-107389-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107389 Bug ID: 107389 Summary: Alignment not inferred from type at -O0 Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: rth at gcc dot gnu.org Target Milestone: --- Consider typedef __uint128_t aligned_type __attribute__((aligned(16))); _Static_assert(__alignof(aligned_type) == 16); __uint128_t foo(aligned_type *p) { return __atomic_load_n(p, 0); } For s390x, atomic_loadti should expand this to LPQ. For my purposes, it must also do this at -O0, not just with optimization. But the alignment seen by gen_atomic_loadti is only 8, so it FAILs the expansion and falls back to libatomic. The following appears to solve the problem: --- a/gcc/builtins.cc +++ b/gcc/builtins.cc @@ -468,8 +468,11 @@ get_pointer_alignment_1 } else { + /* Assume alignment from the type. */ + tree ptr_type = TREE_TYPE (exp); + tree obj_type = TREE_TYPE (ptr_type); + *alignp = TYPE_ALIGN (obj_type); *bitposp = 0; - *alignp = BITS_PER_UNIT; return false; } } but I have an inkling that would have undesired effects for other usages. If so, perhaps a special case could be made for the usage in get_builtin_sync_mem.
next reply other threads:[~2022-10-25 7:57 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-25 7:57 rth at gcc dot gnu.org [this message] 2022-10-25 12:46 ` [Bug c/107389] " rguenth at gcc dot gnu.org 2022-10-25 12:52 ` rguenth at gcc dot gnu.org 2022-10-25 15:12 ` rth at gcc dot gnu.org 2022-10-26 8:15 ` [Bug middle-end/107389] Always propagate __builtin_assume_aligned rth at gcc dot gnu.org 2022-10-28 9:19 ` rguenth at gcc dot gnu.org 2022-10-28 9:30 ` rguenth at gcc dot gnu.org 2022-11-08 15:39 ` cvs-commit at gcc dot gnu.org 2022-11-08 15:40 ` rguenth at gcc dot gnu.org 2022-11-28 22:15 ` pinskia 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-107389-4@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).