From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31217 invoked by alias); 4 Nov 2013 10:56:10 -0000 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 Received: (qmail 27647 invoked by uid 48); 4 Nov 2013 10:54:07 -0000 From: "glisse at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/58845] [4.8/4.9 Regression] Operator || and && broken for vectors Date: Mon, 04 Nov 2013 10:56:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: glisse at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-11/txt/msg00201.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58845 --- Comment #8 from Marc Glisse --- (In reply to Richard Biener from comment #5) > Well, what does OpenCL specify here? "The logical operators and (&&), or (||) operate on all scalar and vector built-in types. For scalar built-in types only, and (&&) will only evaluate the right hand operand if the left hand operand compares unequal to 0. For scalar built-in types only, or (||) will only evaluate the right hand operand if the left hand operand compares equal to 0. For built-in vector types, both operands are evaluated and the operators are applied component-wise. If one operand is a scalar and the other is a vector, the scalar may be subject to the usual arithmetic conversion to the element type used by the vector operand. The scalar type is then widened to a vector that has the same number of components as the vector operand. The operation is done component-wise resulting in the same size vector. The logical operator exclusive or (^^) is reserved. The result is a scalar signed integer of type int if the source operands are scalar and a vector signed integer type of the same size as the source operands if the source operands are vector types. Vector source operands of type charn and ucharn return a charn result; vector source operands of type shortn and ushortn return a shortn result; vector source operands of type intn, uintn and floatn return an intn result; vector source operands of type longn, ulongn and doublen return a longn result. For scalar types, the logical operators shall return 0 if the result of the operation is false and 1 if the result is true. For vector types, the logical operators shall return 0 if the result of the operation is false and -1 (i.e. all bits set) if the result is true." > v1 && v2 > > should be emitted as GENERIC > > (v1 != { 0, 0, ... }) && (v2 != { 0, 0, ... }) > > where the ANDIF semantics don't make sense for vectors(?) and thus we > can directly emit GENERIC > > (v1 != { 0, 0, ... }) & (v2 != { 0, 0, ... }) > > from the frontend. IIRC that's what the patch did: http://gcc.gnu.org/ml/gcc-patches/2013-04/msg00783.html (In reply to Jakub Jelinek from comment #6) > If there are no side-effects in v1 or v2, why not, but if there are > side-effects, IMHO it should act as ANDIF, not as BIT_AND_EXPR. What does ANDIF mean in this case? Only evaluate v2 if v1 has at least one non-zero element? That still doesn't match the scalar version. Only evaluate parts of v2? That doesn't seem possible. (In reply to rguenther@suse.de from comment #7) > Then I'd say leave the whole thing to gimplification. And implement what semantics in gimplification?