Bug 95309 - [11 Regression] Many targets failing ssa-dom-cse-2.c after vectorizer changes
Summary: [11 Regression] Many targets failing ssa-dom-cse-2.c after vectorizer changes
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: 11.0
Assignee: Richard Biener
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2020-05-25 04:53 UTC by Jeffrey A. Law
Modified: 2020-05-25 14:02 UTC (History)
0 users

See Also:
Host:
Target: iq2000-elf and others
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-05-25 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey A. Law 2020-05-25 04:53:51 UTC
Various ports have regressed the tree-ssa/ssa-dom-cse-2.c after this change:

commit a4b48fc47c3406b6f41be093c4615879b7006710
Author: Richard Biener <rguenther@suse.de>
Date:   Mon May 18 16:05:00 2020 +0200

    cost invariant nodes from vect_slp_analyze_node_operations SLP walk
    
    2020-05-19  Richard Biener  <rguenther@suse.de>
    
            * tree-vectorizer.h (_slp_tree::vectype): Add field.
            (SLP_TREE_VECTYPE): New.
            * tree-vect-slp.c (vect_create_new_slp_node): Initialize
            SLP_TREE_VECTYPE.
            (vect_create_new_slp_node): Likewise.
            (vect_prologue_cost_for_slp): Move here from tree-vect-stmts.c
            and simplify.
            (vect_slp_analyze_node_operations): Walk nodes children for
            invariant costing.
            (vect_get_constant_vectors): Use local scope op variable.
            * tree-vect-stmts.c (vect_prologue_cost_for_slp_op): Remove here.
            (vect_model_simple_cost): Adjust.
            (vect_model_store_cost): Likewise.
            (vectorizable_store): Likewise.

You should be able to see this on the iq2000-elf port (and many others).

I believe the test is supposed to verify that we're able to determine the return
value statically after unrolling the loop.  It's unclear if the stores get in the
way of cse-ing the assignment to _22 and _29 in the dump or if there's something
else going on:

  MEM[(int *)&a] = { 0 };
  MEM[(int *)&a + 4B] = { 1 };
  MEM[(int *)&a + 8B] = { 2 };
  MEM[(int *)&a + 12B] = { 3 };
  MEM[(int *)&a + 16B] = { 4 };
  MEM[(int *)&a + 20B] = { 5 };
  MEM[(int *)&a + 24B] = { 6 };
  MEM[(int *)&a + 28B] = { 7 };
  _22 = a[0];
  _29 = a[1];
  sum_30 = _22 + _29;
  _36 = a[2];
  sum_37 = sum_30 + _36;
  _43 = a[3];
  sum_44 = sum_37 + _43;
  _50 = a[4];
  sum_51 = sum_44 + _50;
  _57 = a[5];
  sum_58 = sum_51 + _57;
  _64 = a[6];
  sum_65 = sum_58 + _64;
  _1 = a[7];
  sum_16 = _1 + sum_65;
  a ={v} {CLOBBER};
  return sum_16;
Comment 1 Richard Biener 2020-05-25 11:13:13 UTC
So SLP vectorization decides to vectorize the SImode stores with V1SImode vector stores because the cited revision does not cost the constant as SLP_TREE_NUMBER_OF_VEC_STMTS is zero for it.  That's because this wasn't
adjusted when changing what SLP node we pass in and we've never computed
SLP_TREE_NUMBER_OF_VEC_STMTS for invariants sofar.
Comment 2 GCC Commits 2020-05-25 14:02:25 UTC
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:dc0c0196340f7ac58b10d0042d7cea776d6f7864

commit r11-615-gdc0c0196340f7ac58b10d0042d7cea776d6f7864
Author: Richard Biener <rguenther@suse.de>
Date:   Mon May 25 13:06:03 2020 +0200

    tree-optimization/95309 - fix invariant SLP node costing
    
    This makes sure to compute SLP_TREE_NUMBER_OF_VEC_STMTS during SLP
    analysis even for invariant / external nodes so costing properly
    knows what to cost.
    
    2020-05-25  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/95309
            * tree-vect-slp.c (vect_get_constant_vectors): Move number
            of vector computation ...
            (vect_slp_analyze_node_operations): ... to analysis phase.
Comment 3 Richard Biener 2020-05-25 14:02:53 UTC
Fixed (on ip2000-elf).