public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/103182] New: [12 Regression] Recent change causes code correctness regression
@ 2021-11-11  6:02 law at gcc dot gnu.org
  2021-11-11  6:13 ` [Bug tree-optimization/103182] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: law at gcc dot gnu.org @ 2021-11-11  6:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103182
           Summary: [12 Regression] Recent change causes code correctness
                    regression
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: law at gcc dot gnu.org
  Target Milestone: ---

This change:

d70ef65692fced7ab72e0aceeff7407e5a34d96d is the first bad commit
commit d70ef65692fced7ab72e0aceeff7407e5a34d96d
Author: Jan Hubicka <jh@suse.cz>
Date:   Wed Nov 10 13:08:41 2021 +0100

    Make EAF flags more regular (and expressive)

    I hoped that I am done with EAF flags related changes, but while looking
into
    the Fortran testcases I noticed that I have designed them in unnecesarily
    restricted way.  I followed the scheme of NOESCAPE and NODIRECTESCAPE which
is
    however the only property tht is naturally transitive.

    This patch replaces the existing flags by 9 flags:

[ ... ]

Is causing gcc.dg/torture/pr45962-2.c to fail on or1k-elf and a few other
platforms at -O2.

You should be able to reproduce this with just a cross compiler since the
.optimized dump after the change above just calls "foo" then aborts.  The check
for the value of i after the call to foo has been eliminated.

There's a bit of dodgy code in foo() from an aliasing standpoint.  I haven't
looked at it real closely though.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/103182] [12 Regression] Recent change causes code correctness regression
  2021-11-11  6:02 [Bug tree-optimization/103182] New: [12 Regression] Recent change causes code correctness regression law at gcc dot gnu.org
@ 2021-11-11  6:13 ` pinskia at gcc dot gnu.org
  2021-11-11  6:15 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-11  6:13 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
   Target Milestone|---                         |12.0
             Target|                            |or1k-elf

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/103182] [12 Regression] Recent change causes code correctness regression
  2021-11-11  6:02 [Bug tree-optimization/103182] New: [12 Regression] Recent change causes code correctness regression law at gcc dot gnu.org
  2021-11-11  6:13 ` [Bug tree-optimization/103182] " pinskia at gcc dot gnu.org
@ 2021-11-11  6:15 ` pinskia at gcc dot gnu.org
  2021-11-11  7:51 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-11  6:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note I think the testcase that is failing is gcc.dg/torture/pr45967-2.c (as
pr45962-2.c does not exist).

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/103182] [12 Regression] Recent change causes code correctness regression
  2021-11-11  6:02 [Bug tree-optimization/103182] New: [12 Regression] Recent change causes code correctness regression law at gcc dot gnu.org
  2021-11-11  6:13 ` [Bug tree-optimization/103182] " pinskia at gcc dot gnu.org
  2021-11-11  6:15 ` pinskia at gcc dot gnu.org
@ 2021-11-11  7:51 ` redi at gcc dot gnu.org
  2021-11-11  8:08 ` hubicka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2021-11-11  7:51 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=103175

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
That commit also causes ice-on-valid for c++ and fortran.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/103182] [12 Regression] Recent change causes code correctness regression
  2021-11-11  6:02 [Bug tree-optimization/103182] New: [12 Regression] Recent change causes code correctness regression law at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-11-11  7:51 ` redi at gcc dot gnu.org
@ 2021-11-11  8:08 ` hubicka at gcc dot gnu.org
  2021-11-11  9:18 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: hubicka at gcc dot gnu.org @ 2021-11-11  8:08 UTC (permalink / raw)
  To: gcc-bugs

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

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2021-11-11

--- Comment #3 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
mine.
Concerning the ICE in libstdc++ it is somewhat overactive sanity check which is
harmless code correctness wise. I will look into it first.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/103182] [12 Regression] Recent change causes code correctness regression
  2021-11-11  6:02 [Bug tree-optimization/103182] New: [12 Regression] Recent change causes code correctness regression law at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-11-11  8:08 ` hubicka at gcc dot gnu.org
@ 2021-11-11  9:18 ` rguenth at gcc dot gnu.org
  2021-11-11 14:53 ` law at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-11-11  9:18 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/103182] [12 Regression] Recent change causes code correctness regression
  2021-11-11  6:02 [Bug tree-optimization/103182] New: [12 Regression] Recent change causes code correctness regression law at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-11-11  9:18 ` rguenth at gcc dot gnu.org
@ 2021-11-11 14:53 ` law at gcc dot gnu.org
  2021-11-12 22:06 ` hubicka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: law at gcc dot gnu.org @ 2021-11-11 14:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jeffrey A. Law <law at gcc dot gnu.org> ---
And just to be clear, Andrew's c#1 is correct.  It's 45967-2.c.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/103182] [12 Regression] Recent change causes code correctness regression
  2021-11-11  6:02 [Bug tree-optimization/103182] New: [12 Regression] Recent change causes code correctness regression law at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-11-11 14:53 ` law at gcc dot gnu.org
@ 2021-11-12 22:06 ` hubicka at gcc dot gnu.org
  2021-11-13  0:51 ` cvs-commit at gcc dot gnu.org
  2021-11-13  1:10 ` hubicka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: hubicka at gcc dot gnu.org @ 2021-11-12 22:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
What happens here is that we optimize the loop to memcpy and memcpy EAF flags
coming from fnspec are quite interesting.  The copied argument is marked as
escaping but used only directly.  This is correct but not what modref expects
since it generally punts on tracking anything stored in memory, so it needs to
give up on all other flags which it doesn't.

diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
index e999c2c5d1e..c705a67daf7 100644
--- a/gcc/ipa-modref.c
+++ b/gcc/ipa-modref.c
@@ -1888,19 +1888,18 @@ callee_to_caller_flags (int call_flags, bool
ignore_stores,
      that is not the same as caller returning it.  */
   call_flags |= EAF_NOT_RETURNED_DIRECTLY
                | EAF_NOT_RETURNED_INDIRECTLY;
-  /* TODO: We miss return value propagation.
-     Be conservative and if value escapes to memory
-     also mark it as escaping.  */
   if (!ignore_stores && !(call_flags & EAF_UNUSED))
     {
+      /* If value escapes we are no longer able to track what happens
+        with it because we can read it from the escaped location
+        anytime.  */
       if (!(call_flags & EAF_NO_DIRECT_ESCAPE))
-       lattice.merge (~(EAF_NOT_RETURNED_DIRECTLY
-                        | EAF_NOT_RETURNED_INDIRECTLY
-                        | EAF_NO_DIRECT_READ
-                        | EAF_UNUSED));
-      if (!(call_flags & EAF_NO_INDIRECT_ESCAPE))
+       lattice.merge (0);
+      else if (!(call_flags & EAF_NO_INDIRECT_ESCAPE))
        lattice.merge (~(EAF_NOT_RETURNED_INDIRECTLY
                         | EAF_NO_DIRECT_READ
+                        | EAF_NO_INDIRECT_READ
+                        | EAF_NO_INDIRECT_CLOBBER
                         | EAF_UNUSED));
     }
   else

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/103182] [12 Regression] Recent change causes code correctness regression
  2021-11-11  6:02 [Bug tree-optimization/103182] New: [12 Regression] Recent change causes code correctness regression law at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-11-12 22:06 ` hubicka at gcc dot gnu.org
@ 2021-11-13  0:51 ` cvs-commit at gcc dot gnu.org
  2021-11-13  1:10 ` hubicka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-13  0:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jan Hubicka <hubicka@gcc.gnu.org>:

https://gcc.gnu.org/g:2f3d43a35155685b1795b4392e20e1c14a33c38f

commit r12-5221-g2f3d43a35155685b1795b4392e20e1c14a33c38f
Author: Jan Hubicka <jh@suse.cz>
Date:   Sat Nov 13 01:51:25 2021 +0100

    Fix wrong code with modref and some builtins.

    ipa-modref gets confused by EAF flags of memcpy becuase parameter 1 is
    escaping but used only directly.  In modref we do not track values saved to
    memory and thus we clear all other flags on each store.  This needs to also
    happen when called function escapes parameter.

    gcc/ChangeLog:

            PR tree-optimization/103182
            * ipa-modref.c (callee_to_caller_flags): Fix merging of flags.
            (modref_eaf_analysis::analyze_ssa_name): Fix merging of flags.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug tree-optimization/103182] [12 Regression] Recent change causes code correctness regression
  2021-11-11  6:02 [Bug tree-optimization/103182] New: [12 Regression] Recent change causes code correctness regression law at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-11-13  0:51 ` cvs-commit at gcc dot gnu.org
@ 2021-11-13  1:10 ` hubicka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: hubicka at gcc dot gnu.org @ 2021-11-13  1:10 UTC (permalink / raw)
  To: gcc-bugs

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

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
fixed.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-11-13  1:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-11  6:02 [Bug tree-optimization/103182] New: [12 Regression] Recent change causes code correctness regression law at gcc dot gnu.org
2021-11-11  6:13 ` [Bug tree-optimization/103182] " pinskia at gcc dot gnu.org
2021-11-11  6:15 ` pinskia at gcc dot gnu.org
2021-11-11  7:51 ` redi at gcc dot gnu.org
2021-11-11  8:08 ` hubicka at gcc dot gnu.org
2021-11-11  9:18 ` rguenth at gcc dot gnu.org
2021-11-11 14:53 ` law at gcc dot gnu.org
2021-11-12 22:06 ` hubicka at gcc dot gnu.org
2021-11-13  0:51 ` cvs-commit at gcc dot gnu.org
2021-11-13  1:10 ` hubicka at gcc dot gnu.org

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