From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65145 invoked by alias); 11 Aug 2016 10:48:20 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 64279 invoked by uid 89); 11 Aug 2016 10:48:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=10pm X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 11 Aug 2016 10:48:18 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E7269C04D292; Thu, 11 Aug 2016 10:48:16 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-204-43.brq.redhat.com [10.40.204.43]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7BAmFO6020335 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 11 Aug 2016 06:48:16 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u7BAmD7u021604; Thu, 11 Aug 2016 12:48:13 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u7BAmB6n021603; Thu, 11 Aug 2016 12:48:11 +0200 Date: Thu, 11 Aug 2016 10:48:00 -0000 From: Jakub Jelinek To: Prathamesh Kulkarni Cc: Richard Biener , gcc Patches Subject: Re: fold strlen (s) eq/ne 0 to *s eq/ne 0 on GIMPLE Message-ID: <20160811104811.GN14857@tucnak.redhat.com> Reply-To: Jakub Jelinek References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2016-08/txt/msg00904.txt.bz2 On Thu, Aug 11, 2016 at 04:06:10PM +0530, Prathamesh Kulkarni wrote: > +static void > +replace_call_by_cmp (gimple_stmt_iterator *gsi, location_t loc, > + tree type, tree arg1, tree arg2, > + tree res_type, enum tree_code cmp_code) > +{ > + tree ptrtype = build_pointer_type_for_mode (char_type_node, ptr_mode, true); > + tree off = build_int_cst (ptrtype, 0); > + arg1 = build2_loc (loc, MEM_REF, type, arg1, off); > + tree tem1 = fold_const_aggregate_ref (arg1); > + if (tem1) > + arg1 = tem1; > + > + if (POINTER_TYPE_P (TREE_TYPE (arg2))) > + { > + arg2 = build2_loc (loc, MEM_REF, type, arg2, off); > + tree tem2 = fold_const_aggregate_ref (arg2); > + if (tem2) > + arg2 = tem2; > + } > + else > + gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (arg2))); > + > + tree res = fold_convert_loc (loc, res_type, > + fold_build2_loc (loc, cmp_code, > + boolean_type_node, > + arg1, arg2)); > + > + gimplify_and_update_call_from_tree (gsi, res); I know it is pre-existing, but do you really need to create everything as trees first and then gimplify? Can't you emit GIMPLE right away? > @@ -2505,7 +2558,7 @@ const pass_data pass_data_strlen = > 0, /* properties_provided */ > 0, /* properties_destroyed */ > 0, /* todo_flags_start */ > - 0, /* todo_flags_finish */ > + TODO_update_ssa_only_virtuals, /* todo_flags_finish */ > }; > > class pass_strlen : public gimple_opt_pass And if you do, I'd hope you can avoid this. The strlen call has a vuse, just use the same virtual operand in vuse on the mem read. Jakub