From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27408 invoked by alias); 14 Jun 2011 10:03:12 -0000 Received: (qmail 27397 invoked by uid 22791); 14 Jun 2011 10:03: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-f41.google.com (HELO mail-ww0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 14 Jun 2011 10:02:56 +0000 Received: by wwi18 with SMTP id 18so3221201wwi.2 for ; Tue, 14 Jun 2011 03:02:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.199.19 with SMTP id eq19mr6233911wbb.75.1308045774639; Tue, 14 Jun 2011 03:02:54 -0700 (PDT) Received: by 10.227.28.69 with HTTP; Tue, 14 Jun 2011 03:02:54 -0700 (PDT) In-Reply-To: References: Date: Tue, 14 Jun 2011 10:05: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/msg01024.txt.bz2 On Mon, Jun 13, 2011 at 2:43 PM, Ira Rosen wrote: > On 10 June 2011 12:14, Richard Guenther wrot= e: >> 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. > > Bootstrapped and now testing on powerpc64-suse-linux (tested > vectorizer testsuite on powerpc64-suse-linux and x86_64-suse-linux. > > What do you think? /* Mark the stmts that are involved in the pattern. */ - gsi_insert_before (&si, pattern_stmt, GSI_SAME_STMT); set_vinfo_for_stmt (pattern_stmt, new_stmt_vec_info (pattern_stmt, loop_vinfo, NULL)); + gimple_set_bb (pattern_stmt, gimple_bb (stmt)); do you really need this? Otherwise it looks reasonable. Btw, we can probably remove the simple DCE done in slpeel_tree_peel_loop_to_edge (remove_dead_stmts_from_loop) with this patch. 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 statements > =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 statem= ent > =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. >