public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/98190] GCC 11.0 miscompiles code using _Bool when inlining: bfxil instruction misused? Date: Tue, 08 Dec 2020 13:08:46 +0000 [thread overview] Message-ID: <bug-98190-4-h7Hyn3sIvS@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-98190-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98190 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|RESOLVED |REOPENED Resolution|DUPLICATE |--- CC| |jakub at gcc dot gnu.org Last reconfirmed| |2020-12-08 --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I don't see UB there, UB would be if you copy a value other than 0 or 1 to the _Bool variable, but that is not happening here. Consider even: static int __attribute__((noipa)) foo (const char *p, const char *q, const int len) { for (int i = 0; i < len; p++, q++, i++) { int equal; _Bool x, y; __builtin_memcpy ((char *) &x, p, sizeof x); __builtin_memcpy ((char *) &y, q, sizeof y); equal = (x == y); if (equal <= 0) return equal; } return 1; } int main () { const _Bool buf[4] = { 1, 0, 0, 0 }; register long x4 asm ("x4") = 0xdeadbeefULL; register long x5 asm ("x5") = 0xdeadbeefULL; asm volatile (""::"r" (x4), "r" (x5)); if (foo ((char *) &buf[0], (char *) &buf[0], 1) != 1) __builtin_abort (); return 0; } Copying through char * from _Bool to _Bool really must work, that is what happens e.g. in structure assignments etc. if it has _Bool fields. The reason this is miscompiled is that the aarch64 backend decides that the x and y variables should be promoted from QImode to SImode and the expansion of the memcpy folded into assignment sets a MEM_REF with QImode (i.e. low parts of the promoted DECL_RTL), but nothing sign or zero extends it.
next prev parent reply other threads:[~2020-12-08 13:08 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-12-08 0:22 [Bug c/98190] New: " vstinner at redhat dot com 2020-12-08 0:29 ` [Bug middle-end/98190] " pinskia at gcc dot gnu.org 2020-12-08 0:31 ` pinskia at gcc dot gnu.org 2020-12-08 0:33 ` vstinner at redhat dot com 2020-12-08 0:37 ` pinskia at gcc dot gnu.org 2020-12-08 13:08 ` jakub at gcc dot gnu.org [this message] 2020-12-08 13:55 ` [Bug middle-end/98190] [11 Regression] GCC11 miscompiles code using _Bool when inlining: bfxil instruction misused since r11-165 jakub at gcc dot gnu.org 2020-12-08 14:52 ` rguenth at gcc dot gnu.org 2020-12-08 19:07 ` jakub at gcc dot gnu.org 2020-12-08 19:16 ` jakub at gcc dot gnu.org 2020-12-09 9:04 ` rsandifo at gcc dot gnu.org 2020-12-09 9:16 ` rguenther at suse dot de 2020-12-09 9:41 ` jakub at gcc dot gnu.org 2020-12-09 15:03 ` rguenther at suse dot de 2020-12-09 16:30 ` rsandifo at gcc dot gnu.org 2020-12-10 8:22 ` jakub at gcc dot gnu.org 2020-12-10 11:39 ` rguenther at suse dot de 2020-12-11 10:12 ` cvs-commit at gcc dot gnu.org 2020-12-11 11:50 ` jakub 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-98190-4-h7Hyn3sIvS@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).