From patchwork Wed May 9 12:38:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Matz X-Patchwork-Id: 157938 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 AB1DAB6FA8 for ; Wed, 9 May 2012 22:39:06 +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=1337171947; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:Message-ID:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=bfCI225HTSqsf/mUAX2l XAMIPo4=; b=SE/RWHxlJ0vS8Xl4i70TO30XFAx3+/3NQVRtPC2Bti6joDCVgQbt uKkhKzGVYszNbO7Z+BeHFduW+0eD7GmepEX4CvDCPRNsZKnp9A8D4SBcQMCzJ8al Q4yPuM46JF9Dp+uxsxuR727ftJh1rcrNhoMN66ltBdUpbxo+1ohMWus= 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:Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=gPicpm3m7VqNqhprPl+EoliHZQB/ArC017YVEU5NrI+tms51HmFUJz+aHxpPsh H/YNP+Sc3wQX7EJZ2za44Fpp1RdPBa78bBftPas/lJbOILE5pIONQwlub/uCxOw0 De2rLS4HxxpZqnlEQQkEeHbgdhlOGN4lD4adDVaEzaOvM=; Received: (qmail 27966 invoked by alias); 9 May 2012 12:39:00 -0000 Received: (qmail 27890 invoked by uid 22791); 9 May 2012 12:38:59 -0000 X-SWARE-Spam-Status: No, hits=-5.1 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 09 May 2012 12:38:46 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 3E11496D8B for ; Wed, 9 May 2012 14:38:45 +0200 (CEST) Date: Wed, 9 May 2012 14:38:45 +0200 (CEST) From: Michael Matz To: gcc-patches@gcc.gnu.org Subject: Fix PR53185 (vectorizer segfault) Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes 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, the current code for strided loads can't deal with the situation when a prologue loop (peeling for alignment) is created after analyzing the data refs. There are multiple issues (non-constant steps in DRs mainly), so this is a simple stop gap. Regtesting on x86_64-linux (all langs) in progress. Okay for trunk? Ciao, Michael. -------------------- PR tree-optimization/53185 * tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Disable peeling when we see strided loads. testsuite/ * gcc.dg/vect/pr53185.c: New test. Index: tree-vect-data-refs.c =================================================================== --- tree-vect-data-refs.c (revision 187287) +++ tree-vect-data-refs.c (working copy) @@ -1507,6 +1507,17 @@ vect_enhance_data_refs_alignment (loop_v && GROUP_FIRST_ELEMENT (stmt_info) != stmt) continue; + /* FORNOW: Any strided load prevents peeling. The induction + variable analysis will fail when the prologue loop is generated, + and so we can't generate the new base for the pointer. */ + if (STMT_VINFO_STRIDE_LOAD_P (stmt_info)) + { + if (vect_print_dump_info (REPORT_DETAILS)) + fprintf (vect_dump, "strided load prevents peeling"); + do_peeling = false; + break; + } + /* For invariant accesses there is nothing to enhance. */ if (integer_zerop (DR_STEP (dr))) continue; Index: testsuite/gcc.dg/vect/pr53185.c =================================================================== --- testsuite/gcc.dg/vect/pr53185.c (revision 0) +++ testsuite/gcc.dg/vect/pr53185.c (revision 0) @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -ftree-vectorize" } */ +unsigned short a, e; +int *b, *d; +int c; +extern int fn2(); +void fn1 () { + void *f; + for (;;) { + fn2 (); + b = f; + e = 0; + for (; e < a; ++e) + b[e] = d[e * c]; + } +}