From patchwork Thu Nov 26 08:34:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sujoy Saraswati X-Patchwork-Id: 57321 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp374423lbb; Thu, 26 Nov 2015 00:36:10 -0800 (PST) X-Received: by 10.98.67.207 with SMTP id l76mr38281148pfi.59.1448526970462; Thu, 26 Nov 2015 00:36:10 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id e25si40397697pfb.189.2015.11.26.00.36.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Nov 2015 00:36:10 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-415462-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-return-415462-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-415462-patch=linaro.org@gcc.gnu.org; dkim=pass header.i=@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=Ful lGah6uP71YlA5FP2gAqxqkyt8OLeExVKSrIkzvKXlosc/A+v92Gf0dC+XMcJWSsA VPJuH2QOYgV3wBg1jm/GZ3Aa3HUFw0RBPOw2BZJ1+msBSvyvoS7F45KWJ1jyxI70 zFOmNKuE4JnAZBjd/fr8AKuuou80yJwDAhgdaJGE= 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:from :to:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; s=default; bh=z77CepXik HLTXge+GjtdjBPH3G0=; b=vPGgMfEdExSTXq/HZcnWQmJXZp4qV3xFqBun/1Ha8 6hn7n5Xum0+efNDtENSxQCv+nGmlHM+z/n9gIPgZOEuqAofDUJDEUxHnPtgW6DqG HnWvQp9hZ+ndexX9oYTpL0nNODyugAG4Mk5xyAerjuBvnGLk5+92kjMD0hlzHXmC DM= Received: (qmail 104903 invoked by alias); 26 Nov 2015 08:35:58 -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 104886 invoked by uid 89); 26 Nov 2015 08:35:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.7 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-HELO: g4t3425.houston.hp.com Received: from g4t3425.houston.hp.com (HELO g4t3425.houston.hp.com) (15.201.208.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 26 Nov 2015 08:35:57 +0000 Received: from G9W0364.americas.hpqcorp.net (g9w0364.houston.hp.com [16.216.193.45]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by g4t3425.houston.hp.com (Postfix) with ESMTPS id 2DEA5D1; Thu, 26 Nov 2015 08:35:55 +0000 (UTC) Received: from G4W6300.americas.hpqcorp.net (16.210.26.225) by G9W0364.americas.hpqcorp.net (16.216.193.45) with Microsoft SMTP Server (TLS) id 14.3.169.1; Thu, 26 Nov 2015 08:34:52 +0000 Received: from G4W3297.americas.hpqcorp.net ([169.254.11.80]) by G4W6300.americas.hpqcorp.net ([16.210.26.225]) with mapi id 14.03.0169.001; Thu, 26 Nov 2015 08:34:51 +0000 From: "Saraswati, Sujoy (OSTL)" To: Joseph Myers , Sujoy Saraswati , GCC Patches CC: Richard Biener Subject: Fix 61441 [4/5] Produce quiet NaN for real value operations Date: Thu, 26 Nov 2015 08:34:51 +0000 Message-ID: <5379BA8D7E9D7E4D87BF6749A92854C248FC90E3@G4W3297.americas.hpqcorp.net> MIME-Version: 1.0 Hi, This patch makes resulting NaN values to be quiet NaN for real value operations, irrespective of the flag_signaling_nans flag. The caller has the responsibility to avoid the operation if flag_signaling_nans is on. Regards, Sujoy 2015-11-26 Sujoy Saraswati PR tree-optimization/61441 * real.c (do_add): Make resulting NaN value to be qNaN. (do_multiply, do_divide, do_fix_trunc): Same. (real_arithmetic, real_ldexp, real_convert): Same. (real_isinteger): Updated comment stating it returns false for sNaN. =================================================================== diff -u -p a/gcc/real.c b/gcc/real.c --- a/gcc/real.c 2015-11-25 10:35:29.059583459 +0530 +++ b/gcc/real.c 2015-11-25 15:07:53.604085529 +0530 @@ -541,6 +541,10 @@ do_add (REAL_VALUE_TYPE *r, const REAL_V case CLASS2 (rvc_normal, rvc_inf): /* R + Inf = Inf. */ *r = *b; + /* Make resulting NaN value to be qNaN. The caller has the + responsibility to avoid the operation if flag_signaling_nans + is on. */ + r->signalling = 0; r->sign = sign ^ subtract_p; return false; @@ -554,6 +558,10 @@ do_add (REAL_VALUE_TYPE *r, const REAL_V case CLASS2 (rvc_inf, rvc_normal): /* Inf + R = Inf. */ *r = *a; + /* Make resulting NaN value to be qNaN. The caller has the + responsibility to avoid the operation if flag_signaling_nans + is on. */ + r->signalling = 0; return false; case CLASS2 (rvc_inf, rvc_inf): @@ -676,6 +684,10 @@ do_multiply (REAL_VALUE_TYPE *r, const R case CLASS2 (rvc_nan, rvc_nan): /* ANY * NaN = NaN. */ *r = *b; + /* Make resulting NaN value to be qNaN. The caller has the + responsibility to avoid the operation if flag_signaling_nans + is on. */ + r->signalling = 0; r->sign = sign; return false; @@ -684,6 +696,10 @@ do_multiply (REAL_VALUE_TYPE *r, const R case CLASS2 (rvc_nan, rvc_inf): /* NaN * ANY = NaN. */ *r = *a; + /* Make resulting NaN value to be qNaN. The caller has the + responsibility to avoid the operation if flag_signaling_nans + is on. */ + r->signalling = 0; r->sign = sign; return false; @@ -826,6 +842,10 @@ do_divide (REAL_VALUE_TYPE *r, const REA case CLASS2 (rvc_nan, rvc_nan): /* ANY / NaN = NaN. */ *r = *b; + /* Make resulting NaN value to be qNaN. The caller has the + responsibility to avoid the operation if flag_signaling_nans + is on. */ + r->signalling = 0; r->sign = sign; return false; @@ -834,6 +854,10 @@ do_divide (REAL_VALUE_TYPE *r, const REA case CLASS2 (rvc_nan, rvc_inf): /* NaN / ANY = NaN. */ *r = *a; + /* Make resulting NaN value to be qNaN. The caller has the + responsibility to avoid the operation if flag_signaling_nans + is on. */ + r->signalling = 0; r->sign = sign; return false; @@ -964,6 +988,10 @@ do_fix_trunc (REAL_VALUE_TYPE *r, const case rvc_zero: case rvc_inf: case rvc_nan: + /* Make resulting NaN value to be qNaN. The caller has the + responsibility to avoid the operation if flag_signaling_nans + is on. */ + r->signalling = 0; break; case rvc_normal: @@ -1022,7 +1050,13 @@ real_arithmetic (REAL_VALUE_TYPE *r, int case MIN_EXPR: if (op1->cl == rvc_nan) + { *r = *op1; + /* Make resulting NaN value to be qNaN. The caller has the + responsibility to avoid the operation if flag_signaling_nans + is on. */ + r->signalling = 0; + } else if (do_compare (op0, op1, -1) < 0) *r = *op0; else @@ -1031,7 +1065,13 @@ real_arithmetic (REAL_VALUE_TYPE *r, int case MAX_EXPR: if (op1->cl == rvc_nan) + { *r = *op1; + /* Make resulting NaN value to be qNaN. The caller has the + responsibility to avoid the operation if flag_signaling_nans + is on. */ + r->signalling = 0; + } else if (do_compare (op0, op1, 1) < 0) *r = *op1; else @@ -1162,6 +1202,10 @@ real_ldexp (REAL_VALUE_TYPE *r, const RE case rvc_zero: case rvc_inf: case rvc_nan: + /* Make resulting NaN value to be qNaN. The caller has the + responsibility to avoid the operation if flag_signaling_nans + is on. */ + r->signalling = 0; break; case rvc_normal: @@ -2731,6 +2775,12 @@ real_convert (REAL_VALUE_TYPE *r, format round_for_format (fmt, r); + /* Make resulting NaN value to be qNaN. The caller has the + responsibility to avoid the operation if flag_signaling_nans + is on. */ + if (r->cl == rvc_nan) + r->signalling = 0; + /* round_for_format de-normalizes denormals. Undo just that part. */ if (r->cl == rvc_normal) normalize (r); @@ -4944,7 +4994,8 @@ real_copysign (REAL_VALUE_TYPE *r, const r->sign = x->sign; } -/* Check whether the real constant value given is an integer. */ +/* Check whether the real constant value given is an integer. + Returns false for signalling NaN. */ bool real_isinteger (const REAL_VALUE_TYPE *c, format_helper fmt)