From patchwork Thu Mar 3 11:04:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 591391 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 89231140E47 for ; Thu, 3 Mar 2016 22:04:46 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=PKEPvbmx; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=QyP0An/CwArrhzzvGlL85Vkbnxm0m5K1vUu6+OTZxvaNKsvUY+5iJ wS0DQKIsr0+k0e/sCe7EgQuWB91GPKWqmBEni8J5/0m1o9WVMw1JOhQEYL2lqv8I eogqWGzN6w5LyCsgnryzJK0K/OrcmW+oaV9oGYW1HqVPYdqwjNAPT8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=4CEFVFsY/2k+8+BhvlRMuvOP5p0=; b=PKEPvbmxwkuetnGL3crD 8+GzowMpjuR5C39Qz1+ZiC4kgZJlDsHtFUUHJKwyIP4rLajNc4k8/BXwE5COusVj WzgRic5mKNzD78Q7FRtlRyseZmf1A3Q7b5Qem1ITB8pr7VTUltj9dr4Gt/JxJ2Y5 6UwiJLULsqX2JOvPsLSjArk= Received: (qmail 50640 invoked by alias); 3 Mar 2016 11:04:38 -0000 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 Received: (qmail 50617 invoked by uid 89); 3 Mar 2016 11:04:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1370 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 03 Mar 2016 11:04:36 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 6BAB964D23 for ; Thu, 3 Mar 2016 11:04:35 +0000 (UTC) Received: from redhat.com (ovpn-204-101.brq.redhat.com [10.40.204.101]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u23B4WgF018083 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 3 Mar 2016 06:04:34 -0500 Date: Thu, 3 Mar 2016 12:04:31 +0100 From: Marek Polacek To: GCC Patches Subject: [PATCH] Fix ICE with vector types in X % -Y pattern (PR middle-end/70050) Message-ID: <20160303110431.GB10006@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) We crashed on the attached testcase because we were trying to apply the X % -Y -> X % Y transformation even on vectors. That doesn't go well with the check for !TYPE_UNSIGNED. So I think let's limit the pattern to only work on integral types. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2016-03-03 Marek Polacek PR middle-end/70050 * match.pd (X % -Y): Add INTEGRAL_TYPE_P check. * gcc.dg/pr70050.c: New test. Marek diff --git gcc/match.pd gcc/match.pd index 5903782..112deb3 100644 --- gcc/match.pd +++ gcc/match.pd @@ -293,7 +293,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* X % -Y is the same as X % Y. */ (simplify (trunc_mod @0 (convert? (negate @1))) - (if (!TYPE_UNSIGNED (type) + (if (INTEGRAL_TYPE_P (type) + && !TYPE_UNSIGNED (type) && !TYPE_OVERFLOW_TRAPS (type) && tree_nop_conversion_p (type, TREE_TYPE (@1)) /* Avoid this transformation if X might be INT_MIN or diff --git gcc/testsuite/gcc.dg/pr70050.c gcc/testsuite/gcc.dg/pr70050.c index e69de29..610456f 100644 --- gcc/testsuite/gcc.dg/pr70050.c +++ gcc/testsuite/gcc.dg/pr70050.c @@ -0,0 +1,11 @@ +/* PR middle-end/70025 */ +/* { dg-do compile } */ +/* { dg-options "-Wno-psabi" } */ + +typedef int v8si __attribute__ ((vector_size (32))); + +v8si +foo (v8si v) +{ + return v %= -v; +}