From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12825 invoked by alias); 14 Jun 2011 11:28:12 -0000 Received: (qmail 12811 invoked by uid 22791); 14 Jun 2011 11:28:11 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,TW_TM X-Spam-Check-By: sourceware.org Received: from mail-ww0-f51.google.com (HELO mail-ww0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 14 Jun 2011 11:27:57 +0000 Received: by wwf26 with SMTP id 26so5176686wwf.8 for ; Tue, 14 Jun 2011 04:27:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.169.139 with SMTP id z11mr6128292wby.60.1308050875575; Tue, 14 Jun 2011 04:27:55 -0700 (PDT) Received: by 10.227.28.69 with HTTP; Tue, 14 Jun 2011 04:27:55 -0700 (PDT) In-Reply-To: References: Date: Tue, 14 Jun 2011 11:29:00 -0000 Message-ID: Subject: Re: [patch] Don't insert pattern statements into the code (was Fix PR tree-optimization/49318) From: Richard Guenther To: Ira Rosen Cc: gcc-patches@gcc.gnu.org, Patch Tracking Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes 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 X-SW-Source: 2011-06/txt/msg01037.txt.bz2 On Tue, Jun 14, 2011 at 12:38 PM, Ira Rosen wrote: > On 14 June 2011 13:02, Richard Guenther wrot= e: >> On Mon, Jun 13, 2011 at 2:43 PM, Ira Rosen wrote: >>> On 10 June 2011 12:14, Richard Guenther wr= ote: >>>> In the end I think we should not generate the pattern stmt during >>>> pattern matching but only mark the relevant statements with a >>>> pattern kind. =A0Say, for each pattern we have a "main" statement >>>> that has related stmts belonging to the pattern that define uses >>>> of the "main" statement - mark those to refer to that "main" statement. >>>> For that "main" statement simply record an enum value, like, >>>> widening_mult. =A0Then only at vectorized statement >>>> generation time actually generate the vectorized form of the >>>> pattern statement. >>> >>> I ended up with the following: during pattern detection a new scalar >>> pattern statement is created but not inserted into the code, it is >>> only recorded as a related statement of the last statement in the >>> detected pattern. Every time the last statement is being >>> analyzed/transformed, we switch to the pattern statement instead. It >>> is much more difficult just to mark the last stmt with an enum value, >>> since we have to retrieve the relevant operands every time. >>> >>> I am not sure if we need to free the pattern stmt at the end. No, they are going to be garbage collected. >>> Bootstrapped and now testing on powerpc64-suse-linux (tested >>> vectorizer testsuite on powerpc64-suse-linux and x86_64-suse-linux. >>> >>> What do you think? >> >> =A0 /* Mark the stmts that are involved in the pattern. */ >> - =A0gsi_insert_before (&si, pattern_stmt, GSI_SAME_STMT); >> =A0 set_vinfo_for_stmt (pattern_stmt, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0new_stmt_vec_info (pattern_st= mt, loop_vinfo, NULL)); >> + =A0gimple_set_bb (pattern_stmt, gimple_bb (stmt)); >> >> do you really need this? > > Yes, there are a lot of uses of gimple_bb (stmt). Otherwise, we'd have > to check there that bb exists (or that this is not a pattern stmt) and > use the bb of the original statement if not. I see. It's not really uglier than the part where you have to special-case them when walking use-operands, so ... Still a lot better than when inserting them for real. >> Otherwise it looks reasonable. =A0Btw, >> we can probably remove the simple DCE done in >> slpeel_tree_peel_loop_to_edge (remove_dead_stmts_from_loop) >> with this patch. > > I'll try that. Thanks, Richard. > Thanks, > Ira > >> >> Thanks, >> Richard. >> >>> Thanks, >>> Ira >>> >>> ChangeLog: >>> >>> =A0 =A0 * tree-vect-loop.c (vect_determine_vectorization_factor): Don't >>> =A0 =A0 remove irrelevant pattern statements. =A0For irrelevant stateme= nts >>> =A0 =A0 check if it is the last statement of a detected pattern, use >>> =A0 =A0 corresponding pattern statement instead. >>> =A0 =A0 (destroy_loop_vec_info): No need to remove pattern statements, >>> =A0 =A0 only free stmt_vec_info. >>> =A0 =A0 (vect_transform_loop): For irrelevant statements check if it is >>> =A0 =A0 the last statement of a detected pattern, use corresponding >>> =A0 =A0 pattern statement instead. >>> =A0 =A0 * tree-vect-patterns.c (vect_pattern_recog_1): Don't insert >>> =A0 =A0 pattern statements. =A0Set basic block for the new statement. >>> =A0 =A0 (vect_pattern_recog): Update documentation. >>> =A0 =A0 * tree-vect-stmts.c (vect_mark_stmts_to_be_vectorized): Scan >>> =A0 =A0 operands of pattern statements. >>> =A0 =A0 (vectorizable_call): Fix printing. =A0In case of a pattern stat= ement >>> =A0 =A0 use the lhs of the original statement when creating a dummy >>> =A0 =A0 statement to replace the original call. >>> =A0 =A0 (vect_analyze_stmt): For irrelevant statements check if it is >>> =A0 =A0 the last statement of a detected pattern, use corresponding >>> =A0 =A0 pattern statement instead. >>> =A0 =A0 * tree-vect-slp.c (vect_schedule_slp_instance): For pattern >>> =A0 =A0 statements use gsi of the original statement. >>> >> >