From patchwork Thu Jan 12 14:42:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 135638 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 86E30B6F67 for ; Fri, 13 Jan 2012 01:43:16 +1100 (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=1326984197; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Subject:To:Message-ID:From:Date: MIME-Version:Content-type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=K9gTGMsGBcALP7OibKcpk6eOUeU=; b=ccr3kTmqoy7WZxW XbowxpYkcC6Z2sGKlweW1K7wws/xqHzQkG7N9KiJwl5PSn2oKmqExeXhpjFxp6Vr WwQ2Z9xhS3KBAxkvdBJm64se+e4i0Pn70Wo81K+bF1+Rb0KUMUUFNm7RgiJvYt3N 3ItsncLi+5sXe/C0ZEDpkTMHggFM= 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:Received:Received:Received:Received:Subject:X-KeepSent:To:Message-ID:From:Date:MIME-Version:Content-type:x-cbid:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=hZA5kIj7MURrcRje5SO5jL7QZm8swsxvx6bZgE723kde9JcBKWKF+UAMCMwFI6 kJAHuVlIJqgQ5oyjfzf8jvh/+E0Ou1jkHW176JSgsagrmGgBHT5+r58xNfhuIegX NiTtJRFA6wdO1O5DIMWlpyz2+Da4e5jYooCLgJA2qpnvc=; Received: (qmail 3823 invoked by alias); 12 Jan 2012 14:43:09 -0000 Received: (qmail 3807 invoked by uid 22791); 12 Jan 2012 14:43:07 -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 e06smtp15.uk.ibm.com (HELO e06smtp15.uk.ibm.com) (195.75.94.111) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 12 Jan 2012 14:42:52 +0000 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Jan 2012 14:42:50 -0000 Received: from d06nrmr1507.portsmouth.uk.ibm.com ([9.149.38.233]) by e06smtp15.uk.ibm.com ([192.168.101.145]) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 12 Jan 2012 14:42:48 -0000 Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q0CEgl1x2642150 for ; Thu, 12 Jan 2012 14:42:47 GMT Received: from d06av01.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q0CEglGC015547 for ; Thu, 12 Jan 2012 07:42:47 -0700 Received: from d06ml319.portsmouth.uk.ibm.com (d06ml319.portsmouth.uk.ibm.com [9.149.76.146]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q0CEglcl015544 for ; Thu, 12 Jan 2012 07:42:47 -0700 Subject: [patch] Fix PR tree-optimization/51799 X-KeepSent: E13767AF:DEFDB2CD-C2257983:004428DC; type=4; name=$KeepSent To: gcc-patches@gcc.gnu.org Message-ID: From: Ira Rosen Date: Thu, 12 Jan 2012 16:42:42 +0200 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII x-cbid: 12011214-0342-0000-0000-00000097F1C7 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, In over-widening pattern we expect the last statement to be a type demotion, but don't check this properly. The patch fixes the check, and also updates vect-widen-shift-u8.c to expect additional widening shift pattern instead of over-widening pattern. Bootstrapped and tested on powerpc64-suse-linux and checked with cross for arm-linux-gnueabi. Committed. Ira ChangeLog: PR tree-optimization/51799 * tree-vect-patterns.c (vect_recog_over_widening_pattern): Check that the last operation is a type demotion. testsuite/ChangeLog: PR tree-optimization/51799 * gcc.dg/vect/pr51799.c: New test. * gcc.dg/vect/vect-widen-shift-u8.c: Expect two widening shift patterns. { Index: testsuite/gcc.dg/vect/pr51799.c =================================================================== --- testsuite/gcc.dg/vect/pr51799.c (revision 0) +++ testsuite/gcc.dg/vect/pr51799.c (revision 0) @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned long uint32_t; +void +f0a (uint32_t * __restrict__ result, int8_t * __restrict__ arg1, + uint32_t * __restrict__ arg4, int8_t temp_6) +{ + int idx; + for (idx = 0; idx < 416; idx += 1) + { + result[idx] = (uint8_t)(((arg1[idx] << 7) + arg4[idx]) * temp_6); + } +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ Index: testsuite/gcc.dg/vect/vect-widen-shift-u8.c =================================================================== --- testsuite/gcc.dg/vect/vect-widen-shift-u8.c (revision 183125) +++ testsuite/gcc.dg/vect/vect-widen-shift-u8.c (working copy) @@ -59,7 +59,6 @@ int main (void) return 0; } -/* { dg-final { scan-tree-dump-times "vect_recog_widen_shift_pattern: detected" 1 "vect" { target vect_widen_shift } } } */ +/* { dg-final { scan-tree-dump-times "vect_recog_widen_shift_pattern: detected" 2 "vect" { target vect_widen_shift } } } */ /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ /* { dg-final { cleanup-tree-dump "vect" } } */ - Index: tree-vect-patterns.c =================================================================== --- tree-vect-patterns.c (revision 183125) +++ tree-vect-patterns.c (working copy) @@ -1186,13 +1186,15 @@ vect_recog_over_widening_pattern (VEC (gimple, hea { use_lhs = gimple_assign_lhs (use_stmt); use_type = TREE_TYPE (use_lhs); - /* Support only type promotion or signedess change. Check that USE_TYPE - is not bigger than the original type. */ + /* Support only type demotion or signedess change. */ if (!INTEGRAL_TYPE_P (use_type) - || TYPE_PRECISION (new_type) > TYPE_PRECISION (use_type) - || TYPE_PRECISION (type) < TYPE_PRECISION (use_type)) + || TYPE_PRECISION (type) <= TYPE_PRECISION (use_type)) return NULL; + /* Check that NEW_TYPE is not bigger than the conversion result. */ + if (TYPE_PRECISION (new_type) > TYPE_PRECISION (use_type)) + return NULL; + if (TYPE_UNSIGNED (new_type) != TYPE_UNSIGNED (use_type) || TYPE_PRECISION (new_type) != TYPE_PRECISION (use_type))