From patchwork Wed Jun 6 00:59:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Iyer, Balaji V" X-Patchwork-Id: 163215 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]) by ozlabs.org (Postfix) with SMTP id 378D2B6F13 for ; Wed, 6 Jun 2012 11:00:14 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1339549215; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:To:Subject:Date:Message-ID:Content-Type: MIME-Version:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=4nMcFqp mZaV25CAjmXuyCgTO1Rg=; b=wH9w6nTDDPD5o/lgz8PVi/UgDNBrvbrZQG5kD9G 7/CSo7YskjH3/593rg3z0sC87XOzxW6oFnkDpdd061iUAGwevpze3yFwiORdXofC 3oQ3BSNgfwfQwlrhXxU7ff8sDT8za+UVstD65L9CWRIS1G36yiwuiea5bRJ7E1Di qGr4= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-ExtLoop1:Received:Received:Received:From:To:Subject:Date:Message-ID:Content-Type:MIME-Version:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=M/3WlR3xNJyjclGHhVIN5byTsId2BwByA2LFUBwt0iuy2Kp4okR3xlGeQMBqNf vz///joS+Bzxfn4UYpbLLbZyQeDy9fNsN6hCfB8h0/rotgCJvuqySScx30J/W080 jvoUO5XhYhm373w5uuE83q6sL7kjRwHP8l+7/hy6q1Exk=; Received: (qmail 8138 invoked by alias); 6 Jun 2012 01:00:10 -0000 Received: (qmail 8122 invoked by uid 22791); 6 Jun 2012 01:00:09 -0000 X-SWARE-Spam-Status: No, hits=-4.7 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga14.intel.com (HELO mga14.intel.com) (143.182.124.37) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 06 Jun 2012 00:59:55 +0000 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 05 Jun 2012 17:59:54 -0700 X-ExtLoop1: 1 Received: from azsmsx601.amr.corp.intel.com ([10.2.121.193]) by AZSMGA002.ch.intel.com with ESMTP; 05 Jun 2012 17:59:54 -0700 Received: from fmsmsx101.amr.corp.intel.com (10.19.9.52) by azsmsx601.amr.corp.intel.com (10.2.121.193) with Microsoft SMTP Server (TLS) id 8.2.255.0; Tue, 5 Jun 2012 17:59:53 -0700 Received: from fmsmsx102.amr.corp.intel.com ([169.254.2.199]) by FMSMSX101.amr.corp.intel.com ([169.254.1.33]) with mapi id 14.01.0355.002; Tue, 5 Jun 2012 17:59:53 -0700 From: "Iyer, Balaji V" To: "gcc-patches@gcc.gnu.org" Subject: [PATCH][Cilkplus] Did an induction variable optimization Date: Wed, 6 Jun 2012 00:59:52 +0000 Message-ID: MIME-Version: 1.0 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 Hello Everyone, This patch is for the Cilkplus branch affecting the C compiler. This patch will remove an unwanted conversion of the induction variable in the cilk_for function. Thanking You, Yours Sincerely, Balaji V. Iyer. Index: gcc/cilk-spawn.c =================================================================== --- gcc/cilk-spawn.c (revision 188251) +++ gcc/cilk-spawn.c (working copy) @@ -2290,9 +2290,6 @@ int incr_sign = cfd->incr_sign; enum tree_code add_op = incr_sign >= 0 ? PLUS_EXPR : MINUS_EXPR; - gcc_assert (TYPE_MAIN_VARIANT (TREE_TYPE (loop_var)) == - TYPE_MAIN_VARIANT (count_type)); - /* Compute an expression to be added or subtracted. We want to add or subtract LOOP_VAR * INCR. INCR may be negative. @@ -2374,8 +2371,8 @@ tree body, block; tree lower_bound; tree loop_var; - tree count_type; tree tempx,tempy; + declare_cilk_for_parms (cfd); cfd->wd.fntype = build_function_type (void_type_node, cfd->wd.argtypes); @@ -2420,14 +2417,12 @@ lower_bound = hack; } loop_var = build_decl (UNKNOWN_LOCATION, VAR_DECL, NULL_TREE, - TREE_TYPE (cfd->min_parm)); + cfd->var_type); DECL_CONTEXT (loop_var) = fndecl; - add_stmt (build2 (INIT_EXPR, void_type_node, loop_var, cfd->min_parm)); + add_stmt (build_modify_expr (UNKNOWN_LOCATION, loop_var, TREE_TYPE (loop_var), + NOP_EXPR, UNKNOWN_LOCATION, + cfd->min_parm, TREE_TYPE (cfd->min_parm))); - count_type = cfd->count_type; - gcc_assert (TYPE_MAIN_VARIANT (TREE_TYPE (loop_var)) == - TYPE_MAIN_VARIANT (count_type)); - /* The new loop body is var2 = (T)((control variable) * INCR + (lower bound)); @@ -2464,14 +2459,15 @@ add_stmt (loop_body); tempx = build2 (MODIFY_EXPR, void_type_node, loop_var, - build2 (PLUS_EXPR, count_type, + build2 (PLUS_EXPR, TREE_TYPE (loop_var), loop_var, - build_int_cst (count_type, 1))); + build_int_cst (TREE_TYPE (loop_var), 1))); add_stmt(tempx); tempy = build3 (COND_EXPR, void_type_node, build2 (LT_EXPR, boolean_type_node, loop_var, - cfd->max_parm), + build_c_cast (UNKNOWN_LOCATION, + TREE_TYPE (loop_var), cfd->max_parm)), build1 (GOTO_EXPR, void_type_node, lab), build_empty_stmt (UNKNOWN_LOCATION)); Index: gcc/ChangeLog.cilk =================================================================== --- gcc/ChangeLog.cilk (revision 188251) +++ gcc/ChangeLog.cilk (working copy) @@ -1,3 +1,10 @@ +2012-06-05 Balaji V. Iyer + + * cilk-spawn.c (compute_loop_var): Removed an unwanted assert. + (build_cilk_for_body): Changed var type from min_parms's to the original + var_type. This change is propagated in several places with the + appropriate type conversions. + 2012-06-02 Balaji V. Iyer * tree-inline.c (remap_gimple_op_r): Added a check for NON-NULL