public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "powerboat9.gamer at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/113164] New: [missed optimization] struct fields should not alias
Date: Thu, 28 Dec 2023 14:55:57 +0000	[thread overview]
Message-ID: <bug-113164-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113164

            Bug ID: 113164
           Summary: [missed optimization] struct fields should not alias
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: powerboat9.gamer at gmail dot com
  Target Milestone: ---

I have the following code

> struct sss {
>     int a;
>     int b;
> };
> 
> int foo(struct sss *a, struct sss *b) {
>     return &a->a == &b->b;
> }

When I compile it with

> gcc -c -O3 -Wall -Wextra test.c

I get

> 0000000000000000 <foo>:
>    0:	48 83 c6 04          	add    $0x4,%rsi
>    4:	31 c0                	xor    %eax,%eax
>    6:	48 39 fe             	cmp    %rdi,%rsi
>    9:	0f 94 c0             	sete   %al
>    c:	c3                   	ret

, but GCC should be able to infer that the two pointers being compared can not
alias.

             reply	other threads:[~2023-12-28 14:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-28 14:55 powerboat9.gamer at gmail dot com [this message]
2023-12-28 18:22 ` [Bug middle-end/113164] " pinskia at gcc dot gnu.org
2024-01-08 14:16 ` rguenth at gcc dot gnu.org
2024-05-16 12:47 ` 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-113164-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: link
Be 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).