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.
Created attachment 52393 [details] Test-case Forgotten testcase
I will have a look.
Isn't this a dup of bug 60712?
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
So yes, __restrict info _does_ survive inlining.
The typos have been there and unnoticed since the original r5-5305 ... :/
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.
Fixed on trunk, I'm considering backporting to GCC 11 eventually.
Fixed for GCC 12, not backporting.