From patchwork Mon Mar 12 21:14:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 885031 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-474644-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="jl7o1TXq"; dkim-atps=neutral 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 400p8k4MG9z9sT6 for ; Tue, 13 Mar 2018 19:35:50 +1100 (AEDT) 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:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=k3Udp+pqiLYL5KAHZcqL6Qtz2FnJq f7TKDbgPwFw5zUSwO5d+WixBSA5xwaj2cN5lL2eWNdIG7Tyf7MuwlQqLO+qNUVOZ KD5i6EicJBwgoxr9kc4sMgcCMVOB+Ozk/2BIGLVVktOBGN/6P2jU2j+mM2+9hapt qxaZqmTED+uvQo= 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:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=5UcvGMgTPFqhHqNw7PnRtfLhJTM=; b=jl7 o1TXqJfImxieAMYhCEVNx4A9Jc2VDIFNrEBY2z0Gm6uQm02ivebXV6pHdvWdH7Cj rlr6B4D0FAJ/zSwYufgir6gC6XIuTtx0H4RRZcf7bUTJc8lNqgEy+u9NWaPDltvY kMoQdis+W0d8uqp4n0tNcqDKAWDWpzCXy78n7rSQ= Received: (qmail 88930 invoked by alias); 13 Mar 2018 08:35:32 -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 88883 invoked by uid 89); 13 Mar 2018 08:35:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1736 X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Mar 2018 08:35:26 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D907EEB713 for ; Tue, 13 Mar 2018 08:35:19 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.36.118.110]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22CB27C48 for ; Tue, 13 Mar 2018 08:35:19 +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 w2CLE2Gx001692; Mon, 12 Mar 2018 22:14:02 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w2CLE09O001691; Mon, 12 Mar 2018 22:14:00 +0100 Date: Mon, 12 Mar 2018 22:14:00 +0100 From: Jakub Jelinek To: Uros Bizjak , "Joseph S. Myers" Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix __builtin_round{,f,l} ICE on x86 (PR target/84827) Message-ID: <20180312211400.GV8577@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes Hi! Since r237074 the 387 rounding insns are guarded with (flag_fp_int_builtin_inexact || !flag_trapping_math), and the round2 expander is enabled for 387 fancy math whenever flag_unsafe_math_optimizations; as the testcase shows, the latter doesn't imply the former, so this patch adds another guard. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-03-12 Jakub Jelinek PR target/84827 * config/i386/i386.md (round2): For 387 fancy math, disable pattern if -ftrapping-math -fno-fp-int-builtin-inexact. * gcc.target/i386/pr84827.c: New test. Jakub --- gcc/config/i386/i386.md.jj 2018-03-05 16:59:42.881641832 +0100 +++ gcc/config/i386/i386.md 2018-03-12 15:54:28.925304229 +0100 @@ -16311,7 +16311,8 @@ (define_expand "round2" "(TARGET_USE_FANCY_MATH_387 && (!(SSE_FLOAT_MODE_P (mode) && TARGET_SSE_MATH) || TARGET_MIX_SSE_I387) - && flag_unsafe_math_optimizations) + && flag_unsafe_math_optimizations + && (flag_fp_int_builtin_inexact || !flag_trapping_math)) || (SSE_FLOAT_MODE_P (mode) && TARGET_SSE_MATH && !flag_trapping_math && !flag_rounding_math)" { --- gcc/testsuite/gcc.target/i386/pr84827.c.jj 2018-03-12 16:04:20.195411779 +0100 +++ gcc/testsuite/gcc.target/i386/pr84827.c 2018-03-12 15:54:58.041309098 +0100 @@ -0,0 +1,21 @@ +/* PR target/84827 */ +/* { dg-do compile } */ +/* { dg-options "-Ofast -fno-fp-int-builtin-inexact -ftrapping-math -fno-associative-math -mfpmath=387" } */ + +double +f1 (double a) +{ + return __builtin_round (a); +} + +float +f2 (float a) +{ + return __builtin_roundf (a); +} + +long double +f3 (long double a) +{ + return __builtin_roundl (a); +}