public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ibuclaw at gdcproject dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug d/96153] d: struct literals have non-deterministic hash values
Date: Wed, 05 Aug 2020 16:30:10 +0000	[thread overview]
Message-ID: <bug-96153-4-x6OBbuRJqN@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96153-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Created attachment 49006
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49006&action=edit
inline memset

(In reply to Iain Buclaw from comment #3)
> (In reply to Rainer Orth from comment #2)
> > The new test FAILs on 64-bit Solaris/SPARC:
> > 
> > The test PASSes with -O0 and -Os, as well as with -m32.
> 
> Thanks, I've checked Linux/SPARC64 and see the same thing.

DSE is removing the call to memset as dead code, so the optimizer is not
understanding the hint.

Inlining the memset using a bunch of MEM_REFs yields the correct result, and
infact the optimizer is able to fully const-fold the hash computation at -O3 so
all assert contracts are removed.

Though not sure about the approach, are there any pitfalls to this?

This is what optimized trees look like at -O1 and -O2 levels, with comments
inserted describing which bits are set.

x86_64 -O1:
  // 0..128 = 0
  MEM <uint128_t *> [(uint128_t *)&D.4244] = 0B;
  // 128..192 = 0
  MEM[(ulong *)&D.4244 + 16B] = 0B;
  // 0..32 = 12
  D.4244.payload = 12;
  // 128..160 = 4294967295
  D.4244.hook.var2 = 4294967295;
  // 64..128 = 18446744073709551615
  D.4244.hook.var1 = 18446744073709551615;

x86_64 -O2:
  // 0..64 = 12
  MEM <unsigned long> [(void *)&D.4244] = 12;
  // 64..128 = 18446744073709551615
  D.4244.hook.var1 = 18446744073709551615;
  // 128..192 = 4294967295
  MEM <unsigned long> [(void *)&D.4244 + 16B] = 4294967295;

SPARC64 -O1:
  // 0..128 = 51539607552
  MEM <uint128_t *> [(void *)&D.1048] = 51539607552B;
  // 64..128 = 18446744073709551615
  MEM <ulong> [(void *)&D.1048 + 8B] = 18446744073709551615;
  // 128..192 = -4294967296
  MEM <ulong *> [(void *)&D.1048 + 16B] = -4294967296B;

SPARC -O2
  // 0..128 = 51539607552
  MEM <uint128_t *> [(void *)&D.1048] = 51539607552B;
  // 64..128 = 18446744073709551615
  MEM <ulong> [(void *)&D.1048 + 8B] = 18446744073709551615;
  // 128..192 = -4294967296
  MEM <ulong *> [(void *)&D.1048 + 16B] = -4294967296B;


Both SPARC and x86_64 yield the same hash values.

  assert(-1444610504 != -1444610503);
  assert(-1444610503 == -1444610503);

  parent reply	other threads:[~2020-08-05 16:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-10 14:40 [Bug d/96153] New: " ibuclaw at gdcproject dot org
2020-08-04 15:05 ` [Bug d/96153] " cvs-commit at gcc dot gnu.org
2020-08-05  8:46 ` ro at gcc dot gnu.org
2020-08-05 11:42 ` ibuclaw at gdcproject dot org
2020-08-05 16:30 ` ibuclaw at gdcproject dot org [this message]
2020-08-06 12:49 ` ibuclaw at gdcproject dot org
2020-08-23  7:05 ` ibuclaw at gdcproject dot org
2020-08-24 19:49 ` ibuclaw at gdcproject dot org
2020-08-26  8:04 ` cvs-commit at gcc dot gnu.org
2020-08-26  8:05 ` ibuclaw at gdcproject dot 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-96153-4-x6OBbuRJqN@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).