From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12467 invoked by alias); 13 Jul 2012 11:04:40 -0000 Received: (qmail 12455 invoked by uid 22791); 13 Jul 2012 11:04:40 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 13 Jul 2012 11:04:27 +0000 From: "steven at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/21998] (cond ? result1 : result2) is vectorized, where equivalent if-syntax isn't (store) Date: Fri, 13 Jul 2012 11:04:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: steven at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-07/txt/msg01042.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21998 Steven Bosscher changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |steven at gcc dot gnu.org --- Comment #4 from Steven Bosscher 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.