From patchwork Tue Oct 5 13:20:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejas Belagod X-Patchwork-Id: 66826 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 CA9ABB70CB for ; Wed, 6 Oct 2010 00:20:38 +1100 (EST) Received: (qmail 14700 invoked by alias); 5 Oct 2010 13:20:37 -0000 Received: (qmail 14690 invoked by uid 22791); 5 Oct 2010 13:20:36 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cam-admin0.cambridge.arm.com (HELO cam-admin0.cambridge.arm.com) (217.140.96.50) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 05 Oct 2010 13:20:28 +0000 Received: from cam-owa2.Emea.Arm.com (cam-owa2.emea.arm.com [10.1.105.18]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id o95DGwF9003423 for ; Tue, 5 Oct 2010 14:16:58 +0100 (BST) Received: from [10.1.67.25] ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 5 Oct 2010 14:20:25 +0100 Subject: [Patch] Fix ICE (PR Tree-Vect/45847). From: Tejas Belagod To: gcc-patches@gcc.gnu.org Date: Tue, 05 Oct 2010 14:20:25 +0100 Message-Id: <1286284825.22296.74.camel@e102484-lin.cambridge.arm.com> Mime-Version: 1.0 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 attached patch fixes Bugzilla 45847 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45847). When compiling without -mvectorize-with-neon-quad and vectorizing scalar widening operations that widen words to double words, there are no corresponding vector types for DI scalar types. For this scenario, a call to get_vect_type_for_scalar_type() returns NULL and an absent NULL-check caused this segfault. The attached patch adds this NULL-check. Also, this is consistent with all the other places where a NULL-check follows a call to get_vect_type_for_scalar_type() in tree-vect-patterns.c. Regression tested with arm-linux-gnueabi. OK? --- Tejas Belagod ARM. gcc/ 2010-10-05 Tejas Belagod * tree-vect-patterns.c (vect_recog_widen_mult_pattern): Add NULL check for vectype_out returned by get_vectype_for_scalar_type(). testsuite/ 2010-10-05 Tejas Belagod * gcc.dg/vect/pr45847.c: New test. diff --git a/gcc/testsuite/gcc.dg/vect/pr45847.c b/gcc/testsuite/gcc.dg/vect/pr45847.c new file mode 100644 index 0000000..f34caa1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr45847.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + + +long long foo (long long *__restrict a, int *__restrict b, int *__restrict c ) +{ + int i; + long long sum=0; + for (i=0;i<256;i++) + sum += (long long)b[i] * c[i]; + + return sum; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ + diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c index 0d5824c..ebe00d6 100644 --- a/gcc/tree-vect-patterns.c +++ b/gcc/tree-vect-patterns.c @@ -413,6 +413,7 @@ vect_recog_widen_mult_pattern (gimple last_stmt, vectype = get_vectype_for_scalar_type (half_type0); vectype_out = get_vectype_for_scalar_type (type); if (!vectype + || !vectype_out || !supportable_widening_operation (WIDEN_MULT_EXPR, last_stmt, vectype_out, vectype, &dummy, &dummy, &dummy_code,