Revert accidental change in ipa-modref-tree.h

2021-10-11 Thread Jan Hubicka via Gcc-patches
Hi, I managed to commit an unrelatd change that was sitting my tree that breaks bootstrap. I have reverted it now and checked bootstrap gets past the failing point (still waiting for full bootstrap to finish at x86_64-linux). Honza gcc/ChangeLog: * ipa-modref-tree.h (struct

Re: [Patch] (was: Re: [r12-4457 Regression] FAIL: gfortran.dg/deferred_type_param_6.f90 -Os execution test on Linux/x86_64)

2021-10-16 Thread Jan Hubicka via Gcc-patches
> > Fortran has for a long time 'character(len=5), allocatable" or > "character(len=*)". In the first case, the "5" can be ignored as both > caller and callee know the length. In the second case, the length is > determined by the argument, but it cannot be changed. > > Since a not-that-short

Re: [r12-4457 Regression] FAIL: gfortran.dg/deferred_type_param_6.f90 -Os execution test on Linux/x86_64

2021-10-16 Thread Jan Hubicka via Gcc-patches
Hi, > > FAIL: gfortran.dg/deferred_type_param_6.f90 -O1 execution test > FAIL: gfortran.dg/deferred_type_param_6.f90 -Os execution test Sorry for the breakage. This time it seems like bug in Fortran FE which was previously latent: __attribute__((fn spec (". . R "))) void subfunc

Cleanup compute_points_to_sets

2021-10-19 Thread Jan Hubicka via Gcc-patches
Hi, this patch fixes two issues I noticed while proofreading the code. First is that I have added conditional around setting of nonlocal and escaped flags (since they may be set from solver) while keeping the variable in assignment that is confusing. Second is that we still do not set pt in the

Fix wrong code in ldist-strlen-1.c

2021-10-16 Thread Jan Hubicka via Gcc-patches
Hi, while updating compute_points_to_sets I missed that the code not only sets the nonlocal/escaped flags but also initializes pt. With my previous change if uses_global_memory is false pt is not updated correctly which may lead to wrong code. This is fixed by the following patch I comitted to

Re: [PATCH] ipa-param-manip: Be careful about a reallocating hash_map (PR 103449)

2021-11-29 Thread Jan Hubicka via Gcc-patches
> Hi, > > PR 103449 revealed that when I was storing result of one hash_map > lookup into another entry in the hash_map, I was still accessing the > entry in the table, which meanwhile could get reallocated, making the > accesses invalid-after-free. > > Fixed with the following, which also

Re: [PATCH] alias: Optimise call_may_clobber_ref_p

2021-12-06 Thread Jan Hubicka via Gcc-patches
> On Mon, Dec 6, 2021 at 4:03 PM Richard Biener > wrote: > > > > On Mon, Dec 6, 2021 at 11:10 AM Richard Sandiford > > wrote: > > > > > > Richard Biener writes: > > > > On Sun, Dec 5, 2021 at 10:59 PM Richard Sandiford via Gcc-patches > > > > wrote: > > > >> > > > >> When compiling an

Fix early exit in modref_merge_call_site_flags

2021-12-19 Thread Jan Hubicka via Gcc-patches
Hi, when adding support for static chain and return slot flags I forgot to update early exit condition in modref_merge_call_site_flags. This yields to wrong code as demonstrated by the Fortran testcase attached to PR (which I hope someone will help me to turn into testuite one).

Fix handling of deferred SSA names in modref

2021-12-19 Thread Jan Hubicka via Gcc-patches
Hi, in the testcase we fail to analyze SSA name because flag do_dataflow is set and thus triggers early exist in analyze_ssa_name. Fixed by disabling early exits when handling deferred names. Bootstrapped/regtested x86_64-linux, comitted. gcc/ChangeLog: 2021-12-20 Jan Hubicka PR

Re: Patch ping

2022-01-03 Thread Jan Hubicka via Gcc-patches
> Hi! > > I'd like to ping the > https://gcc.gnu.org/pipermail/gcc-patches/2021-December/586553.html > symtab: Fold == to 0 if folding_initializer [PR94716] > > patch. Thanks. OK. Note that with LTO partitioning it may happen that alias is defined in one partition but used in another. We

Re: [PATCH] Fix ICE in lsplit when built with -O3 -fno-guess-branch-probability [PR103793]

2021-12-28 Thread Jan Hubicka via Gcc-patches
> - /* Proportion second loop's bb counts except those dominated by false > -branch to avoid drop 1s down. */ > - basic_block bbi_copy = get_bb_copy (false_edge->dest); > - bbs2 = get_loop_body (loop2); > - for (j = 0; j < loop2->num_nodes; j++) > - if (bbs2[j] ==

Re: [PATCH 1/3] loop-invariant: Don't move cold bb instructions to preheader in RTL

2021-12-29 Thread Jan Hubicka via Gcc-patches
> > > > From: Xiong Hu Luo > > > > gcc/ChangeLog: > > > > * loop-invariant.c (find_invariants_bb): Check profile count > > before motion. > > (find_invariants_body): Add argument. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.dg/loop-invariant-2.c: New. OK, thanks! Honza

Improve tracking of bases in modref

2021-11-21 Thread Jan Hubicka via Gcc-patches
Hi, on exchange2 benchamrk we miss some useful propagation because modref gives up very early on analyzing accesses through pointers. For example in int test (int *a) { int i; for (i=0; a[i];i++); return i+a[i]; } We are not able to determine that a[i] accesses are relative to a. This is

Fix failure in merge_block.c testcase

2021-11-21 Thread Jan Hubicka via Gcc-patches
Hi, this testcase needs -fno-ipa-modref becuase otherwise it hits the issue that complete loop unrolling leaves somewhat mismatched profile. Bootstrapped/regtested x86_64-linux, comitted. gcc/testsuite/ChangeLog: 2021-11-21 Jan Hubicka PR ipa/103264 *

Improve byte-wise DSE (modref-dse-[45].c failures)

2021-11-22 Thread Jan Hubicka via Gcc-patches
Hi, testcase modref-dse-4.c and modref-dse-5.c fails on some targets because they depend on store merging. What really happens is that without store merging we produce for kill_me combined write that is ao_ref with offset=0, size=32 and max_size=96. We have size != max_size becaue we do ont

Re: [PATCH] Fix incorrect loop exit edge probability [PR103270]

2021-11-23 Thread Jan Hubicka via Gcc-patches
> On Tue, Nov 23, 2021 at 6:52 AM Xionghu Luo wrote: > > > > r12-4526 cancelled jump thread path rotates loop. It exposes a issue in > > profile-estimate when predict_extra_loop_exits, outer loop's exit edge > > is marked as inner loop's extra loop exit and set with incorrect > > prediction, then

Small tweak to modref pure/const discoverys

2021-11-20 Thread Jan Hubicka via Gcc-patches
Hi, while looking into the PR I also improved debug output in ipa-modref and fixed ignore_nondeterminism predicate: looping pures and cont are still deterministic. Bootstrapped/regtested x86_64-linux, comitted. gcc/ChangeLog: 2021-11-21 Jan Hubicka PR ipa/103052 *

Fix looping flag discovery in ipa-pure-const

2021-11-20 Thread Jan Hubicka via Gcc-patches
Hi, The testcase shows situation where there is non-trivial cycle in the callgraph involving a noreturn call. This cycle is important for const function discovery but not important for pure. IPA pure const uses same strongly connected components for both propagations which makes it to get

Reduce size of modref_access_tree

2021-11-23 Thread Jan Hubicka via Gcc-patches
Hi, Modref tree template stores its own copy of param_moderf_max_bases, *_max_refs and *_max_accesses values. This was done before we had per-function limits and even back then it was bit dubious, so this patch removes it. Bootstrapped/regtested x86_64-linux, will commit it shortly. Honza

Re: [PATCH] Fix IPA modref ubsan.

2021-11-18 Thread Jan Hubicka via Gcc-patches
> > > I don't know what the guidance is on using vec in IPA passes > > > but with respect to existing practice elsewhere, there are > > > existing uses of vec and auto_vec with non-POD types and vec > > > does work with them (see the vec_default_construct and > > > vec_copy_construct templates,

Re: [PATCH] IPA: fix reproducibility in IPA MOD REF

2021-11-18 Thread Jan Hubicka via Gcc-patches
> > > > > > Isn't problem that the following code > > > > > >past_flags.reserve_exact (summary->arg_flags.length ()); > > >past_flags.splice (summary->arg_flags); > > >past_retslot_flags = summary->retslot_flags; > > > > Aha, that makes sense.

Re: [PATCH] IPA: use cgraph_node instance

2021-11-18 Thread Jan Hubicka via Gcc-patches
> Hi. > > This is a refactoring I noticed. > > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? > Thanks, > Martin > > gcc/ChangeLog: > > * ipa-modref.c (analyze_function): Use fnode instead of repeated > cgraph_node::get

Re: [PATCH] Fix IPA modref ubsan.

2021-11-18 Thread Jan Hubicka via Gcc-patches
> On 11/18/21 5:41 AM, Jan Hubicka via Gcc-patches wrote: > > > modref_tree::merge(modref_tree*, > > > vec*, modref_parm_map*, bool) > > > > > > is called with modref_parm_map chain_map; > > > > > > The variable has uninit

Re: [PATCH] IPA: fix reproducibility in IPA MOD REF

2021-11-18 Thread Jan Hubicka via Gcc-patches
> On 11/18/21 19:22, Jan Hubicka wrote: > > > Supported LTO compression algorithms: zlib zstd > > > gcc version 12.0.0 2028 (experimental) (GCC) > > > /usr/bin/ld: ./xxx.ltrans0.ltrans.o: warning: relocation against > > > `lm_read_ctl_dict_size_n_lmclass_used' in read-only section `.text' > >

Re: [PATCH] Fix rs6000 predicates.md use of decl_replaceable_p

2021-11-18 Thread Jan Hubicka via Gcc-patches
> --- a/gcc/config/rs6000/predicates.md > +++ b/gcc/config/rs6000/predicates.md > @@ -1086,7 +1086,9 @@ (define_predicate "current_file_function_operand" > (match_test "(DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op)) > && (SYMBOL_REF_LOCAL_P (op) >

Re: [PATCH] IPA: fix reproducibility in IPA MOD REF

2021-11-18 Thread Jan Hubicka via Gcc-patches
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? > Thanks, > Martin > > gcc/ChangeLog: > > * ipa-modref.c (analyze_function): Do not execute the code > only if dump_file != NULL. > --- > gcc/ipa-modref.c | 14 +++--- > 1

Re: [PATCH] IPA: fix reproducibility in IPA MOD REF

2021-11-18 Thread Jan Hubicka via Gcc-patches
> Supported LTO compression algorithms: zlib zstd > gcc version 12.0.0 2028 (experimental) (GCC) > /usr/bin/ld: ./xxx.ltrans0.ltrans.o: warning: relocation against > `lm_read_ctl_dict_size_n_lmclass_used' in read-only section `.text' > /usr/bin/ld: ./xxx.ltrans0.ltrans.o: relocation

Re: [PATCH] Fix rs6000 predicates.md use of decl_replaceable_p

2021-11-18 Thread Jan Hubicka via Gcc-patches
> On Thu, Nov 18, 2021 at 2:07 PM Jan Hubicka wrote: > > > > > --- a/gcc/config/rs6000/predicates.md > > > +++ b/gcc/config/rs6000/predicates.md > > > @@ -1086,7 +1086,9 @@ (define_predicate "current_file_function_operand" > > > (match_test "(DEFAULT_ABI != ABI_AIX ||

Re: [PATCH] options: Make -Ofast switch off -fsemantic-interposition

2021-11-18 Thread Jan Hubicka via Gcc-patches
> Hi, > > On Fri, Nov 12 2021, Martin Jambor wrote: > > Hi, > > > > using -fno-semantic-interposition has been reported by various people > > to bring about considerable speed up at the cost of strict compliance > > to the ELF symbol interposition rules See for example > >

Finish lto parts of kill analysis

2021-11-17 Thread Jan Hubicka via Gcc-patches
Hi, this patch adds the IPA part of modref kill analysis. It just copies of what local code did alrady. I did not manage to push out all patches for modref I planned and I will wait for next stage1. This one however I would like to push since it is quite simple and it makes no sense to leave

Fix gamess miscompare

2021-11-17 Thread Jan Hubicka via Gcc-patches
Hi, this patch fixes bug in streaming in modref access tree that now cause a failure of gamess benchmark. The bug is quite old (present in GCC11 release) but it needs quite interesting series of events to manifest. In particular 1) At lto time ISRA turns some parameters passed by reference to

Re: [PATCH] options: Make -Ofast switch off -fsemantic-interposition

2021-11-19 Thread Jan Hubicka via Gcc-patches
> > Hi, > > > > On Fri, Nov 12 2021, Martin Jambor wrote: > > > Hi, > > > > > > using -fno-semantic-interposition has been reported by various people > > > to bring about considerable speed up at the cost of strict compliance > > > to the ELF symbol interposition rules See for example > > >

Remove gimple_static_chain test disabling modref in ref_maybe_used_in_call_p

2021-11-19 Thread Jan Hubicka via Gcc-patches
Hi, this patch removes test for function not having call chain guarding modref use in ref_maybe_used_by_call_p_1. It never made sense since modref treats call chain accesses explicitly. It was however copied from earlier check for ECF_CONST (which seems dubious too, but I would like to discuss it

Fix some side cases of side effects analysis

2021-11-11 Thread Jan Hubicka via Gcc-patches
Hi, I wrote script comparing modref pure/const discovery with ipa-pure-const and found mistakes on both ends. I fixed ipa-pure-const in previous two patches. This plugs the case where modref was too optimistic in handling looping pure consts which were previously missed due to early exits on

Re: Fix recursion discovery in ipa-pure-const

2021-11-11 Thread Jan Hubicka via Gcc-patches
> On Thu, Nov 11, 2021 at 2:41 PM Jan Hubicka via Gcc-patches > wrote: > > > > Hi, > > We make self recursive functions as looping of fear of endless recursion. > > This is done correctly for local pure/const and for non-trivial SCCs in > > callgraph, b

Enable pure/const discovery in modref

2021-11-11 Thread Jan Hubicka via Gcc-patches
Hi, this patch enables the pure/const discovery in modref, so we newly can handle some extra cases, for example: struct a {int a,b,c;}; __attribute__ ((noinline)) int init (struct a *a) { a->a=1; a->b=2; a->c=3; } int const_fn () { struct a a; init (); return a.a + a.b + a.c; } Here

Fix noreturn discovery

2021-11-11 Thread Jan Hubicka via Gcc-patches
Hi, this patch fixes ipa-pure-const handling of noreturn flags. It is not safe to set it for interposable symbols and we should also set it for aliases (just like we do for other flags). This patch merely copies other flag handling and implements it here. Bootstrapped/regtested x86_64-linux,

Re: [PATCH] vect: Remove vec_outside/inside_cost fields

2021-11-11 Thread Jan Hubicka via Gcc-patches
> > Now afunc writes to __var_5_mma only indirectly so I think it is correct > > that > > we optimize the conditional out. > > > > Easy fix would be to add -fno-ipa-modref, but perhaps someone with > > better understanding of Fortran would help me to improve the testcase so > > the calls to

Re: Use modref summary to DSE calls to non-pure functions

2021-11-11 Thread Jan Hubicka via Gcc-patches
> > Hmm, I could try to do this, but possibly incrementally? > > You mean handle a argument specially for unknown param offset? > Yeah, I guess so. I think it is also pointer that was allocated and is going to be freed... > > > Basically I want to have > > > > foo () > > decl = {} > > > > To

Fix recursion discovery in ipa-pure-const

2021-11-11 Thread Jan Hubicka via Gcc-patches
Hi, We make self recursive functions as looping of fear of endless recursion. This is done correctly for local pure/const and for non-trivial SCCs in callgraph, but for trivial SCCs we miss the flag. I think it is bad decision since infinite recursion will run out of stack, but changing it upsets

Silence additional warning in gfortran.dg/do_subscript_3.f90

2021-11-10 Thread Jan Hubicka via Gcc-patches
Hi, the testcase tests for out of bound accesses warnings and with ipa-modref improvements it now triggers a new warning: /aux/hubicka/trunk-git/gcc/testsuite/gfortran.dg/do_subscript_3.f90:11:9: Warning: (1) /aux/hubicka/trunk-git/gcc/testsuite/gfortran.dg/do_subscript_3.f90:10:47: Warning:

Fix modref_tree::remap_params

2021-11-10 Thread Jan Hubicka via Gcc-patches
Hi, this patch fixes wrong compare in remap_params which triggers a wrong code with my followup patch. This needs backporting to gcc11 as well which I plan to do tomorrow. Bootstrapped/regtested x86_64-linux, comitted. gcc/ChangeLog: * ipa-modref-tree.h (modref_tree::remap_params): Fix

Extend modref by side-effect analysis

2021-11-10 Thread Jan Hubicka via Gcc-patches
Hi, this patch makes modref to also collect info whether function has side effects. This allows pure/const function detection and also handling functions which do store some memory in similar way as we handle pure/consts now. The code is symmetric to what ipa-pure-const does. Modref is actually

Use modref summary to DSE calls to non-pure functions

2021-11-10 Thread Jan Hubicka via Gcc-patches
Hi, this patch implements DSE using modref summaries: if function has no side effects besides storing to memory pointed to by its argument and if we can prove those stores to be dead, we can optimize out. So we handle for example: volatile int *ptr; struct a { int a,b,c; } a;

Introduce finalize method to modref_summary

2021-11-12 Thread Jan Hubicka via Gcc-patches
Hi, this patch adds finalize method that is called once summary is computed before it is used by optimizers. It adds convenient place to compute various flags as one for DSE Richard asked for. Bootstrapped/regtested x86_64-linux, will commit it shortly. gcc/ChangeLog: * ipa-modref.c

Fix ICE in tree-ssa-structalias

2021-11-12 Thread Jan Hubicka via Gcc-patches
Hi, this patch fixes ICE in sanity check of EAF flags determined: we can not escape/clobber/return param indirectly w/o reading it. I moved check earlier and fixed the wrong updates. Boottrapped/regtested x86_64-linux, comitted. Honza PR tree-optimization/103175 * ipa-modref.c

Re: [PATCH] options: Make -Ofast switch off -fsemantic-interposition

2021-11-12 Thread Jan Hubicka via Gcc-patches
> Hi, > > using -fno-semantic-interposition has been reported by various people > to bring about considerable speed up at the cost of strict compliance > to the ELF symbol interposition rules See for example > https://fedoraproject.org/wiki/Changes/PythonNoSemanticInterpositionSpeedup > > As

Enable ipa-sra for functions with fnspec attribute

2021-11-13 Thread Jan Hubicka via Gcc-patches
Hi, this patch enables some ipa-sra on fortran by allowing signature changes on functions with "fn spec" attribute when ipa-modref is enabled. This is possible since ipa-modref knows how to preserve things we trace in fnspec and fnspec generated by fortran forntend are quite simple and can be

Remember fnspec EAF flags in modref summary

2021-11-13 Thread Jan Hubicka via Gcc-patches
Hi, this patch stores eaf flags from fnspec to modref summaries. THis makes them survive signature changes and also improves IPA propagation in case modref is not able to autodetect given flag. Bootstrapped/regtested x86_64-linux, comitted. Honza gcc/ChangeLog: * attr-fnspec.h

Cleanup modref_access_node

2021-11-13 Thread Jan Hubicka via Gcc-patches
Hi, this patch moves member functions of modref_access_node from ipa-modref-tree.h to ipa-modref-tree.c since they become long and not fitting for inlines anyway. I also cleaned up the interface by making static insert method (which handles inserting accesses into a vector and optimizing them)

Enable more type attributes for signature changes

2021-11-13 Thread Jan Hubicka via Gcc-patches
Hi, this patch whitelists attributes that are safe for attribute changes and also makes access attribute dropped if function sigunature is changed. We could do better by updating the attribute, but doing so seems to be bit snowballing since with LTO the warnings produced seems bit confused. We

Re: [PATCH v2] IPA: Provide a mechanism to register static DTORs via cxa_atexit.

2021-11-13 Thread Jan Hubicka via Gcc-patches
> sheesh … EWRONGREVISEDPATCH > > > On 5 Nov 2021, at 13:08, Iain Sandoe wrote: > > > > I tried enabling this on x86-64-linux (just for interest) and it seems to > > work > > OK there too - but that testing revealed a thinko that didn’t show with a > > a normal regstrap. > > … now with the

Re: Basic kill analysis for modref

2021-11-15 Thread Jan Hubicka via Gcc-patches
> > > + if (always_executed > > > + && callee_summary->kills.length () > > > + && (!cfun->can_throw_non_call_exceptions > > > + || !stmt_could_throw_p (cfun, stmt))) > > > +{ > > > + /* Watch for self recursive updates. */ > > > + auto_vec saved_kills; > > > + > >

Re: Basic kill analysis for modref

2021-11-16 Thread Jan Hubicka via Gcc-patches
> chain_map isn't initialized. > > This caused: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103262 > Hi, this is patch I comitted that moves the misplaced hunk. gcc/ChangeLog: PR ipa/103262 * ipa-modref.c (merge_call_side_effects):

Re: Cleanup hadnling of modref access_nodes in tree-ssa-alias and tree-ssa-dse

2021-11-14 Thread Jan Hubicka via Gcc-patches
Hi, this is variant I comitted. Commonizing the code exposed that I can drop memory walking when parameter passed is NULL (under assumption of flag_delete_null_pointer_checks) since it can not point to useful memory. This was already done in tree-ssa-alias, but not in tree-ssa-dse. This needed

Re: [r12-5236 Regression] FAIL: gcc.dg/tree-prof/merge_block.c scan-tree-dump-not optimized "Invalid sum" on Linux/x86_64

2021-11-14 Thread Jan Hubicka via Gcc-patches
> On Linux/x86_64, > > 5aa91072e24c1e16a5ec641b48b64c9c9f199f13 is the first bad commit > commit 5aa91072e24c1e16a5ec641b48b64c9c9f199f13 > Author: Jan Hubicka > Date: Sat Nov 13 22:25:23 2021 +0100 > > Implement DSE of dead functions calls storing memory. > > caused > > FAIL:

Re: [PATCH] tsan: remove not needed -ldl in options

2021-11-14 Thread Jan Hubicka via Gcc-patches
> Tested and pushed to master as obvious. > > Martin > > gcc/testsuite/ChangeLog: > > * c-c++-common/tsan/free_race.c: Remove unnecessary -ldl. > * c-c++-common/tsan/free_race2.c: Likewise. Thank you, I cut it from the other testcase and forgot to remove it. Patch is OK. Honza

Cleanup hadnling of modref access_nodes in tree-ssa-alias and tree-ssa-dse

2021-11-14 Thread Jan Hubicka via Gcc-patches
Hi, this patch implements the cleanup suggested by Richard to move code getting tree op from access_node and stmt to a common place. I also commonized logic to build ao_ref. While I was on it I also replaced FOR_EACH_* by range for since they reads better. Bootstrapped/regtesed x86_64-linux,

Re: Use modref kills in tree-ssa-dse

2021-11-16 Thread Jan Hubicka via Gcc-patches
> > Not sure, tree-ssa-dse.c doesn't seem to handle MEM_REF with offset? > > VN has adjust_offsets_for_equal_base_address for this purpose. I > agree that some common functionality like > > bool > get_relative_extent_of (const ao_ref *base, const ao_ref *ref, >

Re: Basic kill analysis for modref

2021-11-12 Thread Jan Hubicka via Gcc-patches
> > I wonder why we bother producing summaries for things that do not > bind locally? The summary->kills.length () has an upper bound? Because of local aliases. The size of the array is capped by param_max_modref_accesses which is 16. > > > + && summary->kills.length ()) > > + { > > +

Fix ipa-modref pure/const discovery

2021-11-12 Thread Jan Hubicka via Gcc-patches
Hi, this patch fixes bug I introduced while breaking up the bigger change. We currently can not use pure/const to discover looping pures since lack of global memory writes/stores does not imply we can CSE on the function. THis is witnessed by testsuite doing volatile asm or also can happen if

Re: Use modref summary to DSE calls to non-pure functions

2021-11-12 Thread Jan Hubicka via Gcc-patches
Hi, this is updated patch. It moves the summary walk checking if we can possibly suceed on dse to summary->finalize member function so it is done once per summary and refactors dse_optimize_call to be called from dse_optimize_stmt after early checks. I did not try to handle the special case of

Use modref kills in tree-ssa-dse

2021-11-14 Thread Jan Hubicka via Gcc-patches
Hi, this patch extends tree-ssa-dse to use modref kill summary to clear live_bytes. This makes it possible to remove calls that are killed in parts. I noticed that DSE duplicates the logic of tree-ssa-alias that is mathing bases of memory accesses. Here operands_equal_p (base1, base,

Track nondeterminism and interposable calls in ipa-modref

2021-11-14 Thread Jan Hubicka via Gcc-patches
Hi, This patch adds tracking of two new flags in ipa-modref: nondeterministic and calls_interposable. First is set when function does something that is not guaranteed to be the same if run again (volatile memory access, volatile asm or external function call). Second is set if function calls

Re: Basic kill analysis for modref

2021-11-14 Thread Jan Hubicka via Gcc-patches
> > > > I think you want get_addr_base_and_unit_offset here. All > > variable indexed addresses are in separate stmts. That also means > > you can eventually work with just byte sizes/offsets? > > Will do. The access range in modref summary is bit based (since we want > to disabiguate

Re: [PATCH] tree-optimization/103168 - Improve VN of pure function calls

2021-11-24 Thread Jan Hubicka via Gcc-patches
> This improves value-numbering of calls that read memory, calls > to const functions with aggregate arguments and calls to > pure functions where the latter include const functions we > demoted to pure for the fear of interposing with a less > optimized version. Note that for pure functions we

Re: [PATCH] tree-optimization/103168 - Improve VN of pure function calls

2021-11-24 Thread Jan Hubicka via Gcc-patches
> > Yes, note that we don't have callused unless IPA PTA is enabled, > but it might be salveagable from IPA reference info? What we're > missing is a stmt_clobbers_pt_solution_p, or rather a reasonably > cheap way to construct an ao_ref covering all of a points-to > solution. The not-so-cheap

Improve -fprofile-report

2021-11-27 Thread Jan Hubicka via Gcc-patches
Hi, Profile-report was never properly updated after switch to new profile representation. This patch fixes the way profile mismatches are calculated: we used to collect separately count and freq mismatches, while now we have only counts & probabilities. So we verify - in count: that total

Compare guessed profile frequencies to actual profile feedback in profile dump file

2021-11-28 Thread Jan Hubicka via Gcc-patches
Hi, this patch adds simple code to dump and compare frequencies of basic blocks read from the profile feedback and frequencies guessed statically. It dumps basic blocks in the order of decreasing frequencies from feedback along with guessed frequencies and histograms. It makes it to possible spot

Re: [PATCH] ipa: Careful processing ANCESTOR jump functions and NULL pointers (PR 103083)

2021-11-27 Thread Jan Hubicka via Gcc-patches
> Hi, > > IPA_JF_ANCESTOR jump functions are constructed also when the formal > parameter of the caller is first checked whether it is NULL and left > as it is if it is NULL, to accommodate C++ casts to an ancestor class. > > The jump function type was invented for devirtualization and IPA-CP >

Fix handling of static chain in modref

2021-11-24 Thread Jan Hubicka via Gcc-patches
Hi, this patch fixes wrong code issue where modref did not propagate flags for static chain in ipa_merge_modref_summary_after_inlininig. It is a place I missed to update in original patch extending return slot tracking to static chain. Unlike return slot we need to propagate flags here (return

Fix fail in inline-9.c testcase

2021-11-26 Thread Jan Hubicka via Gcc-patches
Hi, it turns out that I made testcase for value range propagation (which was disabled by accidental return statement) but the testcase was confused by partial inlininig. The right number of inlines is 2, since the function in question is first split and then both function and the split part

Fix wrong code caused by min_flags update in update_summary

2021-11-26 Thread Jan Hubicka via Gcc-patches
Hi update_escape_summary_1 has thinko where it compues proper min_flags but then stores original value (ignoring the fact whether there was a dereference in the escape point). Bootstrapped/regtested and comitted. PR ipa/103432 * ipa-modref.c (update_escape_summary_1): Fix handling

Minod modref tweeks

2021-11-26 Thread Jan Hubicka via Gcc-patches
Hi, while working on analyzing the previous miscomple I made dumps easier to read by dumping cgraph_node name rather then cfun name in function being analysed and I also fixed minor issue with ECF flags merging when updating inline summary. gcc/ChangeLog: 2021-11-26 Jan Hubicka *

Re: [PATCH] ipa: Teach IPA-CP transformation about IPA-SRA modifications (PR 103227)

2021-11-25 Thread Jan Hubicka via Gcc-patches
> > gcc/ChangeLog: > > 2021-11-23 Martin Jambor > > PR ipa/103227 > * ipa-prop.h (ipa_get_param): New overload. Move bits of the existing > one to the new one. > * ipa-param-manipulation.h (ipa_param_adjustments): New member > function

Re: [PATCH] Remove dead code and function

2021-11-25 Thread Jan Hubicka via Gcc-patches
> The only use of get_alias_symbol is gated by a gcc_unreachable (), > so the following patch gets rid of it. > > Bootstrapped and tested on x86_64-unknown-linux-gnu, OK? OK, thanks! Honza

Do not check gimple_call_chain in tree-ssa-alias

2021-11-25 Thread Jan Hubicka via Gcc-patches
Hi, this pach removes gimple_call_cahin checkin ref_maybe_used_by_call_p that disables check for CONST functions. I suppose it was meant to allow consts to read variables from the static chain but this is not what other places do. The testcase: int main() { int a =0;

Re: [PATCH] [RFC] unreachable returns

2021-11-25 Thread Jan Hubicka via Gcc-patches
> We have quite a number of "default" returns that cannot be reached. > One is particularly interesting since it says (see patch below): > > default: >gcc_unreachable (); > } >/* We can get here with --disable-checking. */ >return false; > > which suggests that _maybe_

Improve modref tracking of base pointers

2021-11-22 Thread Jan Hubicka via Gcc-patches
Hi, on exchange2 benchamrk we miss some useful propagation because modref gives up very early on analyzing accesses through pointers. For example in int test (int *a) { int i; for (i=0; a[i];i++); return i+a[i]; } We are not able to determine that a[i] accesses are relative to a. This is

Fix crash in gamess

2021-11-13 Thread Jan Hubicka via Gcc-patches
Hi, this patch adds debug counters for pure/const discover and fixes somewhat embarrasing pasto I made while breaking out ipa_make_function_* helpers out of propagate_pure_const which led to wrong function being marked as pure that in turn leads to wrong code. My apologizes for that.

Re: Enable pure/const discovery in modref

2021-11-12 Thread Jan Hubicka via Gcc-patches
> Hi Honza, > > On Thu, 11 Nov 2021 17:39:18 +0100 > Jan Hubicka via Gcc-patches wrote: > > > diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c > > index 422b52fba4b..550bdeded16 100644 > > --- a/gcc/ipa-pure-const.c > > +++ b/gcc/

Fix wrong code with pure functions

2021-11-12 Thread Jan Hubicka via Gcc-patches
Fix wrong code with pure functions I introduced bug into find_func_aliases_for_call in handling pure functions. Instead of reading global memory pure functions are believed to write global memory. This results in misoptimization of the testcase at -O1. The change to pta-callused.c updates the

Re: [PATCH] vect: Remove vec_outside/inside_cost fields

2021-11-11 Thread Jan Hubicka via Gcc-patches
> > > > > > I think the patch causes the following on x86_64-linux-gnu: > > > FAIL: gfortran.dg/inline_matmul_17.f90 -O scan-tree-dump-times > > > optimized "matmul_r4" 2 > > > > I get that failure even with d70ef65692f (from before the patches > > I committed today). > > Sorry, you are

Fix optimization difference caused by -fdump-ipa-inline

2021-11-16 Thread Jan Hubicka via Gcc-patches
Hi, This patch fixes a bug that caused some optimizations to be dropped with -fdump-ipa-inline. gcc/ChangeLog: 2021-11-17 Jan Hubicka PR ipa/103246 * ipa-modref.c (ipa_merge_modref_summary_after_inlining): Fix clearing of to_info_lto diff --git a/gcc/ipa-modref.c

Re: [PATCH] Fix IPA modref ubsan.

2021-11-18 Thread Jan Hubicka via Gcc-patches
> modref_tree::merge(modref_tree*, vec va_heap, vl_ptr>*, modref_parm_map*, bool) > > is called with modref_parm_map chain_map; > > The variable has uninitialized m.parm_offset_known and it is accessed > here: > > gcc/ipa-modref-tree.h:572 a.parm_offset_known &= m.parm_offset_known; > > Ready

Fix modref and hadnling of some builtins

2021-11-12 Thread Jan Hubicka via Gcc-patches
Hi, 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:

Re: [PATCH] ipa: Teach IPA-CP transformation about IPA-SRA modifications (PR 103227)

2021-11-25 Thread Jan Hubicka via Gcc-patches
> > > > In ipa-modref I precompute this to map so we do not need to walk all > > params, but the loop is probably not bad since functions do not have > > tens of thousdands parameters :) > > The most I have seen is about 70 and those were big outliers. > > I was thinking of precomputing it

Re: Use modref summary to DSE calls to non-pure functions

2021-11-11 Thread Jan Hubicka via Gcc-patches
> > + /* Unlike alias oracle we can not skip subtrees based on TBAA check. > > + Count the size of the whole tree to verify that we will not need too > > many > > + tests. */ > > + FOR_EACH_VEC_SAFE_ELT (summary->stores->bases, i, base_node) > > +FOR_EACH_VEC_SAFE_ELT

Re: Use modref summary to DSE calls to non-pure functions

2021-11-11 Thread Jan Hubicka via Gcc-patches
Hi, > > No, I think if it turns out useful then we want a way to have such ref > represented by an ao_ref. Note that when we come from a > ref tree we know handled-components only will increase offset, > only the base MEM_REF can contain a pointer subtraction (but > the result of that is the

Basic kill analysis for modref

2021-11-11 Thread Jan Hubicka via Gcc-patches
Hi, This patch enables optimization of stores that are killed by calls. Modref summary is extended by array containing list of access ranges, relative to function parameters, that are known to be killed by the function. This array is collected during local analysis and optimized (so separate

Add EAF_NOT_RETURNED_DIRECTLY

2021-11-01 Thread Jan Hubicka via Gcc-patches
Hi, this patch adds EAF_NOT_RETURNED_DIRECTLY which works similarly as EAF_NODIRECTESCAPE. Values pointed to by a given argument may be returned but not the argument itself. This helps PTA quite noticeably because we mostly care about tracking points to which given memory location can escape. I

ipa-modref cleanup

2021-11-02 Thread Jan Hubicka via Gcc-patches
Hi, this patch is a small refactoring of ipa-modref to make it bit more C++y by moving logic analyzing ssa name flags to a class and I also moved the anonymous namespace markers so we do not export unnecessary stuff. There are no functional changes. Bootstrapped/regtested x86_64-linux, will

Re: ipa-modref cleanup

2021-11-02 Thread Jan Hubicka via Gcc-patches
> It broke GCC bootstrap: > > https://gcc.gnu.org/pipermail/gcc-regression/2021-November/075676.html > > In file included from ../../src-master/gcc/coretypes.h:474, > from ../../src-master/gcc/expmed.c:26: > In function ‘poly_uint16 mode_to_bytes(machine_mode)’, > inlined

Fix wrong code caused by ipa-modref retslot handling

2021-11-02 Thread Jan Hubicka via Gcc-patches
Hi, this patch fixes (quite nasty) thinko in how I propagate EAF flags from callee to caller. In this case some flags needs to be changed. In particular - EAF_NOT_RETURNED in callee does not really mean EAF_NOT_RETURNED in caller since we speak of different return values - if callee

Re: [PATCH] Fix loop split incorrect count and probability

2021-10-26 Thread Jan Hubicka via Gcc-patches
> On Tue, 26 Oct 2021, Xionghu Luo wrote: > > > > > > > On 2021/10/21 18:55, Richard Biener wrote: > > > On Thu, 21 Oct 2021, Xionghu Luo wrote: > > > > > >> > > >> > > >> On 2021/10/15 13:51, Xionghu Luo via Gcc-patches wrote: > > >>> > > >>> > > >>> On 2021/9/23 20:17, Richard Biener wrote:

Re: [PATCH] Fix loop split incorrect count and probability

2021-10-26 Thread Jan Hubicka via Gcc-patches
> > > That said, likely the profile update cannot be done uniformly > for all blocks of a loop? For the loop: for (i = 0; i < n; i = inc (i)) { if (ga) ga = do_something (); } to: for (i = 0; i < x; i = inc (i)) { if (true) ga = do_something (); if

Re: [PATCH v2 1/4] Fix loop split incorrect count and probability

2021-10-27 Thread Jan Hubicka via Gcc-patches
> > gcc/ChangeLog: > > * tree-ssa-loop-split.c (split_loop): Fix incorrect probability. > (do_split_loop_on_cond): Likewise. > --- > gcc/tree-ssa-loop-split.c | 25 - > 1 file changed, 16 insertions(+), 9 deletions(-) > > diff --git

Re: [PATCH v2 1/4] Fix loop split incorrect count and probability

2021-10-27 Thread Jan Hubicka via Gcc-patches
> As discussed yesterday, for loop of form > > for (...) > if (cond) > cond = something(); > else > something2 > > Split as > Say "if (cond)" has probability p, then individual statements scale as follows: loop1: pfor (...) p if (true) 1cond = something(); 1

Re: [PATCH v2 1/4] Fix loop split incorrect count and probability

2021-10-27 Thread Jan Hubicka via Gcc-patches
> On Wed, 27 Oct 2021, Jan Hubicka wrote: > > > > > > > gcc/ChangeLog: > > > > > > * tree-ssa-loop-split.c (split_loop): Fix incorrect probability. > > > (do_split_loop_on_cond): Likewise. > > > --- > > > gcc/tree-ssa-loop-split.c | 25 - > > > 1 file changed, 16

Re: [PATCH] ipa: Unshare expresseions before putting them into debug statements (PR 103099, PR 103107)

2021-11-08 Thread Jan Hubicka via Gcc-patches
> Hi, > > my recent patch to improve debug experience when there are removed > parameters (by ipa-sra or ipa-split) was not careful to unshare the > expressions that were then put into debug statements, which manifests > itself as PR 103099. This patch adds unsharing them using >

  1   2   3   4   5   >