public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR88621
@ 2019-01-02 12:18 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2019-01-02 12:18 UTC (permalink / raw)
  To: gcc-patches


Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2019-01-02  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/88621
	* tree-ssa-loop-im.c (gather_mem_refs_stmt): Fix pastos, avoid
	bitfields when canoncalizing.

	* gcc.dg/torture/pr88621.c: New testcase.

diff --git a/gcc/testsuite/gcc.dg/torture/pr88621.c b/gcc/testsuite/gcc.dg/torture/pr88621.c
new file mode 100644
index 00000000000..78492a34dd7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr88621.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+
+struct S
+{
+  int b:4;
+  int c; 
+} e = { -1, 0 };
+
+int d, f;
+
+int main ()
+{
+  while (f)
+    {
+      struct S g = { 0, 0 };
+      e = g;
+    }
+L:
+  while (e.b > 0)
+    ;
+  e.b = 0;
+  if (d)
+    goto L;
+  return 0;
+}
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index 58da79d0545..0919931cec3 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -1468,9 +1468,10 @@ gather_mem_refs_stmt (struct loop *loop, gimple *stmt)
       tree mem_base;
       if (aor.max_size_known_p ()
 	  && aor.offset.is_constant (&offset)
-	  && aor.offset.is_constant (&size)
-	  && aor.offset.is_constant (&max_size)
+	  && aor.size.is_constant (&size)
+	  && aor.max_size.is_constant (&max_size)
 	  && size == max_size
+	  && (size % BITS_PER_UNIT) == 0
 	  && (mem_base = get_addr_base_and_unit_offset (aor.ref, &mem_off)))
 	{
 	  hash = iterative_hash_expr (ao_ref_base (&aor), 0);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-01-02 12:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-02 12:18 [PATCH] Fix PR88621 Richard Biener

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).