From patchwork Wed Jan 15 18:50:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 311243 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EC5C92C0097 for ; Thu, 16 Jan 2014 05:50:54 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :date:to:subject:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=Ft97J ZFYdD70AOlfLeBluGEpugQrTgk5UJ3hiFtpfk24pTwqZRXIRWl8zoY2vYhaHXXe7 vXZkCkjQ1HwWUUGOTTvTZ0W69lU9ouTvrEU/+uQT7/kI3JK5uARqfVWOVLYVDYKC LdgGH03hWsU7nuvPTosvmI65DXANnuUwaTjfoI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :date:to:subject:mime-version:content-type :content-transfer-encoding:message-id; s=default; bh=3ZAe6ke0E1L M6hzsFKzL2GPTwNA=; b=YyB++G/fCLjMxFTmaR5AoD+DLkI2oq01OwVElX2MTAq EFVuX5YvSNlvKCDBb6YqFbvwfHbZYRs2fsQjka8lVS0U5c/rOYSWYuWfztWx/5i0 h7us19cJpPvSCdVsYm6Dv3nyK4nITWvSUTMujen3gVJmwM82uERTwyjtlf4VYg1c = Received: (qmail 643 invoked by alias); 15 Jan 2014 18:50:48 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 633 invoked by uid 89); 15 Jan 2014 18:50:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: multi.imgtec.com Received: from multi.imgtec.com (HELO multi.imgtec.com) (194.200.65.239) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 15 Jan 2014 18:50:45 +0000 From: "Steve Ellcey " Date: Wed, 15 Jan 2014 10:50:38 -0800 To: Subject: [Patch, cilk, C++] Fix cilk testsuite failure User-Agent: Heirloom mailx 12.5 6/20/10 MIME-Version: 1.0 Message-ID: <5676f26c-f6d8-4798-8bdc-2b7b07f08925@BAMAIL02.ba.imgtec.org> X-SEF-Processed: 7_3_0_01192__2014_01_15_18_50_41 The test c-c++-common/cilk-plus/AN/builtin_func_double2.c is failing on MIPS when compiled with C++ but not when compiled with C because GCC is generating an illegal assembly language instruction during the C++ compilation. The reason this works in C but fails for C++ is because the __sec_reduce_any_nonzero call is creating a conditional assignment expression and in C the condition used in that expression is type integer but in C++ it is type boolean. In c/c-array-notation.c we have: case BUILT_IN_CILKPLUS_SEC_REDUCE_ALL_ZERO: case BUILT_IN_CILKPLUS_SEC_REDUCE_ALL_NONZERO: case BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_ZERO: case BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_NONZERO: new_var_type = integer_type_node; break; new_var_type is used as the type of a variable used as the condition 'C' in "foo = C ? 1 : 0". But in C++ we use a boolean type instead of an integer type for the condition. Thus, in cp/cp-array-notation.c we have: case BUILT_IN_CILKPLUS_SEC_REDUCE_ALL_ZERO: case BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_ZERO: case BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_NONZERO: case BUILT_IN_CILKPLUS_SEC_REDUCE_ALL_NONZERO: new_var_type = boolean_type_node; break; The reason this matters is that on MIPS a floating point conditional register ($fcc0) can hold a boolean type but not an integer type but this register cannot be used in a conditional move. So when the C++ code is generated GCC will create an instruction that looks like: movz $4,$6,$fcc0 And this is illegal. I would like to fix this by using integer_type_node for C++ like C is doing and I have attached a tested patch that does this. It fixes the bug and caused no regressions on mips-mti-linux-gnu. One could argue that a better fix would be checking the legality of the conditional move in expr.c and not generating an illegal one, however the current GCC conditional move code checks for the type (mode) of the value being moved but has no check on the type or mode of the conditional being used to control the move so doing this would probably mean adding a new target predicate. Since no other tests are failing with this problem I would rather tweak the cilk code instead. Tested on mips-mti-linux-gnu with no regressions. OK to checkin? Steve Ellcey sellcey@mips.com 2014-01-15 Steve Ellcey PR target/59462 * cp-array-notation.c (expand_sec_reduce_builtin): Change conditional type. diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c index 65b8bcb..6cba0b4 100644 --- a/gcc/cp/cp-array-notation.c +++ b/gcc/cp/cp-array-notation.c @@ -274,7 +274,7 @@ expand_sec_reduce_builtin (tree an_builtin_fn, tree *new_var) case BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_ZERO: case BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_NONZERO: case BUILT_IN_CILKPLUS_SEC_REDUCE_ALL_NONZERO: - new_var_type = boolean_type_node; + new_var_type = integer_type_node; break; case BUILT_IN_CILKPLUS_SEC_REDUCE_MAX_IND: case BUILT_IN_CILKPLUS_SEC_REDUCE_MIN_IND: