On Mon, May 8, 2017 at 6:12 PM, Robin Dapp <rd...@linux.vnet.ibm.com> wrote: > gcc/ChangeLog:
+ /* Compare costs of peeling for known and unknown alignment. */ + if (unknown_align_inside_cost > peel_for_known_alignment.inside_cost + || (unknown_align_inside_cost == peel_for_known_alignment.inside_cost + && unknown_align_outside_cost > peel_for_known_alignment.outside_cost)) + { no braces around single stmts. + dr0 = dr0_known_align; + } + I think when equal we should prefer dr0_known_align peeling. That is, I'd simply use if (unknown_align_inside_cost >= peel_for_known_alignment.inside_cost) dr0 = dr0_known_align; this is because followup optimizations are easier with the prologue/epilogue having niters known. + /* We might still want to try to align the datarefs with unknown + misalignment if peeling for known alignment aligns significantly + less datarefs. */ + if (peel_for_known_alignment.peel_info.count * 2 > unknown_align_count) + { + dr0 = dr0_known_align; the comment doesn't match the code. I also think this heuristic is bogus and instead the cost computation should have figured out the correct DR to peel in the first place. Otherwise this patch looks ok. Thanks, Richard. > 2017-05-08 Robin Dapp <rd...@linux.vnet.ibm.com> > > * tree-vect-data-refs.c (vect_peeling_hash_choose_best_peeling): > Return peel info. > (vect_enhance_data_refs_alignment): > Compute full costs when peeling for unknown alignment, compare > to costs for peeling for known alignment and choose the cheaper > one.