From patchwork Sun Oct 9 15:09:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 118590 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 D8251B70CA for ; Mon, 10 Oct 2011 02:10:12 +1100 (EST) Received: (qmail 5943 invoked by alias); 9 Oct 2011 15:10:09 -0000 Received: (qmail 5931 invoked by uid 22791); 9 Oct 2011 15:10:08 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, TW_TM X-Spam-Check-By: sourceware.org Received: from mail-gy0-f175.google.com (HELO mail-gy0-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 09 Oct 2011 15:09:43 +0000 Received: by gyg8 with SMTP id 8so5594323gyg.20 for ; Sun, 09 Oct 2011 08:09:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.146.2.5 with SMTP id 5mr2912829yab.27.1318172982474; Sun, 09 Oct 2011 08:09:42 -0700 (PDT) Received: by 10.147.99.14 with HTTP; Sun, 9 Oct 2011 08:09:42 -0700 (PDT) Date: Sun, 9 Oct 2011 17:09:42 +0200 Message-ID: Subject: [patch] Fix PR tree-optimization/50635 From: Ira Rosen To: gcc-patches@gcc.gnu.org Cc: Patch Tracking 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 Hi, In vectorizer pattern recognition when a pattern def_stmt already exists, we need to mark it properly for the current pattern. Another problem is that we don't really have to check that TYPE_OUT is a vector type. It is set by the pattern detection procedures, and if the type is invalid we fail later in the operation analysis anyway. Bootstrapped and tested on powerpc64-suse-linux. Committed. Ira ChangeLog: PR tree-optimization/50635 * tree-vect-patterns.c (vect_handle_widen_mult_by_const): Add DEF_STMT to the list of statements to be replaced by the pattern statements. (vect_handle_widen_mult_by_const): Don't check TYPE_OUT. testsuite/ChangeLog: PR tree-optimization/50635 * gcc.dg/vect/pr50635.c: New test. Index: testsuite/gcc.dg/vect/pr50635.c =================================================================== --- testsuite/gcc.dg/vect/pr50635.c (revision 0) +++ testsuite/gcc.dg/vect/pr50635.c (revision 0) @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +typedef signed long int32_t; +typedef char int8_t; + +void f0a(int32_t * result, int32_t * arg1, int8_t * arg2, int32_t temp_3) +{ + int idx; + for (idx=0;idx<10;idx += 1) + { + int32_t temp_4; + int32_t temp_12; + + temp_4 = (-2 & arg2[idx]) + temp_3; + temp_12 = -2 * arg2[idx] + temp_4; + result[idx] = temp_12; + } +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ + Index: tree-vect-patterns.c =================================================================== --- tree-vect-patterns.c (revision 179718) +++ tree-vect-patterns.c (working copy) @@ -388,6 +388,7 @@ vect_handle_widen_mult_by_const (gimple stmt, tree || TREE_TYPE (gimple_assign_lhs (new_stmt)) != new_type) return false; + VEC_safe_push (gimple, heap, *stmts, def_stmt); *oprnd = gimple_assign_lhs (new_stmt); } else @@ -1424,8 +1425,6 @@ vect_pattern_recog_1 (vect_recog_func_ptr vect_rec { /* No need to check target support (already checked by the pattern recognition function). */ - if (type_out) - gcc_assert (VECTOR_MODE_P (TYPE_MODE (type_out))); pattern_vectype = type_out ? type_out : type_in; } else