public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/104466] New: Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r)
@ 2022-02-09 13:53 jamborm at gcc dot gnu.org
  2022-02-09 14:57 ` [Bug tree-optimization/104466] " jamborm at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: jamborm at gcc dot gnu.org @ 2022-02-09 13:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104466
           Summary: Inlining functions with restrict parameters can
                    inhibit lim (e.g. in 554.roms_r)
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jamborm at gcc dot gnu.org
            Blocks: 26163
  Target Milestone: ---
              Host: x86_64-linux
            Target: x86_64-linux

We have noticed that a bit more performance can be squeezed out of
554.roms_r benchmark from the SPEC 2017 FPrate suite by using option
-fno-inline-functions-called-once, even at -O2 (but also at -Ofast).
At least one potential reason is that without inlining, loop invariant
motion is able to disambiguate memory references better because of
restrict qualified parameters.  When it cannot, it can be observed by
lim not taking place, at -O2 at least (which in turn affects other
passes).

I tried to create a small-ish reproducer and am attaching the result.
Compile with: -std=legacy -O2 --param max-inline-insns-auto=0 --param
max-inline-insns-single=0  

with and without -fno-inline-functions-called-once and look for lim of
a load from array n in the lim2 dump.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26163
[Bug 26163] [meta-bug] missed optimization in SPEC (2k17, 2k and 2k6 and 95)

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

* [Bug tree-optimization/104466] Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r)
  2022-02-09 13:53 [Bug tree-optimization/104466] New: Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r) jamborm at gcc dot gnu.org
@ 2022-02-09 14:57 ` jamborm at gcc dot gnu.org
  2022-02-09 15:14 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jamborm at gcc dot gnu.org @ 2022-02-09 14:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Martin Jambor <jamborm at gcc dot gnu.org> ---
Created attachment 52393
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52393&action=edit
Test-case

Forgotten testcase

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

* [Bug tree-optimization/104466] Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r)
  2022-02-09 13:53 [Bug tree-optimization/104466] New: Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r) jamborm at gcc dot gnu.org
  2022-02-09 14:57 ` [Bug tree-optimization/104466] " jamborm at gcc dot gnu.org
@ 2022-02-09 15:14 ` rguenth at gcc dot gnu.org
  2022-02-09 18:53 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-02-09 15:14 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-02-09
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I will have a look.

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

* [Bug tree-optimization/104466] Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r)
  2022-02-09 13:53 [Bug tree-optimization/104466] New: Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r) jamborm at gcc dot gnu.org
  2022-02-09 14:57 ` [Bug tree-optimization/104466] " jamborm at gcc dot gnu.org
  2022-02-09 15:14 ` rguenth at gcc dot gnu.org
@ 2022-02-09 18:53 ` pinskia at gcc dot gnu.org
  2022-02-10  8:03 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-09 18:53 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |60712

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Isn't this a dup of bug 60712?


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60712
[Bug 60712] "restrict" qualifier ignored on local variable or after inlining

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

* [Bug tree-optimization/104466] Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r)
  2022-02-09 13:53 [Bug tree-optimization/104466] New: Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r) jamborm at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-02-09 18:53 ` pinskia at gcc dot gnu.org
@ 2022-02-10  8:03 ` rguenth at gcc dot gnu.org
  2022-02-10  8:16 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-02-10  8:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Bah, what stupid cut&paste error ...



diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc
index d434446a997..3e8d2455ba5 100644
--- a/gcc/tree-ssa-alias.cc
+++ b/gcc/tree-ssa-alias.cc
@@ -2420,12 +2420,12 @@ refs_may_alias_p_2 (ao_ref *ref1, ao_ref *ref2, bool
tbaa_p)
          rbase2 = TREE_OPERAND (rbase2, 0);
     }
   if (rbase1 && rbase2
-      && (TREE_CODE (base1) == MEM_REF || TREE_CODE (base1) == TARGET_MEM_REF)
-      && (TREE_CODE (base2) == MEM_REF || TREE_CODE (base2) == TARGET_MEM_REF)
+      && (TREE_CODE (rbase1) == MEM_REF || TREE_CODE (rbase1) ==
TARGET_MEM_REF)
+      && (TREE_CODE (rbase2) == MEM_REF || TREE_CODE (rbase2) ==
TARGET_MEM_REF)
       /* If the accesses are in the same restrict clique... */
-      && MR_DEPENDENCE_CLIQUE (base1) == MR_DEPENDENCE_CLIQUE (base2)
+      && MR_DEPENDENCE_CLIQUE (rbase1) == MR_DEPENDENCE_CLIQUE (rbase2)
       /* But based on different pointers they do not alias.  */
-      && MR_DEPENDENCE_BASE (base1) != MR_DEPENDENCE_BASE (base2))
+      && MR_DEPENDENCE_BASE (rbase1) != MR_DEPENDENCE_BASE (rbase2))
     return false;

   ind1_p = (TREE_CODE (base1) == MEM_REF

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

* [Bug tree-optimization/104466] Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r)
  2022-02-09 13:53 [Bug tree-optimization/104466] New: Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r) jamborm at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-02-10  8:03 ` rguenth at gcc dot gnu.org
@ 2022-02-10  8:16 ` rguenth at gcc dot gnu.org
  2022-02-10  8:33 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-02-10  8:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
So yes, __restrict info _does_ survive inlining.

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

* [Bug tree-optimization/104466] Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r)
  2022-02-09 13:53 [Bug tree-optimization/104466] New: Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r) jamborm at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-02-10  8:16 ` rguenth at gcc dot gnu.org
@ 2022-02-10  8:33 ` rguenth at gcc dot gnu.org
  2022-02-10  9:55 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-02-10  8:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
The typos have been there and unnoticed since the original r5-5305 ... :/

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

* [Bug tree-optimization/104466] Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r)
  2022-02-09 13:53 [Bug tree-optimization/104466] New: Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r) jamborm at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-02-10  8:33 ` rguenth at gcc dot gnu.org
@ 2022-02-10  9:55 ` cvs-commit at gcc dot gnu.org
  2022-02-10  9:55 ` rguenth at gcc dot gnu.org
  2022-05-06 11:37 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-02-10  9:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:1b72d456b2a88218ed440655ef0b9e29b4ef63a9

commit r12-7173-g1b72d456b2a88218ed440655ef0b9e29b4ef63a9
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Feb 10 09:03:48 2022 +0100

    tree-optimization/104466 - fix cut&paste error perventing alias
disambiguation

    The following fixes a cut&paste error in disambiguating using restrict
    info.  Instead of using the for this purpose computed rbase1/rbase2
    which preserve MEM_REF bases even when they are based on a decl the
    code performs the check on the bases that drop info for those ...

    2022-02-10  Richard Biener  <rguenther@suse.de>

            PR tree-optimization/104466
            * tree-ssa-alias.cc (refs_may_alias_p_2): Use rbase1/rbase2
            for the MR_DEPENDENCE checks as intended.

            * gfortran.dg/pr104466.f90: New testcase.

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

* [Bug tree-optimization/104466] Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r)
  2022-02-09 13:53 [Bug tree-optimization/104466] New: Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r) jamborm at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2022-02-10  9:55 ` cvs-commit at gcc dot gnu.org
@ 2022-02-10  9:55 ` rguenth at gcc dot gnu.org
  2022-05-06 11:37 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-02-10  9:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |12.0

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk, I'm considering backporting to GCC 11 eventually.

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

* [Bug tree-optimization/104466] Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r)
  2022-02-09 13:53 [Bug tree-optimization/104466] New: Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r) jamborm at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2022-02-10  9:55 ` rguenth at gcc dot gnu.org
@ 2022-05-06 11:37 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-06 11:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed for GCC 12, not backporting.

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

end of thread, other threads:[~2022-05-06 11:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 13:53 [Bug tree-optimization/104466] New: Inlining functions with restrict parameters can inhibit lim (e.g. in 554.roms_r) jamborm at gcc dot gnu.org
2022-02-09 14:57 ` [Bug tree-optimization/104466] " jamborm at gcc dot gnu.org
2022-02-09 15:14 ` rguenth at gcc dot gnu.org
2022-02-09 18:53 ` pinskia at gcc dot gnu.org
2022-02-10  8:03 ` rguenth at gcc dot gnu.org
2022-02-10  8:16 ` rguenth at gcc dot gnu.org
2022-02-10  8:33 ` rguenth at gcc dot gnu.org
2022-02-10  9:55 ` cvs-commit at gcc dot gnu.org
2022-02-10  9:55 ` rguenth at gcc dot gnu.org
2022-05-06 11:37 ` rguenth 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).