This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/21998] (cond ? result1 : result2) is vectorized, where equivalent if-syntax isn't (store)
- From: "steven at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 13 Jul 2012 11:04:13 +0000
- Subject: [Bug tree-optimization/21998] (cond ? result1 : result2) is vectorized, where equivalent if-syntax isn't (store)
- Auto-submitted: auto-generated
- References: <bug-21998-4@http.gcc.gnu.org/bugzilla/>
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.