[03/46] Remove unnecessary update of NUM_SLP_USES

2018-07-24 Thread Richard Sandiford
; 0); STMT_VINFO_NUM_SLP_USES (vinfo_for_stmt (stmt))--; } But after transform this update is redundant even for statements that do exist, so it seems better to skip this loop for the final teardown. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (vect_free_slp_insta

[05/46] Fix make_ssa_name call in vectorizable_reduction

2018-07-24 Thread Richard Sandiford
, new_stmt); before creating new_stmt. This method of creating statements probably needs cleaning up, but that's for another day... 2018-07-24 Richard Sandiford gcc/ * tree-vect-loop.c (vectorizable_reduction): Fix an instance in which make_ssa_name was called with new

[04/46] Factor out the test for a valid reduction input

2018-07-24 Thread Richard Sandiford
in a subroutine. 2018-07-24 Richard Sandiford gcc/ * tree-vect-loop.c (vect_valid_reduction_input_p): New function, split out from... (vect_is_slp_reduction): ...here... (vect_is_simple_reduction): ...and here. Remove repetition of tests that are a

[06/46] Add vec_info::add_stmt

2018-07-24 Thread Richard Sandiford
This patch adds a vec_info function for allocating and setting stmt_vec_infos. It's the start of a long process of removing the global stmt_vec_info array. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (stmt_vec_info): Move typedef earlier in file. (vec

[07/46] Add vec_info::lookup_stmt

2018-07-24 Thread Richard Sandiford
t rid of most other calls to vinfo_for_stmt. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (vec_info::lookup_stmt): Declare. * tree-vectorizer.c (vec_info::lookup_stmt): New function. * tree-vect-loop.c (vect_determine_vf_for_stmt): Use it instead

[08/46] Add vec_info::lookup_def

2018-07-24 Thread Richard Sandiford
This patch adds a vec_info helper for checking whether an operand is an SSA_NAME that is defined in the vectorisable region. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (vec_info::lookup_def): Declare. * tree-vectorizer.c (vec_info::lookup_def): New function

[09/46] Add vec_info::lookup_single_use

2018-07-24 Thread Richard Sandiford
This patch adds a helper function for seeing whether there is a single user of an SSA name, and whether that user has a stmt_vec_info. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (vec_info::lookup_single_use): Declare. * tree-vectorizer.c (vec_info

[10/46] Temporarily make stmt_vec_info a class

2018-07-24 Thread Richard Sandiford
g any comments or tried to make it pretty. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (stmt_vec_info): Temporarily change from a typedef to a wrapper class. (NULL_STMT_VEC_INFO): New macro. (vec_info::stmt_infos): Change to vec. (stmt_vec_info::ope

[11/46] Pass back a stmt_vec_info from vect_is_simple_use

2018-07-24 Thread Richard Sandiford
tries to clean up how operands are handled (with a view to allowing mixed vector sizes). 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (vect_is_simple_use): Add an optional stmt_vec_info * parameter before the optional gimple **. * tree-vect-stmts.c (vec

[13/46] Make STMT_VINFO_RELATED_STMT a stmt_vec_info

2018-07-24 Thread Richard Sandiford
This patch changes STMT_VINFO_RELATED_STMT from a gimple stmt to a stmt_vec_info. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (_stmt_vec_info::related_stmt): Change from a gimple stmt to a stmt_vec_info. (is_pattern_stmt_p): Update accordingly

[12/46] Make vect_finish_stmt_generation return a stmt_vec_info

2018-07-24 Thread Richard Sandiford
hole for this series. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (vect_finish_replace_stmt): Return a stmt_vec_info (vect_finish_stmt_generation): Likewise. * tree-vect-stmts.c (vect_finish_stmt_generation_1): Likewise. (vect_finish

[14/46] Make STMT_VINFO_VEC_STMT a stmt_vec_info

2018-07-24 Thread Richard Sandiford
This patch changes STMT_VINFO_VEC_STMT from a gimple stmt to a stmt_vec_info and makes the vectorizable_* routines pass back a stmt_vec_info to vect_transform_stmt. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (_stmt_vec_info::vectorized_stmt): Change from a gimple

[17/46] Make LOOP_VINFO_REDUCTIONS an auto_vec

2018-07-24 Thread Richard Sandiford
This patch changes LOOP_VINFO_REDUCTIONS from an auto_vec to an auto_vec. It also changes the associated vect_force_simple_reduction so that it takes and returns stmt_vec_infos instead of gimple stmts. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (_loop_vec_info::reductions

[15/46] Make SLP_TREE_VEC_STMTS a vec

2018-07-24 Thread Richard Sandiford
This patch changes SLP_TREE_VEC_STMTS from a vec to a vec. This involved making the same change to the phis vector in vectorizable_reduction, since SLP_TREE_VEC_STMTS is spliced into it here: phis.splice (SLP_TREE_VEC_STMTS (slp_node_instance->reduc_phis)); 2018-07-24 Richard Sandif

[16/46] Make STMT_VINFO_REDUC_DEF a stmt_vec_info

2018-07-24 Thread Richard Sandiford
This patch changes STMT_VINFO_REDUC_DEF from a gimple stmt to a stmt_vec_info. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (_stmt_vec_info::reduc_def): Change from a gimple stmt to a stmt_vec_info. * tree-vect-loop.c (vect_active_double_reduction_p

[20/46] Make *FIRST_ELEMENT and *NEXT_ELEMENT stmt_vec_infos

2018-07-24 Thread Richard Sandiford
This patch changes {REDUC,DR}_GROUP_{FIRST,NEXT} element from a gimple stmt to stmt_vec_info. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (_stmt_vec_info::first_element): Change from a gimple stmt to a stmt_vec_info. (_stmt_vec_info::next_element): Likewise

[18/46] Make SLP_TREE_SCALAR_STMTS a vec

2018-07-24 Thread Richard Sandiford
This patch changes SLP_TREE_SCALAR_STMTS from a vec to a vec. It's longer than the previous conversions but mostly mechanical. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (_slp_tree::stmts): Change from a vec to a vec. * tree-vect-slp.c (vect_free_slp

[19/46] Make vect_dr_stmt return a stmt_vec_info

2018-07-24 Thread Richard Sandiford
that are keyed off a data_reference would these days be better keyed off a stmt_vec_info, but it's more convenient to do that later in the series. The vect_dr_size calls that are left over do still benefit from this patch. 2018-07-24 Richard Sandiford gcc/ * tree-vectori

[22/46] Make DR_GROUP_SAME_DR_STMT a stmt_vec_info

2018-07-24 Thread Richard Sandiford
This patch changes STMT_VINFO_SAME_DR_STMT from a gimple stmt to a stmt_vec_info. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (_stmt_vec_info::same_dr_stmt): Change from a gimple stmt to a stmt_vec_info. * tree-vect-stmts.c (vectorizable_load): Update

[21/46] Make grouped_stores and reduction_chains use stmt_vec_infos

2018-07-24 Thread Richard Sandiford
This patch changes the SLP lists grouped_stores and reduction_chains from auto_vec to auto_vec. It was easier to do them together due to the way vect_analyze_slp is structured. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (vec_info::grouped_stores): Change from an

[23/46] Make LOOP_VINFO_MAY_MISALIGN_STMTS use stmt_vec_info

2018-07-24 Thread Richard Sandiford
This patch changes LOOP_VINFO_MAY_MISALIGN_STMTS from an auto_vec to an auto_vec. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (_loop_vec_info::may_misalign_stmts): Change from an auto_vec to an auto_vec. * tree-vect-data-refs.c

[24/46] Make stmt_info_for_cost use a stmt_vec_info

2018-07-24 Thread Richard Sandiford
This patch makes stmt_info_for_cost carry a stmt_vec_info instead of a gimple stmt. The structure is internal to the vectoriser, so targets aren't affected. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (stmt_info_for_cost::stmt): Replace with... (stmt_info_for

[26/46] Make more use of dyn_cast in tree-vect*

2018-07-24 Thread Richard Sandiford
If we use stmt_vec_infos to represent statements in the vectoriser, it's then more natural to use dyn_cast when processing the statement as an assignment, call, etc. This patch does that in a few more places. 2018-07-24 Richard Sandiford gcc/ * tree-vect-data-r

[25/46] Make get_earlier/later_stmt take and return stmt_vec_infos

2018-07-24 Thread Richard Sandiford
...and also make vect_find_last_scalar_stmt_in_slp return a stmt_vec_info. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (get_earlier_stmt, get_later_stmt): Take and return stmt_vec_infos rather than gimple stmts. Do not accept null arguments

[27/46] Remove duplicated stmt_vec_info lookups

2018-07-24 Thread Richard Sandiford
Various places called vect_dr_stmt or vinfo_for_stmt multiple times on the same input. This patch makes them reuse the earlier result. It also splits a couple of single vinfo_for_stmt calls out into separate statements so that they can be reused in later patches. 2018-07-24 Richard Sandiford

[29/46] Use stmt_vec_info instead of gimple stmts internally (part 2)

2018-07-24 Thread Richard Sandiford
This second part handles the less mechnical cases, i.e. those that don't just involve swapping a gimple stmt for an existing stmt_vec_info. 2018-07-24 Richard Sandiford gcc/ * tree-vect-loop.c (vect_analyze_loop_operations): Look up the statement before passing

[28/46] Use stmt_vec_info instead of gimple stmts internally (part 1)

2018-07-24 Thread Richard Sandiford
This first part makes functions use stmt_vec_infos instead of gimple stmts in cases where the stmt_vec_info was already available and where the change is mechanical. Most of it is just replacing "stmt" with "stmt_info". 2018-07-24 Richard Sandiford gcc/ * t

[30/46] Use stmt_vec_infos rather than gimple stmts for worklists

2018-07-24 Thread Richard Sandiford
2018-07-24 Richard Sandiford gcc/ * tree-vect-loop.c (vect_analyze_scalar_cycles_1): Change the type of the worklist from a vector of gimple stmts to a vector of stmt_vec_infos. * tree-vect-stmts.c (vect_mark_relevant, process_use

[31/46] Use stmt_vec_info in function interfaces (part 1)

2018-07-24 Thread Richard Sandiford
This first (less mechanical) part handles cases that involve changes in the callers or non-trivial changes in the functions themselves. 2018-07-24 Richard Sandiford gcc/ * tree-vect-data-refs.c (vect_describe_gather_scatter_call): Take a stmt_vec_info instead of a gcall

[34/46] Alter interface to vect_get_vec_def_for_stmt_copy

2018-07-24 Thread Richard Sandiford
just use the original value. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (vect_get_vec_defs_for_stmt_copy) (vect_get_vec_def_for_stmt_copy): Take a vec_info rather than a vect_def_type for the first argument. * tree-vect-st

[32/46] Use stmt_vec_info in function interfaces (part 2)

2018-07-24 Thread Richard Sandiford
This second part handles the mechanical change from a gimple stmt argument to a stmt_vec_info argument. It updates the function comments if they referred to the argument by name, but it doesn't try to retrofit mentions to other functions. 2018-07-24 Richard Sandiford gcc/ *

[35/46] Alter interfaces within vect_pattern_recog

2018-07-24 Thread Richard Sandiford
vect_pattern_recog_1 took a gimple_stmt_iterator as argument, but was only interested in the gsi_stmt, not anything else. This patch makes the associated routines operate directly on stmt_vec_infos. 2018-07-24 Richard Sandiford gcc/ * tree-vect-patterns.c (vect_mark_pattern_stmts

[33/46] Use stmt_vec_infos instead of vec_info/gimple stmt pairs

2018-07-24 Thread Richard Sandiford
This patch makes vect_record_max_nunits and vect_record_base_alignment take a stmt_vec_info instead of a vec_info/gimple pair. 2018-07-24 Richard Sandiford gcc/ * tree-vect-data-refs.c (vect_record_base_alignment): Replace vec_info and gimple stmt arguments with a

[36/46] Add a pattern_stmt_p field to stmt_vec_info

2018-07-24 Thread Richard Sandiford
This patch adds a pattern_stmt_p field to stmt_vec_info, so that it's possible to tell whether the statement is a pattern statement without referring to other statements. The new field goes in what was previously a hole in the structure, so the size is the same as before. 2018-07-24 Ri

[37/46] Associate alignment information with stmt_vec_infos

2018-07-24 Thread Richard Sandiford
data_references. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (STMT_VINFO_TARGET_ALIGNMENT): New macro. (DR_VECT_AUX, DR_MISALIGNMENT, SET_DR_MISALIGNMENT) (DR_TARGET_ALIGNMENT): Delete. (set_dr_misalignment, dr_misalignment, aligned_access_p

[38/46] Pass stmt_vec_infos instead of data_references where relevant

2018-07-24 Thread Richard Sandiford
the data_reference. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (vect_supportable_dr_alignment): Take a stmt_vec_info rather than a data_reference. * tree-vect-data-refs.c (vect_calculate_target_alignment) (vect_compute_data_ref_alignment

[39/46] Replace STMT_VINFO_UNALIGNED_DR with the associated statement

2018-07-24 Thread Richard Sandiford
After previous changes, it makes more sense to record which stmt's access is going to be aligned via peeling, rather than the associated scalar data reference. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (_loop_vec_info::unaligned_dr): Replace

[40/46] Add vec_info::lookup_dr

2018-07-24 Thread Richard Sandiford
Previous patches got rid of a lot of calls to vect_dr_stmt. This patch replaces the remaining ones with calls to a new vec_info::lookup_dr function, so that the lookup is relative to a particular vec_info rather than to global state. 2018-07-24 Richard Sandiford gcc/ * tree

[41/46] Add vec_info::remove_stmt

2018-07-24 Thread Richard Sandiford
This patch adds a new helper function for permanently removing a statement and its associated stmt_vec_info. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (vec_info::remove_stmt): Declare. * tree-vectorizer.c (vec_info::remove_stmt): New function. * tree-vect

[42/46] Add vec_info::replace_stmt

2018-07-24 Thread Richard Sandiford
This patch adds a helper for replacing a stmt_vec_info's statement with a new statement. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (vec_info::replace_stmt): Declare. * tree-vectorizer.c (vec_info::replace_stmt): New function. * tree-vect-

[43/46] Make free_stmt_vec_info take a stmt_vec_info

2018-07-24 Thread Richard Sandiford
o the actual freeing, since there's no longer a need to do it before resetting the gimple_uids. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (free_stmt_vec_info): Take a stmt_vec_info rather than a gimple stmt. * tree-vect-stmts.c (free_stmt_vec_info): Likewi

[44/46] Remove global vinfo_for_stmt-related routines

2018-07-24 Thread Richard Sandiford
rid of: - vinfo_for_stmt - stmt_vec_info_vec - set_stmt_vec_info_vec since nothing now uses them. This was the main goal of the series. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (vec_info::new_vinfo_for_stmt) (vec_info::set_vinfo_for_stmt, vec_info

[45/46] Remove vect_stmt_in_region_p

2018-07-24 Thread Richard Sandiford
Unlike the old vinfo_for_stmt, vec_info::lookup_stmt can cope with any statement, so there's no need to check beforehand that the statement is part of the vectorisable region. This means that there are no longer any calls to vect_stmt_in_region_p. 2018-07-24 Richard Sandiford

[46/46] Turn stmt_vec_info back into a typedef

2018-07-24 Thread Richard Sandiford
This patch removes the stmt_vec_info wrapper class added near the beginning of the series and turns stmt_vec_info back into a typedef. 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (stmt_vec_info): Turn back into a typedef. (NULL_STMT_VEC_INFO): Delete

Avoid &LOOP_VINFO_MASKS for bb vectorisation (PR 86618)

2018-07-24 Thread Richard Sandiford
r262589 introduced another instance of the bug fixed in r258131. Tested on aarch64-linux-gnu and applied as obvious. Richard 2018-07-24 Richard Sandiford gcc/ PR tree-optimization/86618 * tree-vect-stmts.c (vectorizable_call): Don't take the address

Fix ceil_log2(0) (PR 86644)

2018-07-24 Thread Richard Sandiford
<< ceil_log2 (precision); return MAX (precision, BITS_PER_UNIT); } ceil_log2 (0) returned 64 rather than 0, leading to 1 << 64, which is UB. Tested on aarch64-linux-gnu, aarch64_be-elf and x86_64-linux-gnu. OK to install? Richard 2018-07-24 Richard Sandiford gcc/ * hwint.

Re: [14/46] Make STMT_VINFO_VEC_STMT a stmt_vec_info

2018-07-25 Thread Richard Sandiford
Richard Biener writes: > On Tue, Jul 24, 2018 at 11:58 AM Richard Sandiford > wrote: >> >> This patch changes STMT_VINFO_VEC_STMT from a gimple stmt to a >> stmt_vec_info and makes the vectorizable_* routines pass back >> a stmt_vec_info to vect_transform_stmt.

Re: [36/46] Add a pattern_stmt_p field to stmt_vec_info

2018-07-25 Thread Richard Sandiford
Richard Biener writes: > On Tue, Jul 24, 2018 at 12:07 PM Richard Sandiford > wrote: >> >> This patch adds a pattern_stmt_p field to stmt_vec_info, so that it's >> possible to tell whether the statement is a pattern statement without >> referring to other stat

Re: [38/46] Pass stmt_vec_infos instead of data_references where relevant

2018-07-25 Thread Richard Sandiford
Richard Biener writes: > On Tue, Jul 24, 2018 at 12:08 PM Richard Sandiford > wrote: >> >> This patch makes various routines (mostly in tree-vect-data-refs.c) >> take stmt_vec_infos rather than data_references. The affected routines >> are really dealing with the

Re: [36/46] Add a pattern_stmt_p field to stmt_vec_info

2018-07-26 Thread Richard Sandiford
Richard Biener writes: > On Wed, Jul 25, 2018 at 1:09 PM Richard Sandiford > wrote: >> >> Richard Biener writes: >> > On Tue, Jul 24, 2018 at 12:07 PM Richard Sandiford >> > wrote: >> >> >> >> This patch adds a pattern_stmt_p field t

Re: [37/46] Associate alignment information with stmt_vec_infos

2018-07-26 Thread Richard Sandiford
Richard Biener writes: > On Tue, Jul 24, 2018 at 12:08 PM Richard Sandiford > wrote: >> >> Alignment information is really a property of a stmt_vec_info >> (and the way we want to vectorise it) rather than the original scalar dr. >> I think that was true eve

Re: [38/46] Pass stmt_vec_infos instead of data_references where relevant

2018-07-26 Thread Richard Sandiford
Richard Sandiford writes: > Richard Biener writes: >> On Tue, Jul 24, 2018 at 12:08 PM Richard Sandiford >> wrote: >>> >>> This patch makes various routines (mostly in tree-vect-data-refs.c) >>> take stmt_vec_infos rather than data_references. The aff

[39/46 v2] Change STMT_VINFO_UNALIGNED_DR to a dr_vec_info

2018-07-26 Thread Richard Sandiford
[Updated after new 37/46 and 38/46] After previous changes, it makes more sense for STMT_VINFO_UNALIGNED_DR to be dr_vec_info rather than a data_reference. 2018-07-26 Richard Sandiford gcc/ * tree-vectorizer.h (_loop_vec_info::unaligned_dr): Change to dr_vec_info

[40/46 v2] Add vec_info::lookup_dr

2018-07-26 Thread Richard Sandiford
[Updated after new 37/46 and 38/46. 41 onwards are unaffected.] This patch replaces DR_VECT_AUX and vect_dr_stmt with a new vec_info::lookup_dr function, so that the lookup is relative to a particular vec_info rather than to global state. 2018-07-26 Richard Sandiford gcc/ * tree

[committed] Resync inline implementation of ceil_log2 (PR 86506)

2018-07-30 Thread Richard Sandiford
In r262961 I only updated the out-of-line copy of ceil_log2. This patch applies the same change to the other (inline) one. Tested on aarch64-linux-gnu and x86_64-linux-gnu. Applied as obvious. Richard 2018-07-30 Richard Sandiford gcc/ * hwint.h (ceil_log2): Resync with hwint.c

[00/11] Add a vec_basic_block of scalar statements

2018-07-30 Thread Richard Sandiford
This series puts the statements that need to be vectorised into a "vec_basic_block" structure of linked stmt_vec_infos, and then puts pattern statements into this block rather than hanging them off the original scalar statement. Partly this is clean-up, since making pattern statements more like fi

[01/11] Schedule SLP earlier

2018-07-30 Thread Richard Sandiford
vect_transform_loop used to call vect_schedule_slp lazily when it came across the first SLP statement, but it seems easier to do it before the main loop. 2018-07-30 Richard Sandiford gcc/ * tree-vect-loop.c (vect_transform_loop_stmt): Remove slp_scheduled argument

[02/11] Remove vect_schedule_slp return value

2018-07-30 Thread Richard Sandiford
Nothing now uses the vect_schedule_slp return value, so it's not worth propagating the value through vect_schedule_slp_instance. 2018-07-30 Richard Sandiford gcc/ * tree-vectorizer.h (vect_schedule_slp): Return void. * tree-vect-slp.c (vect_schedule_slp_instance): Lik

[03/11] Remove vect_transform_stmt grouped_store argument

2018-07-30 Thread Richard Sandiford
Nothing now uses the grouped_store value passed back by vect_transform_stmt, so we might as well remove it. 2018-07-30 Richard Sandiford gcc/ * tree-vectorizer.h (vect_transform_stmt): Remove grouped_store argument. * tree-vect-stmts.c (vect_transform_stmt): Likewise

[04/11] Add a vect_orig_stmt helper function

2018-07-30 Thread Richard Sandiford
This patch just adds a helper function for going from a potential pattern statement to the original scalar statement. 2018-07-30 Richard Sandiford gcc/ * tree-vectorizer.h (vect_orig_stmt): New function. * tree-vect-data-refs.c (vect_preserves_scalar_order_p): Use it

[05/11] Add a vect_stmt_to_vectorize helper function

2018-07-30 Thread Richard Sandiford
pattern statements if appropriate. 2018-07-30 Richard Sandiford gcc/ * tree-vectorizer.h (vect_stmt_to_vectorize): New function. * tree-vect-loop.c (vect_update_vf_for_slp): Use it. (vectorizable_reduction): Likewise. * tree-vect-slp.c (vect_analyze_slp_instance

[06/11] Handle VMAT_INVARIANT separately

2018-07-30 Thread Richard Sandiford
sue. Richi's suggestion of using a vector of vector statements would let us reuse one statement for all copies. 2018-07-30 Richard Sandiford gcc/ * tree-vectorizer.h (vect_create_data_ref_ptr): Remove inv_p parameter. * tree-vect-data-refs.c (vect_create_data_ref_ptr)

[07/11] Use single basic block array in loop_vec_info

2018-07-30 Thread Richard Sandiford
Richard Sandiford gcc/ * tree-vect-loop.c (_loop_vec_info::_loop_vec_info): Use the result of dfs_enumerate_from when constructing stmt_vec_infos, instead of additionally calling get_loop_body. Index: gcc/tree-vect-loop.c

[08/11] Make hoist_defs_of_uses use vec_info::lookup_def

2018-07-30 Thread Richard Sandiford
ng in its own right, but it's a prerequisite for the next patch, which needs to update the stmt_vec_infos of the hoisted statements. 2018-07-30 Richard Sandiford gcc/ * tree-vect-stmts.c (hoist_defs_of_uses): Use vec_info::lookup_def instead of gimple_nop_p and flow_b

[09/11] Add a vec_basic_block structure

2018-07-30 Thread Richard Sandiford
of phis specially, and code that does can still do so. Having a single list simplifies code that wants to look at every scalar phi or stmt in isolation. 2018-07-30 Richard Sandiford gcc/ * tree-vectorizer.h (vec_basic_block): New structure. (vec_info::blocks, _stmt_vec_info::bl

[10/11] Make the vectoriser do its own DCE

2018-07-30 Thread Richard Sandiford
ng the few cases in which the vector code needs part of the original scalar code to be kept around. 2018-07-30 Richard Sandiford gcc/ * tree-vectorizer.h (_stmt_vec_info::used_by_vector_code_p): New member variable. (vect_mark_used_by_vector_code

[11/11] Insert pattern statements into vec_basic_blocks

2018-07-30 Thread Richard Sandiford
The point of this patch is to put pattern statements in the same vec_basic_block as the statements they replace, with the pattern statements for S coming between S and S's original predecessor. This removes the need to handle them specially in various places. 2018-07-30 Richard Sandiford

Re: Fold pointer range checks with equal spans

2018-07-30 Thread Richard Sandiford
[Sorry, somehow missed this till now] Richard Biener writes: > On Mon, Jul 23, 2018 at 5:05 PM Richard Sandiford > wrote: >> >> Marc Glisse writes: >> > On Fri, 20 Jul 2018, Richard Sandiford wrote: >> > >> >> --- gcc/match.pd 2018-07-18

Re: [PATCH] combine: Allow combining two insns to two insns

2018-07-31 Thread Richard Sandiford
Christophe Lyon writes: > On Mon, 30 Jul 2018 at 18:09, Segher Boessenkool > wrote: >> >> On Tue, Jul 24, 2018 at 05:18:41PM +, Segher Boessenkool wrote: >> > This patch allows combine to combine two insns into two. This helps >> > in many cases, by reducing instruction path length, and also

Re: [18/46] Make SLP_TREE_SCALAR_STMTS a vec

2018-07-31 Thread Richard Sandiford
Richard Biener writes: > On Tue, Jul 24, 2018 at 12:01 PM Richard Sandiford > wrote: >> >> This patch changes SLP_TREE_SCALAR_STMTS from a vec to >> a vec. It's longer than the previous conversions >> but mostly mechanical. > > OK. I don't remembe

Re: [PATCH] Avoid infinite loop with duplicate anonymous union fields

2018-07-31 Thread Richard Sandiford
Hi, Thanks for submitting the patch. Bogdan Harjoc writes: > With fresh git sources and contrib/gcc_update the tests pass: > > === gcc Summary === > > # of expected passes 133500 > # of expected failures 422 > # of unsupported tests 2104 > > gcc-build/gcc/xgcc version 9.0.0 20180730 (experiment

Fix over-widening handling of COND_EXPRs (PR 86749)

2018-08-01 Thread Richard Sandiford
-linux-gnu (with and without SVE), aarch64_be-elf and x86_64-linux-gnu. OK to install? Richard 2018-08-01 Richard Sandiford gcc/ PR tree-optimization/86749 * tree-vect-patterns.c (vect_determine_min_output_precision_1): If the lhs is used in a COND_EXPR, check t

Fix remove_stmt in vectorizable_simd_clone_call (PR 86758)

2018-08-01 Thread Richard Sandiford
independently of the rest of the series. Sorry for the breakage. It looks like I compared the x86 results with the wrong baseline. :-( Tested on aarch64-linux-gnu (with and without SVE), aarch64_be-elf and x86_64-linux-gnu. OK to install? Richard 2018-08-01 Richard Sandiford gcc

Re: Fold pointer range checks with equal spans

2018-08-01 Thread Richard Sandiford
Richard Biener writes: > On Mon, Jul 30, 2018 at 7:47 PM Richard Sandiford > wrote: >> >> [Sorry, somehow missed this till now] >> >> Richard Biener writes: >> > On Mon, Jul 23, 2018 at 5:05 PM Richard Sandiford >> > wrote: >> >> >

Re: Fold pointer range checks with equal spans

2018-08-01 Thread Richard Sandiford
Marc Glisse writes: > On Tue, 31 Jul 2018, Richard Biener wrote: > Also, when @2 == @0 + (@1+1) then the original condition is true but ((sizetype) @0 - (sizetype) @2 + @1) > (@1 * 2) is not? (sizetype) @0 - (sizetype) (@0 + @1 + 1) + @1 > @1 * 2 -> -1 > @1 * 2 whi

Re: [PATCH v3 1/4] ifcvt: handle sequences that clobber flags in noce_convert_multiple_sets

2023-10-19 Thread Richard Sandiford
Manolis Tsamis writes: > This is an extension of what was done in PR106590. > > Currently if a sequence generated in noce_convert_multiple_sets clobbers the > condition rtx (cc_cmp or rev_cc_cmp) then only seq1 is used afterwards > (sequences that emit the comparison itself). Since this applies on

Re: [PATCH v3 2/4] ifcvt: Allow more operations in multiple set if conversion

2023-10-19 Thread Richard Sandiford
Manolis Tsamis writes: > Currently the operations allowed for if conversion of a basic block with > multiple sets are few, namely REG, SUBREG and CONST_INT (as controlled by > bb_ok_for_noce_convert_multiple_sets). > > This commit allows more operations (arithmetic, compare, etc) to participate >

Re: [PATCH]AArch64 Handle copysign (x, -1) expansion efficiently

2023-10-19 Thread Richard Sandiford
Tamar Christina writes: > Hi All, > > copysign (x, -1) is effectively fneg (abs (x)) which on AArch64 can be > most efficiently done by doing an OR of the signbit. > > The middle-end will optimize fneg (abs (x)) now to copysign as the > canonical form and so this optimizes the expansion. > > If th

Re: [PATCH]AArch64 Add SVE implementation for cond_copysign.

2023-10-19 Thread Richard Sandiford
Tamar Christina writes: > Hi All, > > This adds an implementation for masked copysign along with an optimized > pattern for masked copysign (x, -1). > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > Ok for master? > > Thanks, > Tamar > > gcc/ChangeLog: > > PR tree-optim

Re: [PATCH] vect: Cost adjacent vector loads/stores together [PR111784]

2023-10-19 Thread Richard Sandiford
"Kewen.Lin" writes: > Hi, > > As comments[1][2], this patch is to change the costing way > on some adjacent vector loads/stores from costing one by > one to costing them together with the total number once. > > It helps to fix the exposed regression PR111784 on aarch64, > as aarch64 specific costi

Re: [PATCH V5] VECT: Enhance SLP of MASK_LEN_GATHER_LOAD[PR111721]

2023-10-19 Thread Richard Sandiford
"juzhe.zh...@rivai.ai" writes: > Hi, this patch fix V4 issue: > > Previously as Richard S commented: > https://gcc.gnu.org/pipermail/gcc-patches/2023-October/633178.html > > slp_op and mask_vectype are only initialised when mask_index >= 0. > Shouldn't this code be under mask_index >= 0 too? > Al

Re: [PATCH-1v4, expand] Enable vector mode for compare_by_pieces [PR111449]

2023-10-20 Thread Richard Sandiford
HAO CHEN GUI writes: > Hi, > Vector mode instructions are efficient for compare on some targets. > This patch enables vector mode for compare_by_pieces. Two help > functions are added to check if vector mode is available for certain > by pieces operations and if if optabs exists for the mode and

Re: [PATCH v3 1/4] ifcvt: handle sequences that clobber flags in noce_convert_multiple_sets

2023-10-20 Thread Richard Sandiford
Thanks for the context. Robin Dapp writes: >> Sorry for the slow review. TBH I was hoping someone else would pick >> it up, since (a) I'm not very familiar with this code, and (b) I don't >> really agree with the way that the current code works. I'm not sure the >> current dependency checking i

Re: [PATCH] rtl-ssa: Don't leave NOTE_INSN_DELETED around

2023-10-20 Thread Richard Sandiford
Alex Coplan writes: > Hi, > > This patch tweaks change_insns to also call ::remove_insn to ensure the > underlying RTL insn gets removed from the insn chain in the case of a > deletion. > > This avoids leaving NOTE_INSN_DELETED around after deleting insns. > > For movement, the RTL insn chain is u

Re: [PATCH] aarch64: [PR110986] Emit csinv again for `a ? ~b : b`

2023-10-20 Thread Richard Sandiford
Andrew Pinski writes: > After r14-3110-g7fb65f10285, the canonical form for > `a ? ~b : b` changed to be `-(a) ^ b` that means > for aarch64 we need to add a few new insn patterns > to be able to catch this and change it to be > what is the canonical form for the aarch64 backend. > A secondary pat

Re: [PATCH] aarch64: [PR110986] Emit csinv again for `a ? ~b : b`

2023-10-20 Thread Richard Sandiford
Richard Earnshaw writes: > On 20/10/2023 13:13, Richard Sandiford wrote: >>> +(define_insn_and_split "*cmov_insn_insv" >>> + [(set (match_operand:GPI 0 "register_operand" "=r") >>> +(xor:GPI >>> +

[PATCH] aarch64: Avoid bogus atomics match

2023-10-24 Thread Richard Sandiford
The non-LSE pattern aarch64_atomic_exchange comes before the LSE pattern aarch64_atomic_exchange_lse. From a recog perspective, the only difference between the patterns is that the non-LSE one clobbers CC and needs a scratch. However, combine and RTL-SSA can both add clobbers to make a pattern ma

[pushed] aarch64: Define TARGET_INSN_COST

2023-10-24 Thread Richard Sandiford
This patch adds a bare-bones TARGET_INSN_COST. See the comment in the patch for the rationale. This change is needed to avoid a regression with a later change. Tested on aarch64-linux-gnu & pushed. Richard gcc/ * config/aarch64/aarch64.cc (aarch64_insn_cost): New function. (TA

[pushed] i386: Fix unprotected REGNO in aeswidekl_operation

2023-10-24 Thread Richard Sandiford
I hit an ICE in aeswidekl_operation while testing the late-combine pass on x86. The predicate tested REGNO without first testing REG_P. Tested on x86_64-linux-gnu & pushed as obvious. Richard gcc/ * config/i386/predicates.md (aeswidekl_operation): Protect REGNO check with REG_P

[PATCH] i386: Avoid paradoxical subreg dests in vector zero_extend

2023-10-24 Thread Richard Sandiford
For the V2HI -> V2SI zero extension in: typedef unsigned short v2hi __attribute__((vector_size(4))); typedef unsigned int v2si __attribute__((vector_size(8))); v2si f (v2hi x) { return (v2si) {x[0], x[1]}; } ix86_expand_sse_extend would generate: (set (reg:V2HI 102) (const_vecto

[PATCH] i386: Fix undefined masks in vpopcnt tests

2023-10-24 Thread Richard Sandiford
The files changed in this patch had tests for masked and unmasked popcnt. However, the mask inputs to the masked forms were undefined, and would be set to zero by init_regs. Any combine-like pass that ran after init_regs could then fold the masked forms into the unmasked ones. I saw this while t

[PATCH] recog/reload: Remove old UNARY_P operand support

2023-10-24 Thread Richard Sandiford
reload and constrain_operands had some old code to look through unary operators. E.g. an operand could be (sign_extend (reg X)), and the constraints would match the reg rather than the sign_extend. This was previously used by the MIPS port. But relying on it was a recurring source of problems, s

[PATCH] recog: Fix propagation into ASM_OPERANDS

2023-10-24 Thread Richard Sandiford
An inline asm with multiple output operands is represented as a parallel set in which the SET_SRCs are the same (shared) ASM_OPERANDS. insn_propgation didn't account for this, and instead propagated into each ASM_OPERANDS individually. This meant that it could apply a substitution X->Y to Y itself

[PATCH 0/4] rtl-ssa: Some small, obvious fixes

2023-10-24 Thread Richard Sandiford
This series contains some small fixes to RTL-SSA. Tested on aarch64-linux-gnu & x86_64-linux-gnu, pushed as obvious. Richard Sandiford (4): rtl-ssa: Fix null deref in first_any_insn_use rtl-ssa: Fix handling of deleted insns rtl-ssa: Don't insert after insns that can throw rtl-s

[PATCH 1/4] rtl-ssa: Fix null deref in first_any_insn_use

2023-10-24 Thread Richard Sandiford
first_any_insn_use implicitly (but contrary to its documentation) assumed that there was at least one use. gcc/ * rtl-ssa/member-fns.inl (first_any_insn_use): Handle null m_first_use. --- gcc/rtl-ssa/member-fns.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git

[PATCH 4/4] rtl-ssa: Avoid creating duplicated phis

2023-10-24 Thread Richard Sandiford
If make_uses_available was called twice for the same use, we could end up trying to create duplicate definitions for the same extended live range. gcc/ * rtl-ssa/blocks.cc (function_info::create_degenerate_phi): Check whether the requested phi already exists. --- gcc/rtl-ssa/block

[PATCH 3/4] rtl-ssa: Don't insert after insns that can throw

2023-10-24 Thread Richard Sandiford
rtl_ssa::can_insert_after didn't handle insns that can throw. Fixing that avoids a regression with a later patch. gcc/ * rtl-ssa.h: Include cfgbuild.h. * rtl-ssa/movement.h (can_insert_after): Replace is_jump with the more comprehensive control_flow_insn_p. --- gcc/rtl-ssa

[PATCH 2/4] rtl-ssa: Fix handling of deleted insns

2023-10-24 Thread Richard Sandiford
RTL-SSA queues up some invasive changes for later. But sometimes the insns involved in those changes can be deleted by later optimisations, making the queued change unnecessary. This patch checks for that case. gcc/ * rtl-ssa/changes.cc (function_info::perform_pending_updates): Check

[PATCH 1/6] rtl-ssa: Ensure global registers are live on exit

2023-10-24 Thread Richard Sandiford
RTL-SSA mostly relies on DF for block-level register liveness information, including artificial uses and defs at the beginning and end of blocks. But one case was missing. DF does not add artificial uses of global registers to the beginning or end of a block. Instead it marks them as used within

[PATCH 0/6] rtl-ssa: Various fixes needed for the late-combine pass

2023-10-24 Thread Richard Sandiford
Testing the late-combine pass showed a depressing number of bugs in areas of RTL-SSA that hadn't been used much until now. Most of them relate to doing things after RA. Tested on aarch64-linux-gnu & x86_64-linux-gnu. OK to install? Richard Richard Sandiford (6): rtl-ssa: Ensu

<    1   2   3   4   5   6   7   8   9   10   >