http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21998

Steven Bosscher <steven at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |steven at gcc dot gnu.org

--- Comment #4 from Steven Bosscher <steven at gcc dot gnu.org> 2012-07-13 
11:04:13 UTC ---
(In reply to comment #1)
> They are not equivalent to GCC, the first always stores, the second has a
> conditional store.

Just to clarify, 7 years later: To GCC the two procedures are not equivalent.

In the first procedure,
 a1[i] = (a1[i] == v1 ? v2 : a1[i]);

expands as:

  if (a1[i] == v1)
    a1[i] = v2;
  else
    a1[i] = a1[i];

while the second procedure expands just as-is:
  if (a1[i] == v1)
    a1[i] = v2;

In the first case, there will always be a store to a1[i], in the second example
this is not the case. Introducing new stores is not allowed, to avoid
introducing data races, see http://gcc.gnu.org/wiki/Atomic/GCCMM/DataRaces.

I'm not sure how GCC should transform the second procedure to allow the loop to
be vectorized.

Reply via email to