public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/110891] [14 Regression] Dead Code Elimination Regression since r14-2674-gd0de3bf9175
Date: Fri, 04 Aug 2023 07:59:33 +0000	[thread overview]
Message-ID: <bug-110891-4-CozL0OEYqO@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110891-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amacleod at redhat dot com

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I didn't anticipate the trick triggering with FRE but we have

Value numbering stmt = _6 = _5 | 64;
Setting value number of _6 to _6 (changed)
...
Value numbering stmt = _9 = _8 & 5;
Setting value number of _9 to _9 (changed)
...
Replaced a with _6 in all uses of _8 = a;
Applying pattern match.pd:184, gimple-match-10.cc:6142
Applying pattern match.pd:1962, gimple-match-6.cc:16850
gimple_simplified to _10 = _5 & 5;
_9 = _10;

that's the old issue that when we are recursively simplifying pattern
results like

  (bit_ior (bit_and @0 @2) (bit_and! @1 @2)))

we need to push operands, but when any outer operation simplifies
away we can't (or rather do not) pop them again (also when asked
to never push we'd fail the pattern before trying to simplify
the outer operation).  That can then result in such stray copies
to appear.

So the first IL difference is

--- a/t.c.114t.fre3     2023-08-04 09:22:55.380428835 +0200
+++ b/t.c.114t.fre3     2023-08-04 09:21:50.455470894 +0200
@@ -159,7 +159,7 @@
   a = _6;
   _10 = _5 & 5;
   _9 = _10;
-  a = _9;
+  a = _10;
   return 0;

 }

but that vanishes in copyprop1.  ifcombine then gets different SSA names
assigned which means different association of bitwise or operations.  For
some reason this causes the divergence in DOM2.

After copyprop2 we have

-FREE_SSANAMES: 12, 21, 3, 4, 7, 16, 15, 19, 22, 26, 17, 27, 13, 6, 20, 25, 8,
18, 24, 9, 
+FREE_SSANAMES: 12, 21, 3, 4, 7, 16, 15, 19, 22, 26, 17, 27, 9, 13, 6, 20, 25,
8, 18, 24, 

so the same SSA names are in the freelist but as that is unordered we pick
different names when re-using.

In the DOM2 pass you can see that ranger behaves slightly different when
processing operands in different order for commutative operations like
bitwise or in this case, that leads to the observed difference in threading.

Tracing ranger reveals too many differences, in the end I'd say "bad luck",
but maybe ranger folks want to investigate as well?

I'm not convinced we need to sort FREE_SSANAMES, solving the slightly
imperfect simplification for match would be nice.

  parent reply	other threads:[~2023-08-04  7:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03 16:01 [Bug tree-optimization/110891] New: " theodort at inf dot ethz.ch
2023-08-03 16:03 ` [Bug tree-optimization/110891] " pinskia at gcc dot gnu.org
2023-08-03 16:13 ` pinskia at gcc dot gnu.org
2023-08-04  7:59 ` rguenth at gcc dot gnu.org [this message]
2023-08-26  0:00 ` pinskia at gcc dot gnu.org
2023-08-26  0:06 ` pinskia at gcc dot gnu.org
2023-08-26  6:35 ` pinskia at gcc dot gnu.org
2023-08-26  6:35 ` pinskia at gcc dot gnu.org
2023-08-27 23:46 ` pinskia at gcc dot gnu.org
2023-08-28  6:53 ` rguenther at suse dot de
2024-03-07 23:26 ` law at gcc dot gnu.org
2024-03-09  7:01 ` law at gcc dot gnu.org
2024-05-07  7:41 ` [Bug tree-optimization/110891] [14/15 " 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-110891-4-CozL0OEYqO@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).