From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 185483858C62 for ; Tue, 8 Nov 2022 12:21:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 185483858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 2DACE22494; Tue, 8 Nov 2022 12:21:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1667910087; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E98EqJyYKmApGUp8QUnjz5o8JtCa0Mnv/M4szBVSGMk=; b=EI2Os21SAPKhi5JS8zPOuz2/yzUQsvFW8F9MyV4VMEfxoSRdeqFNEIXldUKw30756yX1n1 eXneEjdoHkPrkbes9+3ATFO5Qee6LDr2G4Edzw375rWVaLjKNCrZtskOIcWImI0BekfTpc qIgiErT1zOnzvNjjGPP+puUUC8smEVQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1667910087; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=E98EqJyYKmApGUp8QUnjz5o8JtCa0Mnv/M4szBVSGMk=; b=Of6bIYiK51jhzfzV3A4GBu/WSAIvL17109lJZx0psbGFr38daxPgoVgrlcwNATws/UMHh4 THeFj0hScNQRGRCA== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id C05C82C142; Tue, 8 Nov 2022 12:21:26 +0000 (UTC) Date: Tue, 8 Nov 2022 12:21:26 +0000 (UTC) From: Richard Biener To: Jakub Jelinek cc: Jeff Law , "Joseph S. Myers" , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] cdce: Fix up get_no_error_domain for new f{16,32,64,128} builtins [PR107547] In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 8 Nov 2022, Jakub Jelinek wrote: > Hi! > > I've missed that this function needs to handle all the builtins that > are handled in can_test_argument_range. > The following patch does that. For many of the builtins (like acos, or > log) it is the same range regardless of the floating point type, but for > some (cosh, sinh, exp{,m1,2}) it is different for each format, > so I had to compute those ranges. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. > Note, seems the existing ranges were in some cases (e.g. for exp2) > the smallest in absolute value which results infinite result, in others > the largest which still results in finite result (but consistently so > for the IEEE single vs. double). I've followed that for IEEE half and > quad cases too, just am not sure why it was like that. I think > get_domain with true, false is open interval rather than closed > and the comments indicate that too, conservatively that is certainly > correct. > > OT, with frange, perhaps we could DCE the calls unconditionally if > frange can prove we are in the domain range. > > 2022-11-08 Jakub Jelinek > > PR tree-optimization/107547 > * tree-call-cdce.cc (get_no_error_domain): Handle CASE_FLT_FN_FLOATN_NX > of BUILT_IN_{ACOS,ASIN,ACOSH,ATANH,LOG,LOG2,LOG10,LOG1P}. Handle > BUILT_IN_{COSH,SINH,EXP,EXPM1,EXP2}F{16,32,64,128}. > > * gcc.dg/pr107547.c: New test. > > --- gcc/tree-call-cdce.cc.jj 2022-10-31 09:04:56.484075098 +0100 > +++ gcc/tree-call-cdce.cc 2022-11-07 14:51:54.223803618 +0100 > @@ -693,20 +693,31 @@ get_no_error_domain (enum built_in_funct > { > /* Trig functions: return [-1, +1] */ > CASE_FLT_FN (BUILT_IN_ACOS): > + CASE_FLT_FN_FLOATN_NX (BUILT_IN_ACOS): > CASE_FLT_FN (BUILT_IN_ASIN): > + CASE_FLT_FN_FLOATN_NX (BUILT_IN_ASIN): > return get_domain (-1, true, true, > 1, true, true); > /* Hyperbolic functions. */ > CASE_FLT_FN (BUILT_IN_ACOSH): > + CASE_FLT_FN_FLOATN_NX (BUILT_IN_ACOSH): > /* acosh: [1, +inf) */ > return get_domain (1, true, true, > 1, false, false); > CASE_FLT_FN (BUILT_IN_ATANH): > + CASE_FLT_FN_FLOATN_NX (BUILT_IN_ATANH): > /* atanh: (-1, +1) */ > return get_domain (-1, true, false, > 1, true, false); > + case BUILT_IN_COSHF16: > + case BUILT_IN_SINHF16: > + /* coshf16: (-11, +11) */ > + return get_domain (-11, true, false, > + 11, true, false); > case BUILT_IN_COSHF: > case BUILT_IN_SINHF: > + case BUILT_IN_COSHF32: > + case BUILT_IN_SINHF32: > /* coshf: (-89, +89) */ > return get_domain (-89, true, false, > 89, true, false); > @@ -714,21 +725,39 @@ get_no_error_domain (enum built_in_funct > case BUILT_IN_SINH: > case BUILT_IN_COSHL: > case BUILT_IN_SINHL: > + case BUILT_IN_COSHF64: > + case BUILT_IN_SINHF64: > /* cosh: (-710, +710) */ > return get_domain (-710, true, false, > 710, true, false); > + case BUILT_IN_COSHF128: > + case BUILT_IN_SINHF128: > + /* coshf128: (-11357, +11357) */ > + return get_domain (-11357, true, false, > + 11357, true, false); > /* Log functions: (0, +inf) */ > CASE_FLT_FN (BUILT_IN_LOG): > + CASE_FLT_FN_FLOATN_NX (BUILT_IN_LOG): > CASE_FLT_FN (BUILT_IN_LOG2): > + CASE_FLT_FN_FLOATN_NX (BUILT_IN_LOG2): > CASE_FLT_FN (BUILT_IN_LOG10): > + CASE_FLT_FN_FLOATN_NX (BUILT_IN_LOG10): > return get_domain (0, true, false, > 0, false, false); > CASE_FLT_FN (BUILT_IN_LOG1P): > + CASE_FLT_FN_FLOATN_NX (BUILT_IN_LOG1P): > return get_domain (-1, true, false, > 0, false, false); > /* Exp functions. */ > + case BUILT_IN_EXPF16: > + case BUILT_IN_EXPM1F16: > + /* expf: (-inf, 11) */ > + return get_domain (-1, false, false, > + 11, true, false); > case BUILT_IN_EXPF: > case BUILT_IN_EXPM1F: > + case BUILT_IN_EXPF32: > + case BUILT_IN_EXPM1F32: > /* expf: (-inf, 88) */ > return get_domain (-1, false, false, > 88, true, false); > @@ -736,18 +765,35 @@ get_no_error_domain (enum built_in_funct > case BUILT_IN_EXPM1: > case BUILT_IN_EXPL: > case BUILT_IN_EXPM1L: > + case BUILT_IN_EXPF64: > + case BUILT_IN_EXPM1F64: > /* exp: (-inf, 709) */ > return get_domain (-1, false, false, > 709, true, false); > + case BUILT_IN_EXPF128: > + case BUILT_IN_EXPM1F128: > + /* expf128: (-inf, 11356) */ > + return get_domain (-1, false, false, > + 11356, true, false); > + case BUILT_IN_EXP2F16: > + /* exp2f16: (-inf, 16) */ > + return get_domain (-1, false, false, > + 16, true, false); > case BUILT_IN_EXP2F: > + case BUILT_IN_EXP2F32: > /* exp2f: (-inf, 128) */ > return get_domain (-1, false, false, > 128, true, false); > case BUILT_IN_EXP2: > case BUILT_IN_EXP2L: > + case BUILT_IN_EXP2F64: > /* exp2: (-inf, 1024) */ > return get_domain (-1, false, false, > 1024, true, false); > + case BUILT_IN_EXP2F128: > + /* exp2f128: (-inf, 16384) */ > + return get_domain (-1, false, false, > + 16384, true, false); > case BUILT_IN_EXP10F: > case BUILT_IN_POW10F: > /* exp10f: (-inf, 38) */ > --- gcc/testsuite/gcc.dg/pr107547.c.jj 2022-11-07 15:01:29.836952863 +0100 > +++ gcc/testsuite/gcc.dg/pr107547.c 2022-11-07 15:00:22.878866103 +0100 > @@ -0,0 +1,40 @@ > +/* PR tree-optimization/107547 */ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > + > +int x; > + > +void > +foo (void) > +{ > +#define TEST(...) \ > + __builtin_acos##__VA_ARGS__ (x); \ > + __builtin_asin##__VA_ARGS__ (x); \ > + __builtin_acosh##__VA_ARGS__ (x); \ > + __builtin_atanh##__VA_ARGS__ (x); \ > + __builtin_cosh##__VA_ARGS__ (x); \ > + __builtin_sinh##__VA_ARGS__ (x); \ > + __builtin_log##__VA_ARGS__ (x); \ > + __builtin_log2##__VA_ARGS__ (x); \ > + __builtin_log10##__VA_ARGS__ (x); \ > + __builtin_log1p##__VA_ARGS__ (x); \ > + __builtin_exp##__VA_ARGS__ (x); \ > + __builtin_expm1##__VA_ARGS__ (x); \ > + __builtin_exp2##__VA_ARGS__ (x); \ > + __builtin_sqrt##__VA_ARGS__ (x) > + TEST (f); > + TEST (); > + TEST (l); > +#ifdef __FLT16_MAX__ > + TEST (f16); > +#endif > +#ifdef __FLT32_MAX__ > + TEST (f32); > +#endif > +#ifdef __FLT64_MAX__ > + TEST (f64); > +#endif > +#ifdef __FLT128_MAX__ > + TEST (f128); > +#endif > +} > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)