https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116785

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot 
gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-09-27

--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note I have to use -fno-vect-cost-model on the reduced testcase to get
vectorization.  There is indeed

  [t.ii:27:12] # PT = anything 
  tBasis_65 = [t.ii:27:21] this_61(D)->m_Bt;

  [t.ii:71:57] # PT = anything
  _507 = Y_66 + _506;

derefaddrtmp(22) = &NULL
*ANYTHING = derefaddrtmp(22)

Likely the volatile

  irep ={v} 0;



...
irep.1_36 = &ANYTHING
_37 = irep.1_36 + UNKNOWN
_37 = &NONLOCAL
*ANYTHING = _37
irep.3_38 = &ANYTHING
_39 = irep.3_38

because:

  irep.1_36 ={v} irep;
  _37 = irep.1_36 + 1;
  irep ={v} _37;

well, a volatile read-modify-write.  Not using volatile int for RepIndex_type
fixes it.

Note that the volatile handling was adjusted with r15-579-ga9251ab3c91c8c but
it didn't have the desired effect due to bugs fixed with the later changes.

Note that the handling of volatiles, esp. on the store side is a bit too
conservative.  Can you try the following on the original benchmark?

diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
index d6a53f801f0..54c4818998d 100644
--- a/gcc/tree-ssa-structalias.cc
+++ b/gcc/tree-ssa-structalias.cc
@@ -3646,7 +3646,7 @@ get_constraint_for_1 (tree t, vec<ce_s> *results, bool
address_p,
       }
     case tcc_reference:
       {
-       if (TREE_THIS_VOLATILE (t))
+       if (!lhs_p && TREE_THIS_VOLATILE (t))
          /* Fall back to anything.  */
          break;

@@ -3751,7 +3751,7 @@ get_constraint_for_1 (tree t, vec<ce_s> *results, bool
address_p,
       }
     case tcc_declaration:
       {
-       if (VAR_P (t) && TREE_THIS_VOLATILE (t))
+       if (!lhs_p && VAR_P (t) && TREE_THIS_VOLATILE (t))
          /* Fall back to anything.  */
          break;
        get_constraint_for_ssa_var (t, results, address_p);

Reply via email to