From patchwork Thu Jul 13 20:41:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 787977 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 3x7nmM0MS7z9s81 for ; Fri, 14 Jul 2017 06:41:38 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="E38qRLJx"; 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:reply-to:mime-version:content-type; q=dns; s=default; b=TITmsHxIgyoLPAk9ALEz2mE6C7EeTrXIyFZR0HjS56Q wbUIDZd3MeUP3SDkQneQCgQPagI3mBNjP2uddcRjkddMl7r1Dtc4CA4r4Q/Mxf2l U28mbB9CMgqS3qNkMHwd4zYY8qu7YYk4ln2vxMblKo6w0b8y5xZhg97Ibhz+MoPQ = 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:reply-to:mime-version:content-type; s=default; bh=9aHqlmDvPdj+wjKgroTjYLDbH7c=; b=E38qRLJxeU5QWrZ5u cUNGmA7MAuHPZBQk2V+cll6iImbjAphWoDPBnnKIcoTMfTVfJRx7M0ajNpVuUJbR UGJd7vohiWFPldgBMZW5jkUumq9zR4/0wYb7Z6GsHJl67qqQ/to4ETe9T3I2c6QN 8xjE9YCbgoIztvpZdv6qKG/5Mk= Received: (qmail 59820 invoked by alias); 13 Jul 2017 20:41:24 -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 59766 invoked by uid 89); 13 Jul 2017 20:41:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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 ESMTP; Thu, 13 Jul 2017 20:41:22 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 625A980C1A for ; Thu, 13 Jul 2017 20:41:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 625A980C1A Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 625A980C1A Received: from tucnak.zalov.cz (ovpn-116-143.ams2.redhat.com [10.36.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 05D4961F25 for ; Thu, 13 Jul 2017 20:41:20 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v6DKfITH008723 for ; Thu, 13 Jul 2017 22:41:19 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v6DKfIVJ008722 for gcc-patches@gcc.gnu.org; Thu, 13 Jul 2017 22:41:18 +0200 Date: Thu, 13 Jul 2017 22:41:18 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix ICE on _Fract division (PR tree-optimization/81428) Message-ID: <20170713204118.GS2123@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes Hi! _Fract types can't express 1, other spots that call build_one_cst already make sure that the type is integral or uses the !ALL_FRACT_MODE_P (TYPE_MODE (type)) check I've added in this patch. Bootstrapped/regtested on x86_64-linux and i686-linux and tested with a cross to arm on the testcase. Ok for trunk? 2017-07-13 Jakub Jelinek PR tree-optimization/81428 * match.pd (X / X -> one): Don't optimize _Fract divisions, as 1 can't be built for those types. * gcc.dg/fixed-point/pr81428.c: New test. Jakub --- gcc/match.pd.jj 2017-07-13 15:37:34.000000000 +0200 +++ gcc/match.pd 2017-07-13 15:46:11.194593051 +0200 @@ -243,8 +243,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* X / X is one. */ (simplify (div @0 @0) - /* But not for 0 / 0 so that we can get the proper warnings and errors. */ - (if (!integer_zerop (@0)) + /* But not for 0 / 0 so that we can get the proper warnings and errors. + And not for _Fract types where we can't build 1. */ + (if (!integer_zerop (@0) && !ALL_FRACT_MODE_P (TYPE_MODE (type))) { build_one_cst (type); })) /* X / abs (X) is X < 0 ? -1 : 1. */ (simplify --- gcc/testsuite/gcc.dg/fixed-point/pr81428.c.jj 2017-07-13 15:49:52.980806440 +0200 +++ gcc/testsuite/gcc.dg/fixed-point/pr81428.c 2017-07-13 15:49:29.000000000 +0200 @@ -0,0 +1,9 @@ +/* PR tree-optimization/81428 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void +foo (long _Fract *a, long _Fract *b) +{ + *b = *a / *a; +}