From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13848 invoked by alias); 7 Apr 2016 09:33:09 -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 13829 invoked by uid 89); 7 Apr 2016 09:33:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=HContent-Transfer-Encoding:8bit X-HELO: mail-wm0-f46.google.com Received: from mail-wm0-f46.google.com (HELO mail-wm0-f46.google.com) (74.125.82.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 07 Apr 2016 09:33:06 +0000 Received: by mail-wm0-f46.google.com with SMTP id n3so96416632wmn.0 for ; Thu, 07 Apr 2016 02:33:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:from:date:to:cc:message-id; bh=i85iYXBcVnVBr60gDEwzzFCx3pADm2AYB/kzweGd6h4=; b=ZJ50Bd0AcmppfxEM88Re6mPdaZYwft/0DRFBmPnM9lgKtCSHJmFUjmQDH7yg5Ofla+ xu6zVMEcsJlb4fXm9Ak4U015kFgPEoZ/DPuNxauBSKLLe6Mj7WTwyh7P5rf77D3UG+dy Lu0dlN5wi6wXOGP+lCjNlAehKuQP3GKSUOKCoaynM9fwq5mC1pVvqzqy339swzDDq7Px vdSXy7GUuo8mY4wbw/bSUKPBYmR1NQHV/Bvbx7XLjkdrYGc0QgKkjx/0b9FywdJ/vvda ZAVTEpIYXdaONjvkFne1KGO4dUE/Ia2RxGVFIy0Tj5HiKqIiu7r05Bg5aImTCB6Yi6f1 MZeA== X-Gm-Message-State: AD7BkJI6PaIr0TatxbRD/avtJUOZ8SiNNACHsP3R5mpqCKbXGmabDBh/U4XnZHdHrO9pLQ== X-Received: by 10.194.249.72 with SMTP id ys8mr2331626wjc.58.1460021583613; Thu, 07 Apr 2016 02:33:03 -0700 (PDT) Received: from 192-168-178-29.fritz.box (p5DCED3C7.dip0.t-ipconnect.de. [93.206.211.199]) by smtp.gmail.com with ESMTPSA id o128sm7933394wmb.19.2016.04.07.02.33.01 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 07 Apr 2016 02:33:02 -0700 (PDT) User-Agent: K-9 Mail for Android In-Reply-To: <20160407080354.GJ18129@bubble.grove.modra.org> References: <20160405083340.GD18129@bubble.grove.modra.org> <20160406083153.GF18129@bubble.grove.modra.org> <20160406091919.GG18129@bubble.grove.modra.org> <20160407080354.GJ18129@bubble.grove.modra.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Subject: Re: [PATCH] PR70117, ppc long double isinf From: Richard Biener Date: Thu, 07 Apr 2016 09:33:00 -0000 To: Alan Modra CC: GCC Patches Message-ID: X-IsSubscribed: yes X-SW-Source: 2016-04/txt/msg00327.txt.bz2 On April 7, 2016 10:03:54 AM GMT+02:00, Alan Modra wrote: >On Wed, Apr 06, 2016 at 06:49:19PM +0930, Alan Modra wrote: >> On Wed, Apr 06, 2016 at 10:46:48AM +0200, Richard Biener wrote: >> > Can you add a testcase or two for the isnormal () case? >> >> Sure. I'll adapt the testcase I was using to verify the output, > >Revised testcase - target fixed, compiled at -O2 with volatile vars so >we're testing optimized builtins with non-constant data. > >diff --git a/gcc/testsuite/gcc.target/powerpc/pr70117.c >b/gcc/testsuite/gcc.target/powerpc/pr70117.c >new file mode 100644 >index 0000000..f1fdedb >--- /dev/null >+++ b/gcc/testsuite/gcc.target/powerpc/pr70117.c >@@ -0,0 +1,92 @@ >+/* { dg-do run { target { powerpc*-*-linux* powerpc*-*-darwin* >powerpc*-*-aix* rs6000-*-* } } } */ >+/* { dg-options "-std=c99 -mlong-double-128 -O2" } */ >+ >+#include >+ >+union gl_long_double_union >+{ >+ struct { double hi; double lo; } dd; >+ long double ld; >+}; >+ >+/* This is gnulib's LDBL_MAX which, being 107 bits in precision, is >+ slightly larger than gcc's 106 bit precision LDBL_MAX. */ >+volatile union gl_long_double_union gl_LDBL_MAX = >+ { { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } >}; >+ >+volatile double min_denorm = 0x1p-1074; >+volatile double ld_low = 0x1p-969; >+volatile double dinf = 1.0/0.0; >+volatile double dnan = 0.0/0.0; >+ >+int >+main (void) >+{ >+ long double ld; >+ >+ ld = gl_LDBL_MAX.ld; >+ if (__builtin_isinfl (ld)) >+ __builtin_abort (); >+ ld = -gl_LDBL_MAX.ld; >+ if (__builtin_isinfl (ld)) >+ __builtin_abort (); >+ >+ ld = gl_LDBL_MAX.ld; >+ if (!__builtin_isfinite (ld)) >+ __builtin_abort (); >+ ld = -gl_LDBL_MAX.ld; >+ if (!__builtin_isfinite (ld)) >+ __builtin_abort (); >+ >+ ld = ld_low; >+ if (!__builtin_isnormal (ld)) >+ __builtin_abort (); >+ ld = -ld_low; >+ if (!__builtin_isnormal (ld)) >+ __builtin_abort (); >+ >+ ld = -min_denorm; >+ ld += ld_low; >+ if (__builtin_isnormal (ld)) >+ __builtin_abort (); >+ ld = min_denorm; >+ ld -= ld_low; >+ if (__builtin_isnormal (ld)) >+ __builtin_abort (); >+ >+ ld = 0.0; >+ if (__builtin_isnormal (ld)) >+ __builtin_abort (); >+ ld = -0.0; >+ if (__builtin_isnormal (ld)) >+ __builtin_abort (); >+ >+ ld = LDBL_MAX; >+ if (!__builtin_isnormal (ld)) >+ __builtin_abort (); >+ ld = -LDBL_MAX; >+ if (!__builtin_isnormal (ld)) >+ __builtin_abort (); >+ >+ ld = gl_LDBL_MAX.ld; >+ if (!__builtin_isnormal (ld)) >+ __builtin_abort (); >+ ld = -gl_LDBL_MAX.ld; >+ if (!__builtin_isnormal (ld)) >+ __builtin_abort (); >+ >+ ld = dinf; >+ if (__builtin_isnormal (ld)) >+ __builtin_abort (); >+ ld = -dinf; >+ if (__builtin_isnormal (ld)) >+ __builtin_abort (); >+ >+ ld = dnan; >+ if (__builtin_isnormal (ld)) >+ __builtin_abort (); >+ ld = -dnan; >+ if (__builtin_isnormal (ld)) >+ __builtin_abort (); >+ return 0; >+} > >> > What does XLC do here? >> >> Not sure, sorry. I don't have xlc handy. Will try later. > >It seems that to compile 128-bit long double with xlc, I need xlc128, >and I don't have that.. For a double, xlc implements isnormal() on >power8 by moving the fpr argument to a gpr followed by a bunch of bit >twiddling to test the exponent. xlc's sequence isn't as good as it >could be, 15 insns. The ideal ought to be the following, I think, >which gcc compiles to 8 insns on power8 (and could be 7 insns if a >useless sign extension was eliminated). > >int >bit_isnormal (double x) >{ > union { double d; uint64_t l; } val; > val.d = x; > uint64_t exp = (val.l >> 52) & 0x7ff; > return exp - 1 < 0x7fe; >} > >The above is around twice as fast as fold_builtin_interclass_mathfn >implementation of isnormal() for double, on power8. I expect a bit >twiddling implementation for IBM extended would show similar or better >improvement. > >However I'm not inclined to pursue this, especially for gcc-6. The >patch I posted for isnormal() IBM extended is already faster (about >65% average timing on power8) than what existed previously. That's good to know. I think the patch is OK but please seek approval from a ppc maintainer as well Thanks, Richard.