From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@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 20:41:00 -0000 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-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes X-SW-Source: 2017-07/txt/msg00768.txt.bz2 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. --- 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; +} Jakub